Commit c77047b8 authored by Alex Kalderimis's avatar Alex Kalderimis

Rename ServiceParams to IntegrationParams

parent af91d563
# frozen_string_literal: true
class Admin::ServicesController < Admin::ApplicationController
include ServiceParams
include IntegrationParams
before_action :service, only: [:edit, :update]
before_action :disable_query_limiting, only: [:index]
......@@ -21,7 +21,7 @@ class Admin::ServicesController < Admin::ApplicationController
end
def update
if service.update(service_params[:service])
if service.update(integration_params[:integration])
PropagateServiceTemplateWorker.perform_async(service.id) if service.active? # rubocop:disable CodeReuse/Worker
redirect_to admin_application_settings_services_path,
......
# frozen_string_literal: true
module ServiceParams
module IntegrationParams
extend ActiveSupport::Concern
ALLOWED_PARAMS_CE = [
......@@ -79,22 +79,23 @@ module ServiceParams
# Parameters to ignore if no value is specified
FILTER_BLANK_PARAMS = [:password].freeze
def service_params
def integration_params
dynamic_params = @service.event_channel_names + @service.event_names # rubocop:disable Gitlab/ModuleWithInstanceVariables
service_params = params.permit(:id, service: allowed_service_params + dynamic_params)
return_value = params.permit(:id, integration: allowed_integration_params + dynamic_params)
param_values = return_value[:integration]
if service_params[:service].is_a?(ActionController::Parameters)
if param_values.is_a?(ActionController::Parameters)
FILTER_BLANK_PARAMS.each do |param|
service_params[:service].delete(param) if service_params[:service][param].blank?
param_values.delete(param) if param_values[param].blank?
end
end
service_params
return_value
end
def allowed_service_params
def allowed_integration_params
ALLOWED_PARAMS_CE
end
end
ServiceParams.prepend_if_ee('EE::ServiceParams')
IntegrationParams.prepend_if_ee('EE::IntegrationParams')
......@@ -4,7 +4,7 @@ module IntegrationsActions
extend ActiveSupport::Concern
included do
include ServiceParams
include IntegrationParams
before_action :integration, only: [:edit, :update, :test]
end
......@@ -14,7 +14,7 @@ module IntegrationsActions
end
def update
saved = integration.update(service_params[:service])
saved = integration.update(integration_params[:integration])
respond_to do |format|
format.html do
......@@ -49,7 +49,8 @@ module IntegrationsActions
private
def integration
# Using instance variable `@service` still required as it's used in ServiceParams.
# Using instance variable `@service` still required as it's used in
# IntegrationParams.
# Should be removed once that is refactored to use `@integration`.
@integration = @service ||= find_or_initialize_non_project_specific_integration(params[:id]) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
......
# frozen_string_literal: true
class Projects::ServicesController < Projects::ApplicationController
include ServiceParams
include IntegrationParams
include InternalRedirect
# Authorize
......@@ -26,8 +26,8 @@ class Projects::ServicesController < Projects::ApplicationController
end
def update
@service.attributes = service_params[:service]
@service.inherit_from_id = nil if service_params[:service][:inherit_from_id].blank?
@service.attributes = integration_params[:integration]
@service.inherit_from_id = nil if integration_params[:integration][:inherit_from_id].blank?
saved = @service.save(context: :manual_change)
......@@ -60,7 +60,7 @@ class Projects::ServicesController < Projects::ApplicationController
private
def service_test_response
unless @service.update(service_params[:service])
unless @service.update(integration_params[:integration])
return { error: true, message: _('Validations failed.'), service_response: @service.errors.full_messages.join(','), test_failed: false }
end
......
# frozen_string_literal: true
module EE
module ServiceParams
module IntegrationParams
extend ::Gitlab::Utils::Override
ALLOWED_PARAMS_EE = [
......@@ -14,8 +14,8 @@ module EE
:vulnerabilities_issuetype
].freeze
override :allowed_service_params
def allowed_service_params
override :allowed_integration_params
def allowed_integration_params
super + ALLOWED_PARAMS_EE
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment