debian-mirror-gitlab/lib/gitlab/slash_commands/presenters/issue_base.rb

54 lines
1.2 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Gitlab
2017-09-10 17:25:29 +05:30
module SlashCommands
2017-08-17 22:00:37 +05:30
module Presenters
module IssueBase
def color(issuable)
issuable.open? ? '#38ae67' : '#d22852'
end
def status_text(issuable)
issuable.open? ? 'Open' : 'Closed'
end
def project
2018-03-17 18:26:18 +05:30
resource.project
2017-08-17 22:00:37 +05:30
end
def author
2018-03-17 18:26:18 +05:30
resource.author
2017-08-17 22:00:37 +05:30
end
def fields
[
{
title: "Assignee",
2018-03-17 18:26:18 +05:30
value: resource.assignees.any? ? resource.assignees.first.name : "_None_",
2017-08-17 22:00:37 +05:30
short: true
},
{
title: "Milestone",
2018-03-17 18:26:18 +05:30
value: resource.milestone ? resource.milestone.title : "_None_",
2017-08-17 22:00:37 +05:30
short: true
},
{
title: "Labels",
2018-03-17 18:26:18 +05:30
value: resource.labels.any? ? resource.label_names.join(', ') : "_None_",
2017-08-17 22:00:37 +05:30
short: true
}
]
end
2018-03-17 18:26:18 +05:30
private
attr_reader :resource
2020-01-01 13:55:28 +05:30
alias_method :issue, :resource
2017-08-17 22:00:37 +05:30
end
end
end
end
2020-05-24 23:13:21 +05:30
2021-06-08 01:23:25 +05:30
Gitlab::SlashCommands::Presenters::IssueBase.prepend_mod_with('Gitlab::SlashCommands::Presenters::IssueBase')