debian-mirror-gitlab/app/controllers/admin/services_controller.rb

48 lines
1.5 KiB
Ruby
Raw Normal View History

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
2021-06-08 01:23:25 +05:30
include Integrations::Params
2016-08-24 12:49:21 +05:30
2021-06-08 01:23:25 +05:30
before_action :integration, only: [:edit, :update]
2021-04-29 21:17:54 +05:30
before_action :disable_query_limiting, only: [:index]
2015-04-26 12:48:37 +05:30
2021-01-03 14:25:43 +05:30
feature_category :integrations
2015-04-26 12:48:37 +05:30
def index
2021-06-08 01:23:25 +05:30
@activated_services = Integration.for_template.active.sort_by(&:title)
@existing_instance_types = Integration.for_instance.pluck(:type) # rubocop: disable CodeReuse/ActiveRecord
2015-04-26 12:48:37 +05:30
end
def edit
2021-06-08 01:23:25 +05:30
if integration.nil? || Integration.instance_exists_for?(integration.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
2021-06-08 01:23:25 +05:30
if integration.update(integration_params[:integration])
PropagateServiceTemplateWorker.perform_async(integration.id) if integration.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
2021-06-08 01:23:25 +05:30
def integration
@integration ||= Integration.find_by(id: params[:id], template: true)
@service ||= @integration # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/329759
2015-04-26 12:48:37 +05:30
end
2021-06-08 01:23:25 +05:30
alias_method :service, :integration
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2020-07-28 23:09:34 +05:30
2021-04-29 21:17:54 +05:30
def disable_query_limiting
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/220357')
2020-07-28 23:09:34 +05:30
end
2015-04-26 12:48:37 +05:30
end