2018-12-23 12:14:25 +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
|
|
|
|
class IssueShow < Presenters::Base
|
|
|
|
include Presenters::IssueBase
|
|
|
|
|
|
|
|
def present
|
|
|
|
if @resource.confidential?
|
|
|
|
ephemeral_response(show_issue)
|
|
|
|
else
|
|
|
|
in_channel_response(show_issue)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def show_issue
|
|
|
|
{
|
|
|
|
attachments: [
|
|
|
|
{
|
|
|
|
title: "#{@resource.title} · #{@resource.to_reference}",
|
|
|
|
title_link: resource_url,
|
|
|
|
author_name: author.name,
|
|
|
|
author_icon: author.avatar_url,
|
|
|
|
fallback: "Issue #{@resource.to_reference}: #{@resource.title}",
|
|
|
|
pretext: pretext,
|
|
|
|
text: text,
|
|
|
|
color: color(@resource),
|
|
|
|
fields: fields,
|
|
|
|
mrkdwn_in: [
|
|
|
|
:pretext,
|
|
|
|
:text,
|
|
|
|
:fields
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def text
|
2018-12-23 12:14:25 +05:30
|
|
|
message = ["**#{status_text(@resource)}**"]
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
if @resource.upvotes.zero? && @resource.downvotes.zero? && @resource.user_notes_count.zero?
|
2018-12-23 12:14:25 +05:30
|
|
|
return message.join
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
message << " · "
|
|
|
|
message << ":+1: #{@resource.upvotes} " unless @resource.upvotes.zero?
|
|
|
|
message << ":-1: #{@resource.downvotes} " unless @resource.downvotes.zero?
|
|
|
|
message << ":speech_balloon: #{@resource.user_notes_count}" unless @resource.user_notes_count.zero?
|
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
message.join
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def pretext
|
2018-03-27 19:54:05 +05:30
|
|
|
"Issue *#{@resource.to_reference}* from #{project.full_name}"
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|