2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module SystemNoteHelper
|
|
|
|
ICON_NAMES_BY_ACTION = {
|
2023-06-20 00:43:36 +05:30
|
|
|
'approved' => 'check',
|
2021-01-03 14:25:43 +05:30
|
|
|
'unapproved' => 'unapproval',
|
2020-04-08 14:13:33 +05:30
|
|
|
'cherry_pick' => 'cherry-pick-commit',
|
2018-03-17 18:26:18 +05:30
|
|
|
'commit' => 'commit',
|
2022-07-23 23:45:48 +05:30
|
|
|
'description' => 'pencil',
|
2023-06-20 00:43:36 +05:30
|
|
|
'merge' => 'merge',
|
|
|
|
'merged' => 'merge',
|
2020-11-24 15:15:51 +05:30
|
|
|
'opened' => 'issues',
|
2018-03-17 18:26:18 +05:30
|
|
|
'closed' => 'issue-close',
|
|
|
|
'time_tracking' => 'timer',
|
|
|
|
'assignee' => 'user',
|
2021-01-03 14:25:43 +05:30
|
|
|
'reviewer' => 'user',
|
2022-07-23 23:45:48 +05:30
|
|
|
'title' => 'pencil',
|
2018-03-17 18:26:18 +05:30
|
|
|
'task' => 'task-done',
|
|
|
|
'label' => 'label',
|
|
|
|
'cross_reference' => 'comment-dots',
|
|
|
|
'branch' => 'fork',
|
|
|
|
'confidential' => 'eye-slash',
|
|
|
|
'visible' => 'eye',
|
|
|
|
'milestone' => 'clock',
|
|
|
|
'discussion' => 'comment',
|
|
|
|
'moved' => 'arrow-right',
|
2022-07-23 23:45:48 +05:30
|
|
|
'outdated' => 'pencil',
|
2019-10-12 21:52:04 +05:30
|
|
|
'pinned_embed' => 'thumbtack',
|
2020-04-08 14:13:33 +05:30
|
|
|
'duplicate' => 'duplicate',
|
2018-03-17 18:26:18 +05:30
|
|
|
'locked' => 'lock',
|
2018-11-20 20:47:30 +05:30
|
|
|
'unlocked' => 'lock-open',
|
2020-04-22 19:07:51 +05:30
|
|
|
'due_date' => 'calendar',
|
2022-08-27 11:52:29 +05:30
|
|
|
'start_date_or_due_date' => 'calendar',
|
2020-05-24 23:13:21 +05:30
|
|
|
'health_status' => 'status-health',
|
|
|
|
'designs_added' => 'doc-image',
|
|
|
|
'designs_modified' => 'doc-image',
|
|
|
|
'designs_removed' => 'doc-image',
|
2020-07-28 23:09:34 +05:30
|
|
|
'designs_discussion_added' => 'doc-image',
|
|
|
|
'status' => 'status',
|
2020-11-24 15:15:51 +05:30
|
|
|
'alert_issue_added' => 'issues',
|
2021-01-03 14:25:43 +05:30
|
|
|
'new_alert_added' => 'warning',
|
2021-02-22 17:27:13 +05:30
|
|
|
'severity' => 'information-o',
|
2021-11-11 11:23:49 +05:30
|
|
|
'cloned' => 'documents',
|
2022-07-23 23:45:48 +05:30
|
|
|
'issue_type' => 'pencil',
|
2022-07-16 23:28:13 +05:30
|
|
|
'contact' => 'users',
|
2022-10-11 01:57:18 +05:30
|
|
|
'timeline_event' => 'clock',
|
|
|
|
'relate_to_child' => 'link',
|
|
|
|
'unrelate_from_child' => 'link',
|
|
|
|
'relate_to_parent' => 'link',
|
|
|
|
'unrelate_from_parent' => 'link'
|
2017-08-17 22:00:37 +05:30
|
|
|
}.freeze
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def system_note_icon_name(note)
|
2023-06-20 00:43:36 +05:30
|
|
|
if note.system_note_metadata&.action == 'closed' && note.for_merge_request?
|
|
|
|
'merge-request-close'
|
|
|
|
else
|
|
|
|
ICON_NAMES_BY_ACTION[note.system_note_metadata&.action]
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def icon_for_system_note(note)
|
2018-03-17 18:26:18 +05:30
|
|
|
icon_name = system_note_icon_name(note)
|
|
|
|
sprite_icon(icon_name) if icon_name
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
extend self
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
SystemNoteHelper.prepend_mod_with('SystemNoteHelper')
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
# The methods in `EE::SystemNoteHelper` should be available as both instance and
|
|
|
|
# class methods.
|
2021-06-08 01:23:25 +05:30
|
|
|
SystemNoteHelper.extend_mod_with('SystemNoteHelper')
|