Class: Gitlab::SlashCommands::IssueNew
Constant Summary
Constants inherited
from BaseCommand
BaseCommand::QUERY_LIMIT
Instance Attribute Summary
Attributes inherited from BaseCommand
#chat_name, #current_user, #params, #project
Class Method Summary
collapse
Instance Method Summary
collapse
available?, #collection
Methods inherited from BaseCommand
available?, can?, #collection, #initialize
Class Method Details
.allowed?(project, user) ⇒ Boolean
16
17
18
|
# File 'lib/gitlab/slash_commands/issue_new.rb', line 16
def self.allowed?(project, user)
can?(user, :create_issue, project)
end
|
.help_message ⇒ Object
12
13
14
|
# File 'lib/gitlab/slash_commands/issue_new.rb', line 12
def self.help_message
'issue new <title> *`⇧ Shift`*+*`↵ Enter`* <description>'
end
|
.match(text) ⇒ Object
6
7
8
9
10
|
# File 'lib/gitlab/slash_commands/issue_new.rb', line 6
def self.match(text)
/\Aissue\s+(new|create)\s+(?<title>[^\n]*)\n*(?<description>(.|\n)*)/.match(text)
end
|
Instance Method Details
#execute(match) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/gitlab/slash_commands/issue_new.rb', line 20
def execute(match)
title = match[:title]
description = match[:description].to_s.rstrip
result = create_issue(title: title, description: description)
if result.success?
presenter(result[:issue]).present
elsif result[:issue]
presenter(result[:issue]).display_errors
else
Gitlab::SlashCommands::Presenters::Error.new(
result.errors.join(', ')
).message
end
end
|