BigW Consortium Gitlab

system_note_helper.rb 948 Bytes
Newer Older
1
module SystemNoteHelper
2
  ICON_NAMES_BY_ACTION = {
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
    'commit' => 'commit',
    'description' => 'pencil',
    'merge' => 'git-merge',
    'merged' => 'git-merge',
    'opened' => 'issue-open',
    'closed' => 'issue-close',
    'time_tracking' => 'timer',
    'assignee' => 'user',
    'title' => 'pencil',
    'task' => 'task-done',
    'label' => 'label',
    'cross_reference' => 'comment-dots',
    'branch' => 'fork',
    'confidential' => 'eye-slash',
    'visible' => 'eye',
    'milestone' => 'clock',
    'discussion' => 'comment',
    'moved' => 'arrow-right',
    'outdated' => 'pencil',
22
    'duplicate' => 'issue-duplicate',
23 24
    'locked' => 'lock',
    'unlocked' => 'lock-open'
25
  }.freeze
26

27 28 29 30
  def system_note_icon_name(note)
    ICON_NAMES_BY_ACTION[note.system_note_metadata&.action]
  end

31
  def icon_for_system_note(note)
32
    icon_name = system_note_icon_name(note)
33
    sprite_icon(icon_name) if icon_name
34
  end
35 36

  extend self
37
end