summaryrefslogtreecommitdiff
path: root/lib/gitlab/slash_commands/presenters/issue_close.rb
blob: f8d9af2c3c6177913727c6f764698355ba1b0a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Gitlab
  module SlashCommands
    module Presenters
      class IssueClose < Presenters::Base
        include Presenters::IssueBase

        def present
          if resource.confidential?
            ephemeral_response(response_message)
          else
            in_channel_response(response_message)
          end
        end

        def already_closed
          ephemeral_response(text: "Issue #{resource.to_reference} is already closed.")
        end

        private

        def fallback_message
          "Closed issue #{issue.to_reference}: #{issue.title}"
        end

        def pretext
          "I closed an issue on #{author_profile_link}'s behalf: *#{issue.to_reference}* in #{project_link}"
        end
      end
    end
  end
end