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

60 lines
1.4 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
2019-12-04 20:38:33 +05:30
prepend_if_ee('EE::Gitlab::SlashCommands::Presenters::IssueBase') # rubocop: disable Cop/InjectEnterpriseEditionModule
2017-08-17 22:00:37 +05:30
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
2019-12-04 20:38:33 +05:30
def project_link
"[#{project.full_name}](#{project.web_url})"
end
def author_profile_link
"[#{author.to_reference}](#{url_for(author)})"
end
2018-03-17 18:26:18 +05:30
private
attr_reader :resource
2017-08-17 22:00:37 +05:30
end
end
end
end