BigW Consortium Gitlab

issue_base.rb 1.01 KB
Newer Older
Z.J. van de Weg committed
1
module Gitlab
2
  module SlashCommands
Z.J. van de Weg committed
3
    module Presenters
4
      module IssueBase
Z.J. van de Weg committed
5 6 7
        def color(issuable)
          issuable.open? ? '#38ae67' : '#d22852'
        end
8

Z.J. van de Weg committed
9 10 11 12 13
        def status_text(issuable)
          issuable.open? ? 'Open' : 'Closed'
        end

        def project
14
          resource.project
Z.J. van de Weg committed
15 16 17
        end

        def author
18
          resource.author
Z.J. van de Weg committed
19
        end
20

Z.J. van de Weg committed
21 22 23 24
        def fields
          [
            {
              title: "Assignee",
25
              value: resource.assignees.any? ? resource.assignees.first.name : "_None_",
Z.J. van de Weg committed
26 27 28 29
              short: true
            },
            {
              title: "Milestone",
30
              value: resource.milestone ? resource.milestone.title : "_None_",
Z.J. van de Weg committed
31 32 33 34
              short: true
            },
            {
              title: "Labels",
35
              value: resource.labels.any? ? resource.label_names.join(', ') : "_None_",
Z.J. van de Weg committed
36 37 38 39
              short: true
            }
          ]
        end
40 41 42 43

        private

        attr_reader :resource
Z.J. van de Weg committed
44
      end
45 46 47
    end
  end
end