Commit f0889bdf authored by Z.J. van de Weg's avatar Z.J. van de Weg

Incorporate review

parent 7363a7d3
......@@ -3,7 +3,7 @@ class Projects::ServicesController < Projects::ApplicationController
# Authorize
before_action :authorize_admin_project!
before_action :service, only: [:edit, :update, :test, :configure]
before_action :service, only: [:edit, :update, :test]
respond_to :html
......
......@@ -25,15 +25,12 @@ class MattermostSlashCommandsService < ChatService
]
end
def configure(host, current_user, team_id:, trigger:, url:, icon_url:)
def configure(host, current_user, params)
new_token = Mattermost::Session.new(host, current_user).with_session do
Mattermost::Command.create(team_id,
trigger: trigger || @service.project.path,
url: url,
icon_url: icon_url)
Mattermost::Command.create(params[:team_id], command)
end
update!(token: new_token)
update!(token: new_token, active: true)
end
def trigger(params)
......@@ -50,6 +47,23 @@ class MattermostSlashCommandsService < ChatService
private
def command(trigger:, url:, icon_url:)
pretty_project_name = project.name_with_namespace
{
auto_complete: true,
auto_complete_desc: "Perform common operations on: #{pretty_project_name}",
auto_complete_hint: '[help]',
description: "Perform common operations on: #{pretty_project_name}",
display_name: "GitLab / #{pretty_project_name}",
method: 'P',
user_name: 'GitLab',
trigger: trigger,
url: url,
icon_url: icon_url
}
end
def find_chat_user(params)
ChatNames::FindUserService.new(self, params).execute
end
......
= "hello world"
= @teams
= form_for(:create, method: :post, url: configure_namespace_project_mattermost_path(@project.namespace, @project, )) do |f|
= "Team ID"
= f.text_field(:team_id)
......
module Mattermost
class Command < Session
def self.create(team_id, trigger: 'gitlab', url:, icon_url:)
command = {
auto_complete: true,
auto_complete_desc: 'List all available commands',
auto_complete_hint: '[help]',
description: 'Perform common operations on GitLab',
display_name: 'GitLab Slash Commands',
method: 'P',
user_name: 'GitLab',
trigger: trigger,
url: url,
icon_url: icon_url
}
post_command(command)['token']
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment