2017-01-19 03:22:09 -05:00
|
|
|
module Gitlab
|
2017-05-31 01:50:53 -04:00
|
|
|
module SlashCommands
|
2017-01-19 03:22:09 -05:00
|
|
|
module Presenters
|
2017-01-26 09:30:34 -05:00
|
|
|
class IssueShow < Presenters::Base
|
2017-02-08 10:42:27 -05:00
|
|
|
include Presenters::IssueBase
|
2017-01-26 09:30:34 -05:00
|
|
|
|
2017-01-19 03:22:09 -05:00
|
|
|
def present
|
2017-01-30 06:12:57 -05:00
|
|
|
if @resource.confidential?
|
|
|
|
ephemeral_response(show_issue)
|
|
|
|
else
|
|
|
|
in_channel_response(show_issue)
|
|
|
|
end
|
2017-01-19 03:22:09 -05:00
|
|
|
end
|
2017-01-10 13:43:58 -05:00
|
|
|
|
2017-01-19 03:22:09 -05:00
|
|
|
private
|
2017-01-10 13:43:58 -05:00
|
|
|
|
2017-01-19 03:22:09 -05:00
|
|
|
def show_issue
|
2017-01-10 13:43:58 -05:00
|
|
|
{
|
2017-01-19 03:22:09 -05:00
|
|
|
attachments: [
|
|
|
|
{
|
|
|
|
title: "#{@resource.title} · #{@resource.to_reference}",
|
|
|
|
title_link: resource_url,
|
|
|
|
author_name: author.name,
|
|
|
|
author_icon: author.avatar_url,
|
2017-01-26 09:30:34 -05:00
|
|
|
fallback: "Issue #{@resource.to_reference}: #{@resource.title}",
|
2017-01-19 03:22:09 -05:00
|
|
|
pretext: pretext,
|
|
|
|
text: text,
|
|
|
|
color: color(@resource),
|
|
|
|
fields: fields,
|
|
|
|
mrkdwn_in: [
|
|
|
|
:pretext,
|
2017-01-30 06:12:57 -05:00
|
|
|
:text,
|
|
|
|
:fields
|
2017-01-19 03:22:09 -05:00
|
|
|
]
|
|
|
|
}
|
2017-01-10 13:43:58 -05:00
|
|
|
]
|
|
|
|
}
|
2017-01-19 03:22:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def text
|
|
|
|
message = "**#{status_text(@resource)}**"
|
|
|
|
|
|
|
|
if @resource.upvotes.zero? && @resource.downvotes.zero? && @resource.user_notes_count.zero?
|
|
|
|
return message
|
|
|
|
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?
|
2017-01-10 13:43:58 -05:00
|
|
|
|
2017-01-19 03:22:09 -05:00
|
|
|
message
|
|
|
|
end
|
2017-01-10 13:43:58 -05:00
|
|
|
|
2017-01-19 03:22:09 -05:00
|
|
|
def pretext
|
2017-01-30 06:12:57 -05:00
|
|
|
"Issue *#{@resource.to_reference}* from #{project.name_with_namespace}"
|
2017-01-19 03:22:09 -05:00
|
|
|
end
|
|
|
|
end
|
2017-01-10 13:43:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|