Commit 86c6962a authored by Justin Ho Tuan Duong's avatar Justin Ho Tuan Duong Committed by Luke Duncalfe

Rename service to integration in HAML views

- Prefer passing local variables instead of using instance
variables.
- Rename in all views used by integrations.
parent 965d1f5d
- if lookup_context.template_exists?('top', "projects/services/#{@service.to_param}", true)
= render "projects/services/#{@service.to_param}/top"
- if lookup_context.template_exists?('top', "projects/services/#{integration.to_param}", true)
= render "projects/services/#{integration.to_param}/top", integration: integration
%h3.page-title
= @service.title
- if @service.operating?
= integration.title
- if integration.operating?
= sprite_icon('check', css_class: 'gl-text-green-500')
= form_for(@service, as: :service, url: scoped_integration_path(@service), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'test-url' => test_project_service_path(@project, @service) } }) do |form|
= render 'shared/service_settings', form: form, integration: @service
= 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|
= render 'shared/service_settings', form: form, integration: integration
%input{ id: 'services_redirect_to', type: 'hidden', name: 'redirect_to', value: request.referrer }
- if lookup_context.template_exists?('show', "projects/services/#{@service.to_param}", true)
- if lookup_context.template_exists?('show', "projects/services/#{integration.to_param}", true)
%hr
= render "projects/services/#{@service.to_param}/show"
= render "projects/services/#{integration.to_param}/show", integration: integration
- breadcrumb_title @service.title
- breadcrumb_title @integration.title
- add_to_breadcrumbs _('Integration Settings'), project_settings_integrations_path(@project)
- page_title @service.title, _('Integrations')
- page_title @integration.title, _('Integrations')
- @content_class = 'limit-container-width' unless fluid_layout
= render 'form'
= render 'form', integration: @integration
- if @web_hook_logs
= render partial: 'projects/hook_logs/index', locals: { hook: @service.service_hook, hook_logs: @web_hook_logs, project: @project }
= render partial: 'projects/hook_logs/index', locals: { hook: @integration.service_hook, hook_logs: @web_hook_logs, project: @project }
......@@ -57,7 +57,7 @@
.form-group
= label_tag :request_url, s_('MattermostService|Request URL'), class: 'col-12 col-form-label label-bold'
.col-12.input-group
= text_field_tag :request_url, service_trigger_url(subject), class: 'form-control form-control-sm', readonly: 'readonly'
= text_field_tag :request_url, service_trigger_url(integration), class: 'form-control form-control-sm', readonly: 'readonly'
.input-group-append
= clipboard_button(target: '#request_url', class: 'input-group-text')
......
......@@ -10,8 +10,8 @@
%p.inline
= s_("MattermostService|After you configure the integration, view your new Mattermost commands by entering")
%kbd.inline /<trigger> help
- if !enabled && @service.project_level?
= render 'projects/services/mattermost_slash_commands/detailed_help', subject: @service
- if !enabled && integration.project_level?
= render 'projects/services/mattermost_slash_commands/detailed_help', integration: integration
- if enabled && @service.project_level?
= render 'projects/services/mattermost_slash_commands/installation_info', subject: @service
- if enabled && integration.project_level?
= render 'projects/services/mattermost_slash_commands/installation_info', integration: integration
.services-installation-info
- unless @service.activated?
- unless integration.activated?
.row
.col-sm-9.offset-sm-3
= link_to new_project_mattermost_path(@project), class: 'btn gl-button btn-lg' do
......
%h4
= s_('PrometheusService|Auto configuration')
- if service.manual_configuration?
- if integration.manual_configuration?
.info-well
= s_('PrometheusService|To enable the installation of Prometheus on your clusters, deactivate the manual configuration.')
- else
.container-fluid
.row
- if service.prometheus_available?
- if integration.prometheus_available?
.col-sm-2
.svg-container
= image_tag 'illustrations/monitoring/getting_started.svg'
......
......@@ -6,7 +6,7 @@
= link_to s_('PrometheusService|More information'), help_page_path('operations/metrics/index.md', anchor: 'adding-custom-metrics'), target: '_blank', rel: "noopener noreferrer"
.col-lg-9
.card.custom-monitored-metrics.js-panel-custom-monitored-metrics{ data: { qa_selector: 'custom_metrics_container', active_custom_metrics: project_prometheus_metrics_path(project), environments_data: environments_list_data, service_active: "#{@service.active}" } }
.card.custom-monitored-metrics.js-panel-custom-monitored-metrics{ data: { qa_selector: 'custom_metrics_container', active_custom_metrics: project_prometheus_metrics_path(project), environments_data: environments_list_data, service_active: "#{integration.active}" } }
.card-header
%strong
= s_('PrometheusService|Custom metrics')
......
- return unless can?(current_user, :read_prometheus_alerts, @project)
- return unless @service.manual_configuration?
- return unless integration.manual_configuration?
- notify_url = notify_project_prometheus_alerts_url(@project, format: :json)
- authorization_key = @project.alerting_setting.try(:token)
......
- if @project
= render 'projects/services/prometheus/configuration_banner', project: @project, service: @service
= render 'projects/services/prometheus/configuration_banner', project: @project, integration: integration
%h4.gl-mb-3
= s_('PrometheusService|Manual configuration')
......
- project = local_assigns.fetch(:project)
= render 'projects/services/prometheus/custom_metrics', project: project
= render 'projects/services/prometheus/custom_metrics', project: project, integration: integration
.col-lg-3
%p
......
......@@ -4,6 +4,6 @@
= s_('PrometheusService|Metrics')
.row.gl-mb-3.prometheus-metrics-monitoring.js-prometheus-metrics-monitoring
= render 'projects/services/prometheus/metrics', project: @project
= render 'projects/services/prometheus/metrics', project: @project, integration: integration
= render 'projects/services/prometheus/external_alerts', project: @project
= render 'projects/services/prometheus/external_alerts', project: @project, integration: integration
- return unless @service.manual_configuration?
- return unless integration.manual_configuration?
.row
.col-lg-12
......
......@@ -11,7 +11,7 @@
%p.inline
= s_("SlackService|See list of available commands in Slack after setting up this service, by entering")
%kbd.inline /<command> help
- if @service.project_level?
- if integration.project_level?
%p= _("To set up this service:")
%ul.list-unstyled.indent-list
%li
......@@ -39,7 +39,7 @@
.form-group
= label_tag :url, 'URL', class: 'col-12 col-form-label label-bold'
.col-12.input-group
= text_field_tag :url, service_trigger_url(subject), class: 'form-control form-control-sm', readonly: 'readonly'
= text_field_tag :url, service_trigger_url(integration), class: 'form-control form-control-sm', readonly: 'readonly'
.input-group-append
= clipboard_button(target: '#url', class: 'input-group-text')
......
......@@ -7,7 +7,7 @@
.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)
= render "projects/services/#{integration.to_param}/help", subject: integration
= render "projects/services/#{integration.to_param}/help", integration: integration
- elsif integration.help.present?
.info-well
.well-segment
......
......@@ -6,5 +6,5 @@
%p.inline
= _("See the list of available commands in Slack after setting up this service by entering")
%kbd.inline /gitlab help
- if @service.project_level?
= render "projects/services/#{@service.to_param}/slack_integration_form"
- if integration.project_level?
= render "projects/services/#{integration.to_param}/slack_integration_form", integration: integration
- slack_integration = @service.slack_integration
- slack_integration = integration.slack_integration
- if slack_integration
%table.table
%colgroup
......@@ -22,9 +22,9 @@
ago
%td
.controls
- project = @service.project
- project = integration.project
= link_to 'Edit', edit_project_settings_slack_path(project), class: 'btn gl-button btn-default btn-sm'
= link_to 'Remove', project_settings_slack_path(project), method: :delete, class: 'btn gl-button btn-danger btn-sm', data: { confirm: 'Are you sure?' }
- else
%p To set up this service press "Add to Slack"
= render "projects/services/#{@service.to_param}/slack_button", project: @project
= render "projects/services/#{integration.to_param}/slack_button", project: @project
......@@ -11,17 +11,16 @@ RSpec.describe 'projects/services/_form' do
allow(controller).to receive(:current_user).and_return(user)
allow(view).to receive_messages(current_user: user,
allow(view).to receive_messages(
current_user: user,
can?: true,
current_application_settings: Gitlab::CurrentSettings.current_application_settings,
request: double(referrer: '/services'))
integration: project.redmine_service,
request: double(referrer: '/services')
)
end
context 'commit_events and merge_request_events' do
before do
assign(:service, project.redmine_service)
end
it 'display merge_request_events and commit_events descriptions' do
allow(Integrations::Redmine).to receive(:supported_events).and_return(%w(commit merge_request))
......
......@@ -3,12 +3,12 @@
require 'spec_helper'
RSpec.describe 'projects/services/edit' do
let(:service) { create(:drone_ci_service, project: project) }
let(:integration) { create(:drone_ci_service, project: project) }
let(:project) { create(:project) }
before do
assign :project, project
assign :service, service
assign :integration, integration
end
it do
......@@ -17,7 +17,7 @@ RSpec.describe 'projects/services/edit' do
expect(rendered).not_to have_text('Recent Deliveries')
end
context 'service using WebHooks' do
context 'integration using WebHooks' do
before do
assign(:web_hook_logs, [])
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