gitlab-org--gitlab-foss/app/controllers/admin/services_controller.rb

41 lines
1.0 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2015-02-12 01:34:41 +00:00
class Admin::ServicesController < Admin::ApplicationController
include ServiceParams
before_action :service, only: [:edit, :update]
before_action only: :edit do
push_frontend_feature_flag(:integration_form_refactor)
end
2015-02-12 01:34:41 +00:00
def index
@services = Service.find_or_create_templates.sort_by(&:title)
2015-02-12 01:34:41 +00:00
end
def edit
unless service.present?
redirect_to admin_application_settings_services_path,
alert: "Service is unknown or it doesn't exist"
end
end
def update
2018-07-02 10:43:06 +00:00
if service.update(service_params[:service])
PropagateServiceTemplateWorker.perform_async(service.id) if service.active? # rubocop:disable CodeReuse/Worker
2015-02-12 01:34:41 +00:00
redirect_to admin_application_settings_services_path,
notice: 'Application settings saved successfully'
else
render :edit
end
end
private
# rubocop: disable CodeReuse/ActiveRecord
2015-02-12 01:34:41 +00:00
def service
@service ||= Service.find_by(id: params[:id], template: true)
2015-02-12 01:34:41 +00:00
end
# rubocop: enable CodeReuse/ActiveRecord
2015-02-12 01:34:41 +00:00
end