diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index 5cd3fb7d..b7a482fd 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -5,32 +5,23 @@ .event_label { &.pushed { padding:0 2px; - @extend .alert; - @extend .alert-info; } &.opened { padding:0 2px; - @extend .alert; - @extend .alert-success; } &.closed { padding:0 2px; - @extend .alert; - @extend .alert-error; } &.merged { padding:0 2px; - @extend .alert; - @extend .alert-success; } &.left, &.joined { padding:0 2px; - @extend .alert; float:none; } } diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb new file mode 100644 index 00000000..9ad438dc --- /dev/null +++ b/app/helpers/events_helper.rb @@ -0,0 +1,22 @@ +module EventsHelper + def link_to_author(event) + project = event.project + tm = project.team_member_by_id(event.author_id) + + if tm + link_to event.author_name, project_team_member_path(project, tm) + else + event.author_name + end + end + + def event_action_name(event) + target = if event.target_type + event.target_type.titleize.downcase + else + 'project' + end + + [event.action_name, target].join(" ") + end +end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index d4d6c2d4..9b537187 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -33,7 +33,7 @@ module IssuesHelper classes end - def issue_tags + def issue_tags @project.issues.tag_counts_on(:labels).map(&:name) end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index c7dc54ee..468ace15 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -6,5 +6,9 @@ module ProjectsHelper def remove_from_team_message(project, member) "You are going to remove #{member.user_name} from #{project.name}. Are you sure?" end + + def link_to_project project + link_to project.name, project + end end diff --git a/app/models/event.rb b/app/models/event.rb index 535e778d..40f584dd 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -58,6 +58,10 @@ class Event < ActiveRecord::Base end end + def target_title + target.try :title + end + def push? action == self.class::Pushed && valid_push? end diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index 716a214b..cdc24204 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -1,16 +1,9 @@ - if event.allowed? %div.event-item - - if event.issue? - = render "events/event_issue", event: event - - - elsif event.merge_request? - = render "events/event_merge_request", event: event - - - elsif event.push? + - if event.push? = render "events/event_push", event: event - - - elsif event.membership_changed? - = render "events/event_membership_changed", event: event + - else + = render "events/event_common", event: event %span.cgray.right = time_ago_in_words(event.created_at) diff --git a/app/views/events/_event_common.html.haml b/app/views/events/_event_common.html.haml new file mode 100644 index 00000000..0f9a86e9 --- /dev/null +++ b/app/views/events/_event_common.html.haml @@ -0,0 +1,8 @@ += 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) + = link_to [event.project, event.target] do + %strong= truncate event.target_title + at + = link_to_project event.project diff --git a/app/views/events/_event_issue.html.haml b/app/views/events/_event_issue.html.haml deleted file mode 100644 index 60e82c4d..00000000 --- a/app/views/events/_event_issue.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -= image_tag gravatar_icon(event.author_email), class: "avatar" -.event-title - %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name} #{event.action_name} issue - = link_to project_issue_path(event.project, event.issue) do - %strong= truncate event.issue_title - at - %strong= link_to event.project.name, event.project diff --git a/app/views/events/_event_membership_changed.html.haml b/app/views/events/_event_membership_changed.html.haml deleted file mode 100644 index e89065b9..00000000 --- a/app/views/events/_event_membership_changed.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -= image_tag gravatar_icon(event.author_email), class: "avatar" -.event-title - %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name} #{event.action_name} project - %strong= link_to event.project_name, event.project - %span.cgray - = time_ago_in_words(event.created_at) - ago. - diff --git a/app/views/events/_event_merge_request.html.haml b/app/views/events/_event_merge_request.html.haml deleted file mode 100644 index 655337f3..00000000 --- a/app/views/events/_event_merge_request.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -- if event.action_name == "merged" - .event_icon= image_tag "event_mr_merged.png" -= image_tag gravatar_icon(event.author_email), class: "avatar" -.event-title - %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name} #{event.action_name} merge request - = link_to project_merge_request_path(event.project, event.merge_request) do - %strong= truncate event.merge_request_title - at - %strong= link_to event.project.name, event.project -.event-body - .event-info - %span= event.merge_request.source_branch - → - %span= event.merge_request.target_branch - diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index b5273b54..caf1b2c5 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -3,7 +3,7 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" .event-title - %strong.author_name #{event.author_name} + %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