diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-05-31 00:50:53 -0500 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-06-15 09:01:56 -0500 |
commit | ea090291bba6bb665b3631cc5a2659e6673a6959 (patch) | |
tree | 1daf4c15aee8afc0eebef94a345eb077d0390632 /lib/gitlab/slash_commands/command.rb | |
parent | 42aaae9916b7b76da968579fcc722067947df018 (diff) | |
download | gitlab-ce-ea090291bba6bb665b3631cc5a2659e6673a6959.tar.gz |
Rename "Slash commands" to "Quick actions"
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/27070
Deprecate "chat commands" in favor of "slash commands"
We looked for things like:
- `slash commmand`
- `slash_command`
- `slash-command`
- `SlashCommand`
Diffstat (limited to 'lib/gitlab/slash_commands/command.rb')
-rw-r--r-- | lib/gitlab/slash_commands/command.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/gitlab/slash_commands/command.rb b/lib/gitlab/slash_commands/command.rb new file mode 100644 index 00000000000..a78408b0519 --- /dev/null +++ b/lib/gitlab/slash_commands/command.rb @@ -0,0 +1,44 @@ +module Gitlab + module SlashCommands + class Command < BaseCommand + COMMANDS = [ + Gitlab::SlashCommands::IssueShow, + Gitlab::SlashCommands::IssueNew, + Gitlab::SlashCommands::IssueSearch, + Gitlab::SlashCommands::Deploy + ].freeze + + def execute + command, match = match_command + + if command + if command.allowed?(project, current_user) + command.new(project, current_user, params).execute(match) + else + Gitlab::SlashCommands::Presenters::Access.new.access_denied + end + else + Gitlab::SlashCommands::Help.new(project, current_user, params).execute(available_commands, params[:text]) + end + end + + def match_command + match = nil + service = + available_commands.find do |klass| + match = klass.match(params[:text]) + end + + [service, match] + end + + private + + def available_commands + COMMANDS.select do |klass| + klass.available?(project) + end + end + end + end +end |