2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-31 15:51:49 +00:00
|
|
|
module SystemNoteHelper
|
2017-04-06 20:59:47 +00:00
|
|
|
ICON_NAMES_BY_ACTION = {
|
2020-09-30 12:09:53 +00:00
|
|
|
'approved' => 'approval',
|
|
|
|
'unapproved' => 'unapproval',
|
2020-02-27 15:09:24 +00:00
|
|
|
'cherry_pick' => 'cherry-pick-commit',
|
2017-09-22 08:39:47 +00:00
|
|
|
'commit' => 'commit',
|
2018-04-28 00:20:40 +00:00
|
|
|
'description' => 'pencil-square',
|
2017-09-22 08:39:47 +00:00
|
|
|
'merge' => 'git-merge',
|
|
|
|
'merged' => 'git-merge',
|
2020-09-10 18:08:54 +00:00
|
|
|
'opened' => 'issues',
|
2017-09-22 08:39:47 +00:00
|
|
|
'closed' => 'issue-close',
|
|
|
|
'time_tracking' => 'timer',
|
|
|
|
'assignee' => 'user',
|
2020-09-24 09:09:35 +00:00
|
|
|
'reviewer' => 'user',
|
2018-04-28 00:20:40 +00:00
|
|
|
'title' => 'pencil-square',
|
2017-09-22 08:39:47 +00: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-28 00:20:40 +00:00
|
|
|
'outdated' => 'pencil-square',
|
2019-07-20 09:06:19 +00:00
|
|
|
'pinned_embed' => 'thumbtack',
|
2020-03-04 00:07:52 +00:00
|
|
|
'duplicate' => 'duplicate',
|
2017-09-27 12:35:42 +00:00
|
|
|
'locked' => 'lock',
|
2018-09-09 18:08:21 +00:00
|
|
|
'unlocked' => 'lock-open',
|
2020-04-01 06:07:50 +00:00
|
|
|
'due_date' => 'calendar',
|
2020-05-12 21:08:14 +00:00
|
|
|
'health_status' => 'status-health',
|
|
|
|
'designs_added' => 'doc-image',
|
|
|
|
'designs_modified' => 'doc-image',
|
|
|
|
'designs_removed' => 'doc-image',
|
2020-07-09 03:09:01 +00:00
|
|
|
'designs_discussion_added' => 'doc-image',
|
2020-07-09 21:09:33 +00:00
|
|
|
'status' => 'status',
|
2020-08-27 18:10:29 +00:00
|
|
|
'alert_issue_added' => 'issues',
|
2020-09-21 21:09:27 +00:00
|
|
|
'new_alert_added' => 'warning',
|
|
|
|
'severity' => 'information-o'
|
2017-04-06 20:59:47 +00:00
|
|
|
}.freeze
|
2017-03-31 15:51:49 +00:00
|
|
|
|
2017-06-09 21:24:54 +00:00
|
|
|
def system_note_icon_name(note)
|
|
|
|
ICON_NAMES_BY_ACTION[note.system_note_metadata&.action]
|
|
|
|
end
|
|
|
|
|
2017-04-06 20:59:47 +00:00
|
|
|
def icon_for_system_note(note)
|
2017-06-09 21:24:54 +00:00
|
|
|
icon_name = system_note_icon_name(note)
|
2017-09-22 08:39:47 +00:00
|
|
|
sprite_icon(icon_name) if icon_name
|
2017-03-31 15:51:49 +00:00
|
|
|
end
|
2017-06-09 21:24:54 +00:00
|
|
|
|
|
|
|
extend self
|
2017-03-31 15:51:49 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
2020-05-12 15:10:33 +00:00
|
|
|
SystemNoteHelper.prepend_if_ee('EE::SystemNoteHelper')
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
# The methods in `EE::SystemNoteHelper` should be available as both instance and
|
|
|
|
# class methods.
|
|
|
|
SystemNoteHelper.extend_if_ee('EE::SystemNoteHelper')
|