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
format.html do
if saved
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
render 'shared/integrations/edit'
end
......
......@@ -17,31 +17,31 @@ module IntegrationsHelper
"#{event}_events"
end
def scoped_integrations_path
if @project.present?
project_settings_integrations_path(@project)
elsif @group.present?
group_settings_integrations_path(@group)
def scoped_integrations_path(project: nil, group: nil)
if project.present?
project_settings_integrations_path(project)
elsif group.present?
group_settings_integrations_path(group)
else
integrations_admin_application_settings_path
end
end
def scoped_integration_path(integration)
if @project.present?
project_service_path(@project, integration)
elsif @group.present?
group_settings_integration_path(@group, integration)
def scoped_integration_path(integration, project: nil, group: nil)
if project.present?
project_service_path(project, integration)
elsif group.present?
group_settings_integration_path(group, integration)
else
admin_application_settings_integration_path(integration)
end
end
def scoped_edit_integration_path(integration)
if @project.present?
edit_project_service_path(@project, integration)
elsif @group.present?
edit_group_settings_integration_path(@group, integration)
def scoped_edit_integration_path(integration, project: nil, group: nil)
if project.present?
edit_project_service_path(project, integration)
elsif group.present?
edit_group_settings_integration_path(group, integration)
else
edit_admin_application_settings_integration_path(integration)
end
......@@ -51,11 +51,11 @@ module IntegrationsHelper
overrides_admin_application_settings_integration_path(integration, options)
end
def scoped_test_integration_path(integration)
if @project.present?
test_project_service_path(@project, integration)
elsif @group.present?
test_group_settings_integration_path(@group, integration)
def scoped_test_integration_path(integration, project: nil, group: nil)
if project.present?
test_project_service_path(project, integration)
elsif group.present?
test_group_settings_integration_path(group, integration)
else
test_admin_application_settings_integration_path(integration)
end
......@@ -71,7 +71,7 @@ module IntegrationsHelper
end
end
def integration_form_data(integration, group: nil)
def integration_form_data(integration, project: nil, group: nil)
form_data = {
id: integration.id,
show_active: integration.show_active_box?.to_s,
......@@ -87,9 +87,9 @@ module IntegrationsHelper
inherit_from_id: integration.inherit_from_id,
integration_level: integration_level(integration),
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,
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)
}
......@@ -107,9 +107,9 @@ module IntegrationsHelper
}
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
......@@ -215,13 +215,13 @@ module IntegrationsHelper
end
end
def serialize_integration(integration)
def serialize_integration(integration, group: nil, project: nil)
{
active: integration.operating?,
title: integration.title,
description: integration.description,
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
}
end
......
......@@ -16,7 +16,7 @@ module OperationsHelper
{
'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_authorization_key' => @project.alerting_setting&.token,
'prometheus_api_url' => prometheus_integration.api_url,
......
......@@ -6,7 +6,7 @@
- if integration.operating?
= 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
%input{ id: 'services_redirect_to', type: 'hidden', name: 'redirect_to', value: request.referer }
......
......@@ -2,8 +2,8 @@
.service-settings
- if @default_integration
.js-vue-default-integration-settings{ data: integration_form_data(@default_integration, group: @group) }
.js-vue-integration-settings{ data: integration_form_data(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, project: @project) }
.js-integration-help-html.gl-display-none
-# All content below will be repositioned in Vue
- if lookup_context.template_exists?('help', "projects/services/#{integration.to_param}", true)
......
- 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
.js-integrations-list{ data: integration_list_data(integrations) }
.js-integrations-list{ data: integration_list_data(integrations, group: @group, project: @project) }
......@@ -2,7 +2,7 @@
.tabs.gl-tabs
%div
= 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)
= yield
......
- add_to_breadcrumbs _('Integrations'), scoped_integrations_path
- add_to_breadcrumbs _('Integrations'), scoped_integrations_path(project: @project, group: @group)
- breadcrumb_title @integration.title
- page_title @integration.title, _('Integrations')
- @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
- page_title @integration.title, _('Integrations')
- @content_class = 'limit-container-width' unless fluid_layout
......
......@@ -4,7 +4,7 @@
= page_title
- 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 }
- 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 }
......@@ -10,7 +10,7 @@ module EE
end
override :integration_form_data
def integration_form_data(integration, group: nil)
def integration_form_data(integration, project: nil, group: nil)
form_data = super
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