Refactoring event views
This commit is contained in:
parent
663dd6fad6
commit
69751aac32
|
@ -19,4 +19,18 @@ module EventsHelper
|
|||
|
||||
[event.action_name, target].join(" ")
|
||||
end
|
||||
|
||||
def event_image event
|
||||
event_image_path = if event.push?
|
||||
"event_push.png"
|
||||
elsif event.merged?
|
||||
"event_mr_merged.png"
|
||||
end
|
||||
|
||||
return nil unless event_image_path
|
||||
|
||||
content_tag :div, class: 'event_icon' do
|
||||
image_tag event_image_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
- if event.allowed?
|
||||
%div.event-item
|
||||
- if event.push?
|
||||
= render "events/event_push", event: event
|
||||
- else
|
||||
= render "events/event_common", event: event
|
||||
= event_image(event)
|
||||
= image_tag gravatar_icon(event.author_email), class: "avatar"
|
||||
|
||||
- if event.push?
|
||||
= render "events/event/push", event: event
|
||||
- else
|
||||
= render "events/event/common", event: event
|
||||
|
||||
.clearfix
|
||||
%span.cgray.right
|
||||
= time_ago_in_words(event.created_at)
|
||||
ago.
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
%div
|
||||
.event_icon= image_tag "event_push.png"
|
||||
= image_tag gravatar_icon(event.author_email), class: "avatar"
|
||||
|
||||
.event-title
|
||||
%span.author_name= link_to_author event
|
||||
%span.event_label.pushed #{event.push_action_name} #{event.ref_type}
|
||||
= link_to project_commits_path(event.project, event.ref_name) do
|
||||
%strong= event.ref_name
|
||||
at
|
||||
%strong= link_to event.project.name, event.project
|
||||
|
||||
- if event.push_with_commits?
|
||||
- project = event.project
|
||||
.event-body
|
||||
%ul.unstyled.event_commits
|
||||
- few_commits = event.commits[0...2]
|
||||
- few_commits.each do |commit|
|
||||
= render "events/commit", commit: commit, project: project
|
||||
|
||||
- if event.commits_count > 1
|
||||
%li.commits-stat
|
||||
- if event.commits_count > 2
|
||||
%span ... and #{event.commits_count - 2} more commits.
|
||||
= link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do
|
||||
%strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]}
|
||||
.clearfix
|
|
@ -1,4 +1,3 @@
|
|||
= image_tag gravatar_icon(event.author_email), class: "avatar"
|
||||
.event-title
|
||||
%span.author_name= link_to_author event
|
||||
%span.event_label{class: event.action_name}= event_action_name(event)
|
22
app/views/events/event/_push.html.haml
Normal file
22
app/views/events/event/_push.html.haml
Normal file
|
@ -0,0 +1,22 @@
|
|||
.event-title
|
||||
%span.author_name= link_to_author event
|
||||
%span.event_label.pushed #{event.push_action_name} #{event.ref_type}
|
||||
= link_to project_commits_path(event.project, event.ref_name) do
|
||||
%strong= event.ref_name
|
||||
at
|
||||
%strong= link_to event.project.name, event.project
|
||||
|
||||
- if event.push_with_commits?
|
||||
- project = event.project
|
||||
.event-body
|
||||
%ul.unstyled.event_commits
|
||||
- few_commits = event.commits[0...2]
|
||||
- few_commits.each do |commit|
|
||||
= render "events/commit", commit: commit, project: project
|
||||
|
||||
- if event.commits_count > 1
|
||||
%li.commits-stat
|
||||
- if event.commits_count > 2
|
||||
%span ... and #{event.commits_count - 2} more commits.
|
||||
= link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do
|
||||
%strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]}
|
Loading…
Reference in a new issue