2018-07-25 05:30:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-02-11 20:34:41 -05:00
|
|
|
class Admin::ServicesController < Admin::ApplicationController
|
2021-05-04 02:10:20 -04:00
|
|
|
include Integrations::Params
|
2016-07-12 16:00:49 -04:00
|
|
|
|
2021-05-04 02:10:20 -04:00
|
|
|
before_action :integration, only: [:edit, :update]
|
2021-03-16 14:11:53 -04:00
|
|
|
before_action :disable_query_limiting, only: [:index]
|
2015-02-11 20:34:41 -05:00
|
|
|
|
2020-10-05 17:08:47 -04:00
|
|
|
feature_category :integrations
|
|
|
|
|
2015-02-11 20:34:41 -05:00
|
|
|
def index
|
2021-04-13 05:11:10 -04:00
|
|
|
@activated_services = Service.for_template.active.sort_by(&:title)
|
2020-08-26 08:10:53 -04:00
|
|
|
@existing_instance_types = Service.for_instance.pluck(:type) # rubocop: disable CodeReuse/ActiveRecord
|
2015-02-11 20:34:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2021-05-04 02:10:20 -04:00
|
|
|
if integration.nil? || Service.instance_exists_for?(integration.type)
|
2015-02-11 20:34:41 -05:00
|
|
|
redirect_to admin_application_settings_services_path,
|
|
|
|
alert: "Service is unknown or it doesn't exist"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2021-05-04 02:10:20 -04:00
|
|
|
if integration.update(integration_params[:integration])
|
|
|
|
PropagateServiceTemplateWorker.perform_async(integration.id) if integration.active? # rubocop:disable CodeReuse/Worker
|
2017-05-04 12:11:28 -04:00
|
|
|
|
2015-02-11 20:34:41 -05:00
|
|
|
redirect_to admin_application_settings_services_path,
|
|
|
|
notice: 'Application settings saved successfully'
|
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2021-05-04 02:10:20 -04:00
|
|
|
def integration
|
|
|
|
@integration ||= Service.find_by(id: params[:id], template: true)
|
|
|
|
@service ||= @integration # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/329759
|
2015-02-11 20:34:41 -05:00
|
|
|
end
|
2021-05-04 02:10:20 -04:00
|
|
|
alias_method :service, :integration
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2020-06-19 20:08:42 -04:00
|
|
|
|
2021-03-16 14:11:53 -04:00
|
|
|
def disable_query_limiting
|
|
|
|
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/220357')
|
2020-06-19 20:08:42 -04:00
|
|
|
end
|
2015-02-11 20:34:41 -05:00
|
|
|
end
|