2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
class Admin::ServicesController < Admin::ApplicationController
|
2016-08-24 12:49:21 +05:30
|
|
|
include ServiceParams
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
before_action :service, only: [:edit, :update]
|
2020-07-28 23:09:34 +05:30
|
|
|
before_action :whitelist_query_limiting, only: [:index]
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
def index
|
2020-04-22 19:07:51 +05:30
|
|
|
@services = Service.find_or_create_templates.sort_by(&:title)
|
2020-11-24 15:15:51 +05:30
|
|
|
@existing_instance_types = Service.for_instance.pluck(:type) # rubocop: disable CodeReuse/ActiveRecord
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2020-07-28 23:09:34 +05:30
|
|
|
if service.nil? || Service.instance_exists_for?(service.type)
|
2015-04-26 12:48:37 +05:30
|
|
|
redirect_to admin_application_settings_services_path,
|
|
|
|
alert: "Service is unknown or it doesn't exist"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2018-11-18 11:00:15 +05:30
|
|
|
if service.update(service_params[:service])
|
2020-03-13 15:44:24 +05:30
|
|
|
PropagateServiceTemplateWorker.perform_async(service.id) if service.active? # rubocop:disable CodeReuse/Worker
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
redirect_to admin_application_settings_services_path,
|
|
|
|
notice: 'Application settings saved successfully'
|
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2015-04-26 12:48:37 +05:30
|
|
|
def service
|
2020-04-22 19:07:51 +05:30
|
|
|
@service ||= Service.find_by(id: params[:id], template: true)
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
def whitelist_query_limiting
|
|
|
|
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/220357')
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|