2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-31 11:51:49 -04:00
|
|
|
module SystemNoteHelper
|
2017-04-06 16:59:47 -04:00
|
|
|
ICON_NAMES_BY_ACTION = {
|
2017-09-22 04:39:47 -04:00
|
|
|
'commit' => 'commit',
|
2018-04-27 20:20:40 -04:00
|
|
|
'description' => 'pencil-square',
|
2017-09-22 04:39:47 -04:00
|
|
|
'merge' => 'git-merge',
|
|
|
|
'merged' => 'git-merge',
|
|
|
|
'opened' => 'issue-open',
|
|
|
|
'closed' => 'issue-close',
|
|
|
|
'time_tracking' => 'timer',
|
|
|
|
'assignee' => 'user',
|
2018-04-27 20:20:40 -04:00
|
|
|
'title' => 'pencil-square',
|
2017-09-22 04:39:47 -04:00
|
|
|
'task' => 'task-done',
|
|
|
|
'label' => 'label',
|
|
|
|
'cross_reference' => 'comment-dots',
|
|
|
|
'branch' => 'fork',
|
|
|
|
'confidential' => 'eye-slash',
|
|
|
|
'visible' => 'eye',
|
|
|
|
'milestone' => 'clock',
|
|
|
|
'discussion' => 'comment',
|
|
|
|
'moved' => 'arrow-right',
|
2018-04-27 20:20:40 -04:00
|
|
|
'outdated' => 'pencil-square',
|
2019-07-20 05:06:19 -04:00
|
|
|
'pinned_embed' => 'thumbtack',
|
2017-09-26 02:56:04 -04:00
|
|
|
'duplicate' => 'issue-duplicate',
|
2017-09-27 08:35:42 -04:00
|
|
|
'locked' => 'lock',
|
2018-09-09 14:08:21 -04:00
|
|
|
'unlocked' => 'lock-open',
|
|
|
|
'due_date' => 'calendar'
|
2017-04-06 16:59:47 -04:00
|
|
|
}.freeze
|
2017-03-31 11:51:49 -04:00
|
|
|
|
2017-06-09 17:24:54 -04:00
|
|
|
def system_note_icon_name(note)
|
|
|
|
ICON_NAMES_BY_ACTION[note.system_note_metadata&.action]
|
|
|
|
end
|
|
|
|
|
2017-04-06 16:59:47 -04:00
|
|
|
def icon_for_system_note(note)
|
2017-06-09 17:24:54 -04:00
|
|
|
icon_name = system_note_icon_name(note)
|
2017-09-22 04:39:47 -04:00
|
|
|
sprite_icon(icon_name) if icon_name
|
2017-03-31 11:51:49 -04:00
|
|
|
end
|
2017-06-09 17:24:54 -04:00
|
|
|
|
|
|
|
extend self
|
2017-03-31 11:51:49 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
SystemNoteHelper.prepend_if_ee('EE::SystemNoteHelper') # rubocop: disable Cop/InjectEnterpriseEditionModule
|
|
|
|
|
|
|
|
# The methods in `EE::SystemNoteHelper` should be available as both instance and
|
|
|
|
# class methods.
|
|
|
|
SystemNoteHelper.extend_if_ee('EE::SystemNoteHelper')
|