diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-17 12:57:27 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-17 21:34:24 +0100 |
commit | 6737ada0c8d980ed1bd8f425e885fa1b89930616 (patch) | |
tree | b2efd37f2450e137c15f5ee433046a7725202cda /lib | |
parent | d4def9cbcd664b7067e7f9f4ea8be54463bd1d50 (diff) | |
download | gitlab-ce-6737ada0c8d980ed1bd8f425e885fa1b89930616.tar.gz |
Remove some commands for now
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/chat_commands/command.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/chat_commands/issue_create.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/chat_commands/issue_search.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/chat_commands/merge_request_command.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/chat_commands/merge_request_search.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/chat_commands/merge_request_show.rb | 17 | ||||
-rw-r--r-- | lib/mattermost/presenter.rb | 12 |
7 files changed, 11 insertions, 79 deletions
diff --git a/lib/gitlab/chat_commands/command.rb b/lib/gitlab/chat_commands/command.rb index f1490c045c3..0ed51d9b8fc 100644 --- a/lib/gitlab/chat_commands/command.rb +++ b/lib/gitlab/chat_commands/command.rb @@ -3,11 +3,7 @@ module Gitlab class Command < BaseCommand COMMANDS = [ Gitlab::ChatCommands::IssueShow, - Gitlab::ChatCommands::IssueSearch, Gitlab::ChatCommands::IssueCreate, - - Gitlab::ChatCommands::MergeRequestShow, - Gitlab::ChatCommands::MergeRequestSearch, ].freeze def execute diff --git a/lib/gitlab/chat_commands/issue_create.rb b/lib/gitlab/chat_commands/issue_create.rb index b5cf85b58f1..0e2b4c0e9cd 100644 --- a/lib/gitlab/chat_commands/issue_create.rb +++ b/lib/gitlab/chat_commands/issue_create.rb @@ -1,10 +1,14 @@ module Gitlab module ChatCommands - class IssueCreate < BaseCommand + class IssueCreate < IssueCommand def self.match(text) /\Aissue\s+create\s+(?<title>[^\n]*)\n*(?<description>.*)\z/.match(text) end + def self.help_message + 'issue create <title>\n<description>' + end + def execute(match) present nil unless can?(current_user, :create_issue, project) diff --git a/lib/gitlab/chat_commands/issue_search.rb b/lib/gitlab/chat_commands/issue_search.rb deleted file mode 100644 index f64f3ad2680..00000000000 --- a/lib/gitlab/chat_commands/issue_search.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Gitlab - module ChatCommands - class IssueSearch < IssueCommand - def self.match(text) - /\Aissue\s+search\s+(?<query>.*)\s*/.match(text) - end - - def self.help_message - "issue search <query>" - end - - def execute(match) - present search_results(match[:query]) - end - end - end -end diff --git a/lib/gitlab/chat_commands/merge_request_command.rb b/lib/gitlab/chat_commands/merge_request_command.rb deleted file mode 100644 index ad485483b8a..00000000000 --- a/lib/gitlab/chat_commands/merge_request_command.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Gitlab - module ChatCommands - class MergeRequestCommand < BaseCommand - def self.available?(project) - project.merge_requests_enabled? - end - - def collection - project.merge_requests - end - - def readable?(merge_request) - can?(current_user, :read_merge_request, merge_request) - end - end - end -end diff --git a/lib/gitlab/chat_commands/merge_request_search.rb b/lib/gitlab/chat_commands/merge_request_search.rb deleted file mode 100644 index 19a29546736..00000000000 --- a/lib/gitlab/chat_commands/merge_request_search.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Gitlab - module ChatCommands - class MergeRequestSearch < MergeRequestCommand - def self.match(text) - /\Amergerequest\s+search\s+(?<query>.*)\s*/.match(text) - end - - def self.help_message - "mergerequest search <query>" - end - - def execute(match) - present search_results(match[:query]) - end - end - end -end diff --git a/lib/gitlab/chat_commands/merge_request_show.rb b/lib/gitlab/chat_commands/merge_request_show.rb deleted file mode 100644 index 7ed5445e4c2..00000000000 --- a/lib/gitlab/chat_commands/merge_request_show.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Gitlab - module ChatCommands - class MergeRequestShow < MergeRequestCommand - def self.match(text) - /\Amergerequest\s+show\s+(?<iid>\d+)/.match(text) - end - - def self.help_message - "mergerequest show <id>" - end - - def execute(match) - present find_by_iid(match[:iid]) - end - end - end -end diff --git a/lib/mattermost/presenter.rb b/lib/mattermost/presenter.rb index 0f2beb2cd6b..b3d6c025109 100644 --- a/lib/mattermost/presenter.rb +++ b/lib/mattermost/presenter.rb @@ -1,6 +1,8 @@ module Mattermost class Presenter class << self + include Rails.application.routes.url_helpers + def authorize_chat_name(url) message = "Hi there! We've yet to get acquainted! Please [introduce yourself](#{url})!" @@ -59,7 +61,7 @@ module Mattermost message = "The action was not succesfull because:\n" message << resource.errors.messages.map { |message| "- #{message}" }.join("\n") - ephemeral_response(resource.errors.messages.join("\n") + ephemeral_response(resource.errors.messages.join("\n")) end def title(resource) @@ -67,14 +69,12 @@ module Mattermost end def url(resource) - polymorphic_url( + url_for( [ resource.project.namespace.becomes(Namespace), resource.project, - resource - ], - id: resource_id, - routing_type: :url + resource + ] ) end |