Reuse system notes helper for profile event icons

This commit is contained in:
Annabel Dunstone Gray 2017-04-11 12:32:42 -05:00
parent d4c5dc49e0
commit 71b7461f37
7 changed files with 20 additions and 25 deletions

View file

@ -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;
}
}

View file

@ -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

View file

@ -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 }

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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'