Commit c936bec2 authored by Leni Kadali Mutungi's avatar Leni Kadali Mutungi Committed by Andy Soiron

Change instance variables to arguments

Changed instance variables to arguments as part of
solving this issue https://gitlab.com/gitlab-org/gitlab/-/issues/289975
parent a70428b3
...@@ -23,7 +23,7 @@ module Integrations::Actions ...@@ -23,7 +23,7 @@ module Integrations::Actions
format.html do format.html do
if saved if saved
PropagateIntegrationWorker.perform_async(integration.id) PropagateIntegrationWorker.perform_async(integration.id)
redirect_to scoped_edit_integration_path(integration), notice: success_message redirect_to scoped_edit_integration_path(integration, project: integration.project, group: integration.group), notice: success_message
else else
render 'shared/integrations/edit' render 'shared/integrations/edit'
end end
......
...@@ -17,31 +17,31 @@ module IntegrationsHelper ...@@ -17,31 +17,31 @@ module IntegrationsHelper
"#{event}_events" "#{event}_events"
end end
def scoped_integrations_path def scoped_integrations_path(project: nil, group: nil)
if @project.present? if project.present?
project_settings_integrations_path(@project) project_settings_integrations_path(project)
elsif @group.present? elsif group.present?
group_settings_integrations_path(@group) group_settings_integrations_path(group)
else else
integrations_admin_application_settings_path integrations_admin_application_settings_path
end end
end end
def scoped_integration_path(integration) def scoped_integration_path(integration, project: nil, group: nil)
if @project.present? if project.present?
project_service_path(@project, integration) project_service_path(project, integration)
elsif @group.present? elsif group.present?
group_settings_integration_path(@group, integration) group_settings_integration_path(group, integration)
else else
admin_application_settings_integration_path(integration) admin_application_settings_integration_path(integration)
end end
end end
def scoped_edit_integration_path(integration) def scoped_edit_integration_path(integration, project: nil, group: nil)
if @project.present? if project.present?
edit_project_service_path(@project, integration) edit_project_service_path(project, integration)
elsif @group.present? elsif group.present?
edit_group_settings_integration_path(@group, integration) edit_group_settings_integration_path(group, integration)
else else
edit_admin_application_settings_integration_path(integration) edit_admin_application_settings_integration_path(integration)
end end
...@@ -51,11 +51,11 @@ module IntegrationsHelper ...@@ -51,11 +51,11 @@ module IntegrationsHelper
overrides_admin_application_settings_integration_path(integration, options) overrides_admin_application_settings_integration_path(integration, options)
end end
def scoped_test_integration_path(integration) def scoped_test_integration_path(integration, project: nil, group: nil)
if @project.present? if project.present?
test_project_service_path(@project, integration) test_project_service_path(project, integration)
elsif @group.present? elsif group.present?
test_group_settings_integration_path(@group, integration) test_group_settings_integration_path(group, integration)
else else
test_admin_application_settings_integration_path(integration) test_admin_application_settings_integration_path(integration)
end end
...@@ -71,7 +71,7 @@ module IntegrationsHelper ...@@ -71,7 +71,7 @@ module IntegrationsHelper
end end
end end
def integration_form_data(integration, group: nil) def integration_form_data(integration, project: nil, group: nil)
form_data = { form_data = {
id: integration.id, id: integration.id,
show_active: integration.show_active_box?.to_s, show_active: integration.show_active_box?.to_s,
...@@ -87,9 +87,9 @@ module IntegrationsHelper ...@@ -87,9 +87,9 @@ module IntegrationsHelper
inherit_from_id: integration.inherit_from_id, inherit_from_id: integration.inherit_from_id,
integration_level: integration_level(integration), integration_level: integration_level(integration),
editable: integration.editable?.to_s, editable: integration.editable?.to_s,
cancel_path: scoped_integrations_path, cancel_path: scoped_integrations_path(project: project, group: group),
can_test: integration.testable?.to_s, can_test: integration.testable?.to_s,
test_path: scoped_test_integration_path(integration), test_path: scoped_test_integration_path(integration, project: project, group: group),
reset_path: scoped_reset_integration_path(integration, group: group) reset_path: scoped_reset_integration_path(integration, group: group)
} }
...@@ -107,9 +107,9 @@ module IntegrationsHelper ...@@ -107,9 +107,9 @@ module IntegrationsHelper
} }
end end
def integration_list_data(integrations) def integration_list_data(integrations, group: nil, project: nil)
{ {
integrations: integrations.map { |i| serialize_integration(i) }.to_json integrations: integrations.map { |i| serialize_integration(i, group: group, project: project) }.to_json
} }
end end
...@@ -215,13 +215,13 @@ module IntegrationsHelper ...@@ -215,13 +215,13 @@ module IntegrationsHelper
end end
end end
def serialize_integration(integration) def serialize_integration(integration, group: nil, project: nil)
{ {
active: integration.operating?, active: integration.operating?,
title: integration.title, title: integration.title,
description: integration.description, description: integration.description,
updated_at: integration.updated_at, updated_at: integration.updated_at,
edit_path: scoped_edit_integration_path(integration), edit_path: scoped_edit_integration_path(integration, group: group, project: project),
name: integration.to_param name: integration.to_param
} }
end end
......
...@@ -16,7 +16,7 @@ module OperationsHelper ...@@ -16,7 +16,7 @@ module OperationsHelper
{ {
'prometheus_activated' => prometheus_integration.manual_configuration?.to_s, 'prometheus_activated' => prometheus_integration.manual_configuration?.to_s,
'prometheus_form_path' => scoped_integration_path(prometheus_integration), 'prometheus_form_path' => scoped_integration_path(prometheus_integration, project: prometheus_integration.project, group: prometheus_integration.group),
'prometheus_reset_key_path' => reset_alerting_token_project_settings_operations_path(@project), 'prometheus_reset_key_path' => reset_alerting_token_project_settings_operations_path(@project),
'prometheus_authorization_key' => @project.alerting_setting&.token, 'prometheus_authorization_key' => @project.alerting_setting&.token,
'prometheus_api_url' => prometheus_integration.api_url, 'prometheus_api_url' => prometheus_integration.api_url,
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
- if integration.operating? - if integration.operating?
= sprite_icon('check', css_class: 'gl-text-green-500') = sprite_icon('check', css_class: 'gl-text-green-500')
= form_for(integration, as: :service, url: scoped_integration_path(integration), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'test-url' => test_project_service_path(@project, integration) } }) do |form| = form_for(integration, as: :service, url: scoped_integration_path(integration, project: @project, group: @group), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'test-url' => test_project_service_path(@project, integration) } }) do |form|
= render 'shared/service_settings', form: form, integration: integration = render 'shared/service_settings', form: form, integration: integration
%input{ id: 'services_redirect_to', type: 'hidden', name: 'redirect_to', value: request.referer } %input{ id: 'services_redirect_to', type: 'hidden', name: 'redirect_to', value: request.referer }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
.service-settings .service-settings
- if @default_integration - if @default_integration
.js-vue-default-integration-settings{ data: integration_form_data(@default_integration, group: @group) } .js-vue-default-integration-settings{ data: integration_form_data(@default_integration, group: @group, project: @project) }
.js-vue-integration-settings{ data: integration_form_data(integration, group: @group) } .js-vue-integration-settings{ data: integration_form_data(integration, group: @group, project: @project) }
.js-integration-help-html.gl-display-none .js-integration-help-html.gl-display-none
-# All content below will be repositioned in Vue -# All content below will be repositioned in Vue
- if lookup_context.template_exists?('help', "projects/services/#{integration.to_param}", true) - if lookup_context.template_exists?('help', "projects/services/#{integration.to_param}", true)
......
- integration = local_assigns.fetch(:integration) - integration = local_assigns.fetch(:integration)
= form_for integration, as: :service, url: scoped_integration_path(integration), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'test-url' => scoped_test_integration_path(integration) } } do |form| = form_for integration, as: :service, url: scoped_integration_path(integration, group: @group), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'test-url' => scoped_test_integration_path(integration, group: @group) } } do |form|
= render 'shared/service_settings', form: form, integration: integration = render 'shared/service_settings', form: form, integration: integration
.js-integrations-list{ data: integration_list_data(integrations) } .js-integrations-list{ data: integration_list_data(integrations, group: @group, project: @project) }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.tabs.gl-tabs .tabs.gl-tabs
%div %div
= gl_tabs_nav({ class: 'gl-mb-5' }) do = gl_tabs_nav({ class: 'gl-mb-5' }) do
= gl_tab_link_to _('Settings'), scoped_edit_integration_path(integration) = gl_tab_link_to _('Settings'), scoped_edit_integration_path(integration, project: @project, group: @group)
= gl_tab_link_to s_('Integrations|Projects using custom settings'), scoped_overrides_integration_path(integration) = gl_tab_link_to s_('Integrations|Projects using custom settings'), scoped_overrides_integration_path(integration)
= yield = yield
......
- add_to_breadcrumbs _('Integrations'), scoped_integrations_path - add_to_breadcrumbs _('Integrations'), scoped_integrations_path(project: @project, group: @group)
- breadcrumb_title @integration.title - breadcrumb_title @integration.title
- page_title @integration.title, _('Integrations') - page_title @integration.title, _('Integrations')
- @content_class = 'limit-container-width' unless fluid_layout - @content_class = 'limit-container-width' unless fluid_layout
......
- add_to_breadcrumbs _('Integrations'), scoped_integrations_path - add_to_breadcrumbs _('Integrations'), scoped_integrations_path(project: project, group: group)
- breadcrumb_title @integration.title - breadcrumb_title @integration.title
- page_title @integration.title, _('Integrations') - page_title @integration.title, _('Integrations')
- @content_class = 'limit-container-width' unless fluid_layout - @content_class = 'limit-container-width' unless fluid_layout
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
= page_title = page_title
- if @project - if @project
- integrations_link_start = '<a href="%{url}">'.html_safe % { url: scoped_integrations_path } - integrations_link_start = '<a href="%{url}">'.html_safe % { url: scoped_integrations_path(project: @project) }
%p= _("%{webhooks_link_start}%{webhook_type}%{link_end} enable you to send notifications to web applications in response to events in a group or project. We recommend using an %{integrations_link_start}integration%{link_end} in preference to a webhook.").html_safe % { webhooks_link_start: webhooks_link_start, webhook_type: hook.pluralized_name, integrations_link_start: integrations_link_start, link_end: '</a>'.html_safe } %p= _("%{webhooks_link_start}%{webhook_type}%{link_end} enable you to send notifications to web applications in response to events in a group or project. We recommend using an %{integrations_link_start}integration%{link_end} in preference to a webhook.").html_safe % { webhooks_link_start: webhooks_link_start, webhook_type: hook.pluralized_name, integrations_link_start: integrations_link_start, link_end: '</a>'.html_safe }
- else - else
%p= _("%{webhooks_link_start}%{webhook_type}%{link_end} enable you to send notifications to web applications in response to events in a group or project.").html_safe % { webhooks_link_start: webhooks_link_start, webhook_type: hook.pluralized_name, link_end: '</a>'.html_safe } %p= _("%{webhooks_link_start}%{webhook_type}%{link_end} enable you to send notifications to web applications in response to events in a group or project.").html_safe % { webhooks_link_start: webhooks_link_start, webhook_type: hook.pluralized_name, link_end: '</a>'.html_safe }
...@@ -10,7 +10,7 @@ module EE ...@@ -10,7 +10,7 @@ module EE
end end
override :integration_form_data override :integration_form_data
def integration_form_data(integration, group: nil) def integration_form_data(integration, project: nil, group: nil)
form_data = super form_data = super
if integration.is_a?(Integrations::Jira) if integration.is_a?(Integrations::Jira)
......
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