2018-11-19 21:01:13 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
2019-11-29 10:06:43 -05:00
|
|
|
if resource.confidential?
|
|
|
|
ephemeral_response(response_message)
|
2017-01-30 06:12:57 -05:00
|
|
|
else
|
2019-11-29 10:06:43 -05:00
|
|
|
in_channel_response(response_message)
|
2017-01-30 06:12:57 -05:00
|
|
|
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
|
|
|
|
2019-11-29 10:06:43 -05:00
|
|
|
def fallback_message
|
|
|
|
"Issue #{resource.to_reference}: #{resource.title}"
|
2017-01-19 03:22:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def text
|
2019-11-29 10:06:43 -05:00
|
|
|
message = ["**#{status_text(resource)}**"]
|
2017-01-19 03:22:09 -05:00
|
|
|
|
2020-08-05 11:09:59 -04:00
|
|
|
if resource.upvotes == 0 && resource.downvotes == 0 && resource.user_notes_count == 0
|
2018-11-19 21:01:13 -05:00
|
|
|
return message.join
|
2017-01-19 03:22:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
message << " · "
|
2020-08-05 11:09:59 -04:00
|
|
|
message << ":+1: #{resource.upvotes} " unless resource.upvotes == 0
|
|
|
|
message << ":-1: #{resource.downvotes} " unless resource.downvotes == 0
|
|
|
|
message << ":speech_balloon: #{resource.user_notes_count}" unless resource.user_notes_count == 0
|
2017-01-10 13:43:58 -05:00
|
|
|
|
2018-11-19 21:01:13 -05:00
|
|
|
message.join
|
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
|
|
|
def pretext
|
2019-11-29 10:06:43 -05:00
|
|
|
"Issue *#{resource.to_reference}* from #{project.full_name}"
|
2017-01-19 03:22:09 -05:00
|
|
|
end
|
|
|
|
end
|
2017-01-10 13:43:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|