diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-13 19:52:41 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-16 12:21:09 +0100 |
commit | 87d160634dfdaacd0dc382c26932786382d1be34 (patch) | |
tree | 3eb381dd13f1ebd0acdf6c5364f9c2639e057b26 /app/controllers | |
parent | dd385c7c3d3046da18c6c251bce25afab1129662 (diff) | |
download | gitlab-ce-87d160634dfdaacd0dc382c26932786382d1be34.tar.gz |
Base work for auto config MM slash commands
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/services_controller.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 30c2a5d9982..94ea36bbdd9 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -3,7 +3,7 @@ class Projects::ServicesController < Projects::ApplicationController # Authorize before_action :authorize_admin_project! - before_action :service, only: [:edit, :update, :test] + before_action :service, only: [:edit, :update, :test, :configure] respond_to :html @@ -44,9 +44,35 @@ class Projects::ServicesController < Projects::ApplicationController redirect_back_or_default(options: message) end + def configure + host = Gitlab.config.mattermost.host + if @service.auto_config? && host + @service.configure(host, current_user, params) + + redirect_to( + edit_namespace_project_service_path(@project.namespace, @project, @service.to_param), + notice: 'This service is now configured.' + ) + else + redirect_to( + edit_namespace_project_service_path(@project.namespace, @project, @service.to_param), + alert: 'This service can not be automatticly configured.' + ) + end + rescue Mattermost::NoSessionError + redirect_to( + edit_namespace_project_service_path(@project.namespace, @project, @service.to_param), + alert: 'An error occurred, is Mattermost configured with Single Sign on?' + ) + end + private def service @service ||= @project.find_or_initialize_service(params[:id]) end + + def configure_params + params.require(:auto_configure).permit(:trigger, :team_id) + end end |