gitlab-org--gitlab-foss/lib/gitlab/slash_commands/presenters/issue_base.rb

50 lines
1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-01-19 03:22:09 -05:00
module Gitlab
module SlashCommands
2017-01-19 03:22:09 -05:00
module Presenters
module IssueBase
2017-01-19 03:22:09 -05:00
def color(issuable)
issuable.open? ? '#38ae67' : '#d22852'
end
2017-01-19 03:22:09 -05:00
def status_text(issuable)
issuable.open? ? 'Open' : 'Closed'
end
def project
resource.project
2017-01-19 03:22:09 -05:00
end
def author
resource.author
2017-01-19 03:22:09 -05:00
end
2017-01-19 03:22:09 -05:00
def fields
[
{
title: "Assignee",
value: resource.assignees.any? ? resource.assignees.first.name : "_None_",
2017-01-19 03:22:09 -05:00
short: true
},
{
title: "Milestone",
value: resource.milestone ? resource.milestone.title : "_None_",
2017-01-19 03:22:09 -05:00
short: true
},
{
title: "Labels",
value: resource.labels.any? ? resource.label_names.join(', ') : "_None_",
2017-01-19 03:22:09 -05:00
short: true
}
]
end
private
attr_reader :resource
2017-01-19 03:22:09 -05:00
end
end
end
end