gitlab-org--gitlab-foss/lib/gitlab/slash_commands/presenters/issue_show.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-01-19 03:22:09 -05:00
module Gitlab
module SlashCommands
2017-01-19 03:22:09 -05:00
module Presenters
2017-01-26 09:30:34 -05:00
class IssueShow < Presenters::Base
include Presenters::IssueBase
2017-01-26 09:30:34 -05:00
2017-01-19 03:22:09 -05:00
def present
if resource.confidential?
ephemeral_response(response_message)
2017-01-30 06:12:57 -05:00
else
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-19 03:22:09 -05:00
private
def fallback_message
"Issue #{resource.to_reference}: #{resource.title}"
2017-01-19 03:22:09 -05:00
end
def text
message = ["**#{status_text(resource)}**"]
2017-01-19 03:22:09 -05:00
if resource.upvotes == 0 && resource.downvotes == 0 && resource.user_notes_count == 0
return message.join
2017-01-19 03:22:09 -05:00
end
message << " · "
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
message.join
2017-01-19 03:22:09 -05:00
end
2017-01-19 03:22:09 -05:00
def pretext
"Issue *#{resource.to_reference}* from #{project.full_name}"
2017-01-19 03:22:09 -05:00
end
end
end
end
end