From 71b7461f371c2257d85ab05c8463e440f569053d Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Tue, 11 Apr 2017 12:32:42 -0500 Subject: Reuse system notes helper for profile event icons --- app/assets/stylesheets/pages/events.scss | 9 ++++++--- app/helpers/system_note_helper.rb | 9 +++++++-- app/views/events/event/_common.html.haml | 13 ++----------- app/views/events/event/_created_project.html.haml | 4 ++-- app/views/events/event/_note.html.haml | 2 +- app/views/events/event/_push.html.haml | 6 +----- app/views/projects/notes/_note.html.haml | 2 +- 7 files changed, 20 insertions(+), 25 deletions(-) (limited to 'app') diff --git a/app/assets/stylesheets/pages/events.scss b/app/assets/stylesheets/pages/events.scss index 6b5cf394d00..5b723f7c722 100644 --- a/app/assets/stylesheets/pages/events.scss +++ b/app/assets/stylesheets/pages/events.scss @@ -39,15 +39,18 @@ fill: $gl-text-color-secondary; } - &.open-icon svg { - fill: $green-300; + &.opened-icon, + &.created-icon { + svg { + fill: $green-300; + } } &.closed-icon svg { fill: $red-300; } - &.fork-icon svg { + &.accepted-icon svg { fill: $blue-300; } } diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb index 1ea60e39386..91673ea5036 100644 --- a/app/helpers/system_note_helper.rb +++ b/app/helpers/system_note_helper.rb @@ -1,9 +1,11 @@ module SystemNoteHelper ICON_NAMES_BY_ACTION = { 'commit' => 'icon_commit', + 'push' => 'icon_commit', 'merge' => 'icon_merge', 'merged' => 'icon_merged', 'opened' => 'icon_status_open', + 'created' => 'icon_status_open', 'closed' => 'icon_status_closed', 'time_tracking' => 'icon_stopwatch', 'assignee' => 'icon_user', @@ -12,15 +14,18 @@ module SystemNoteHelper 'label' => 'icon_tags', 'cross_reference' => 'icon_random', 'branch' => 'icon_code_fork', + 'accepted' => 'icon_code_fork', 'confidential' => 'icon_eye_slash', 'visible' => 'icon_eye', 'milestone' => 'icon_clock_o', 'discussion' => 'icon_comment_o', - 'moved' => 'icon_arrow_circle_o_right' + 'commented on' => 'icon_comment_o', + 'moved' => 'icon_arrow_circle_o_right', + 'deleted' => 'icon_trash_o' }.freeze def icon_for_system_note(note) - icon_name = ICON_NAMES_BY_ACTION[note.system_note_metadata&.action] + icon_name = ICON_NAMES_BY_ACTION[note] custom_icon(icon_name) if icon_name end end diff --git a/app/views/events/event/_common.html.haml b/app/views/events/event/_common.html.haml index 7e18618ab49..b7cb5d3ed63 100644 --- a/app/views/events/event/_common.html.haml +++ b/app/views/events/event/_common.html.haml @@ -1,20 +1,11 @@ - if current_path?('users#show') - if event.target - - case event.action_name - - when 'opened' - .system-note-image.open-icon - = custom_icon("icon_status_open") - - when 'closed' - .system-note-image.closed-icon - = custom_icon("icon_status_closed") - - else - .system-note-image.fork-icon - = custom_icon("icon_code_fork") + .system-note-image{ class: "#{event.action_name}-icon" } + = icon_for_system_note(event.action_name) - else .system-note-image.user-avatar = author_avatar(event, size: 32) - .event-title %span.author_name= link_to_author event %span{ class: event.action_name } diff --git a/app/views/events/event/_created_project.html.haml b/app/views/events/event/_created_project.html.haml index 653aa16ca00..c08c9442fa9 100644 --- a/app/views/events/event/_created_project.html.haml +++ b/app/views/events/event/_created_project.html.haml @@ -1,6 +1,6 @@ - if current_path?('users#show') - .system-note-image.open-icon - = custom_icon("icon_status_open") + .system-note-image{ class: "#{event.action_name}-icon" } + = icon_for_system_note(event.action_name) - else .system-note-image.user-avatar = author_avatar(event, size: 32) diff --git a/app/views/events/event/_note.html.haml b/app/views/events/event/_note.html.haml index 8437ace22b5..d5dcc9339ac 100644 --- a/app/views/events/event/_note.html.haml +++ b/app/views/events/event/_note.html.haml @@ -1,6 +1,6 @@ - if current_path?('users#show') .system-note-image - = custom_icon("icon_comment_o") + = icon_for_system_note(event.action_name) - else .system-note-image.user-avatar = author_avatar(event, size: 32) diff --git a/app/views/events/event/_push.html.haml b/app/views/events/event/_push.html.haml index d67139777a1..be0eb6cb5ee 100644 --- a/app/views/events/event/_push.html.haml +++ b/app/views/events/event/_push.html.haml @@ -1,11 +1,7 @@ - project = event.project - - if current_path?('users#show') .system-note-image - - if event.action_name == "deleted" - = custom_icon("trash_o") - - else - = custom_icon("icon_commit") + = icon_for_system_note(event.data[:event_name]) - else .system-note-image.user-avatar = author_avatar(event, size: 32) diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index c12c05eeb73..5892c1aa3d1 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -6,7 +6,7 @@ .timeline-entry-inner .timeline-icon - if note.system - = icon_for_system_note(note) + = icon_for_system_note(note.system_note_metadata&.action) - else %a{ href: user_path(note.author) } = image_tag avatar_icon(note.author), alt: '', class: 'avatar s40' -- cgit v1.2.3