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 = {
|
2020-02-27 10:09:24 -05:00
|
|
|
'cherry_pick' => 'cherry-pick-commit',
|
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',
|
2020-03-03 19:07:52 -05:00
|
|
|
'duplicate' => 'duplicate',
|
2017-09-27 08:35:42 -04:00
|
|
|
'locked' => 'lock',
|
2018-09-09 14:08:21 -04:00
|
|
|
'unlocked' => 'lock-open',
|
2020-04-01 02:07:50 -04:00
|
|
|
'due_date' => 'calendar',
|
2020-05-12 17:08:14 -04:00
|
|
|
'health_status' => 'status-health',
|
|
|
|
'designs_added' => 'doc-image',
|
|
|
|
'designs_modified' => 'doc-image',
|
|
|
|
'designs_removed' => 'doc-image',
|
2020-07-08 23:09:01 -04:00
|
|
|
'designs_discussion_added' => 'doc-image',
|
2020-07-09 17:09:33 -04:00
|
|
|
'status' => 'status',
|
2020-08-27 14:10:29 -04:00
|
|
|
'alert_issue_added' => 'issues',
|
|
|
|
'new_alert_added' => 'warning'
|
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
|
|
|
|
2020-05-12 11:10:33 -04:00
|
|
|
SystemNoteHelper.prepend_if_ee('EE::SystemNoteHelper')
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
# The methods in `EE::SystemNoteHelper` should be available as both instance and
|
|
|
|
# class methods.
|
|
|
|
SystemNoteHelper.extend_if_ee('EE::SystemNoteHelper')
|