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) - if lookup_context.template_exists?('top', "projects/services/#{integration.to_param}", true)
= render "projects/services/#{@service.to_param}/top" = render "projects/services/#{integration.to_param}/top", integration: integration
%h3.page-title %h3.page-title
= @service.title = integration.title
- if @service.operating? - if integration.operating?
= sprite_icon('check', css_class: 'gl-text-green-500') = 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| = 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: @service = render 'shared/service_settings', form: form, integration: integration
%input{ id: 'services_redirect_to', type: 'hidden', name: 'redirect_to', value: request.referrer } %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 %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) - 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 - @content_class = 'limit-container-width' unless fluid_layout
= render 'form' = render 'form', integration: @integration
- if @web_hook_logs - 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 @@ ...@@ -57,7 +57,7 @@
.form-group .form-group
= label_tag :request_url, s_('MattermostService|Request URL'), class: 'col-12 col-form-label label-bold' = label_tag :request_url, s_('MattermostService|Request URL'), class: 'col-12 col-form-label label-bold'
.col-12.input-group .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 .input-group-append
= clipboard_button(target: '#request_url', class: 'input-group-text') = clipboard_button(target: '#request_url', class: 'input-group-text')
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
%p.inline %p.inline
= s_("MattermostService|After you configure the integration, view your new Mattermost commands by entering") = s_("MattermostService|After you configure the integration, view your new Mattermost commands by entering")
%kbd.inline /<trigger> help %kbd.inline /<trigger> help
- if !enabled && @service.project_level? - if !enabled && integration.project_level?
= render 'projects/services/mattermost_slash_commands/detailed_help', subject: @service = render 'projects/services/mattermost_slash_commands/detailed_help', integration: integration
- if enabled && @service.project_level? - if enabled && integration.project_level?
= render 'projects/services/mattermost_slash_commands/installation_info', subject: @service = render 'projects/services/mattermost_slash_commands/installation_info', integration: integration
.services-installation-info .services-installation-info
- unless @service.activated? - unless integration.activated?
.row .row
.col-sm-9.offset-sm-3 .col-sm-9.offset-sm-3
= link_to new_project_mattermost_path(@project), class: 'btn gl-button btn-lg' do = link_to new_project_mattermost_path(@project), class: 'btn gl-button btn-lg' do
......
%h4 %h4
= s_('PrometheusService|Auto configuration') = s_('PrometheusService|Auto configuration')
- if service.manual_configuration? - if integration.manual_configuration?
.info-well .info-well
= s_('PrometheusService|To enable the installation of Prometheus on your clusters, deactivate the manual configuration.') = s_('PrometheusService|To enable the installation of Prometheus on your clusters, deactivate the manual configuration.')
- else - else
.container-fluid .container-fluid
.row .row
- if service.prometheus_available? - if integration.prometheus_available?
.col-sm-2 .col-sm-2
.svg-container .svg-container
= image_tag 'illustrations/monitoring/getting_started.svg' = image_tag 'illustrations/monitoring/getting_started.svg'
......
...@@ -6,7 +6,7 @@ ...@@ -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" = 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 .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 .card-header
%strong %strong
= s_('PrometheusService|Custom metrics') = s_('PrometheusService|Custom metrics')
......
- return unless can?(current_user, :read_prometheus_alerts, @project) - 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) - notify_url = notify_project_prometheus_alerts_url(@project, format: :json)
- authorization_key = @project.alerting_setting.try(:token) - authorization_key = @project.alerting_setting.try(:token)
......
- if @project - 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 %h4.gl-mb-3
= s_('PrometheusService|Manual configuration') = s_('PrometheusService|Manual configuration')
......
- project = local_assigns.fetch(:project) - 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 .col-lg-3
%p %p
......
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
= s_('PrometheusService|Metrics') = s_('PrometheusService|Metrics')
.row.gl-mb-3.prometheus-metrics-monitoring.js-prometheus-metrics-monitoring .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 .row
.col-lg-12 .col-lg-12
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
%p.inline %p.inline
= s_("SlackService|See list of available commands in Slack after setting up this service, by entering") = s_("SlackService|See list of available commands in Slack after setting up this service, by entering")
%kbd.inline /<command> help %kbd.inline /<command> help
- if @service.project_level? - if integration.project_level?
%p= _("To set up this service:") %p= _("To set up this service:")
%ul.list-unstyled.indent-list %ul.list-unstyled.indent-list
%li %li
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
.form-group .form-group
= label_tag :url, 'URL', class: 'col-12 col-form-label label-bold' = label_tag :url, 'URL', class: 'col-12 col-form-label label-bold'
.col-12.input-group .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 .input-group-append
= clipboard_button(target: '#url', class: 'input-group-text') = clipboard_button(target: '#url', class: 'input-group-text')
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
.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)
= render "projects/services/#{integration.to_param}/help", subject: integration = render "projects/services/#{integration.to_param}/help", integration: integration
- elsif integration.help.present? - elsif integration.help.present?
.info-well .info-well
.well-segment .well-segment
......
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
%p.inline %p.inline
= _("See the list of available commands in Slack after setting up this service by entering") = _("See the list of available commands in Slack after setting up this service by entering")
%kbd.inline /gitlab help %kbd.inline /gitlab help
- if @service.project_level? - if integration.project_level?
= render "projects/services/#{@service.to_param}/slack_integration_form" = render "projects/services/#{integration.to_param}/slack_integration_form", integration: integration
- slack_integration = @service.slack_integration - slack_integration = integration.slack_integration
- if slack_integration - if slack_integration
%table.table %table.table
%colgroup %colgroup
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
ago ago
%td %td
.controls .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 '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?' } = link_to 'Remove', project_settings_slack_path(project), method: :delete, class: 'btn gl-button btn-danger btn-sm', data: { confirm: 'Are you sure?' }
- else - else
%p To set up this service press "Add to Slack" %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 ...@@ -11,17 +11,16 @@ RSpec.describe 'projects/services/_form' do
allow(controller).to receive(:current_user).and_return(user) 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, can?: true,
current_application_settings: Gitlab::CurrentSettings.current_application_settings, current_application_settings: Gitlab::CurrentSettings.current_application_settings,
request: double(referrer: '/services')) integration: project.redmine_service,
request: double(referrer: '/services')
)
end end
context 'commit_events and merge_request_events' do 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 it 'display merge_request_events and commit_events descriptions' do
allow(Integrations::Redmine).to receive(:supported_events).and_return(%w(commit merge_request)) allow(Integrations::Redmine).to receive(:supported_events).and_return(%w(commit merge_request))
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'projects/services/edit' do 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) } let(:project) { create(:project) }
before do before do
assign :project, project assign :project, project
assign :service, service assign :integration, integration
end end
it do it do
...@@ -17,7 +17,7 @@ RSpec.describe 'projects/services/edit' do ...@@ -17,7 +17,7 @@ RSpec.describe 'projects/services/edit' do
expect(rendered).not_to have_text('Recent Deliveries') expect(rendered).not_to have_text('Recent Deliveries')
end end
context 'service using WebHooks' do context 'integration using WebHooks' do
before do before do
assign(:web_hook_logs, []) assign(:web_hook_logs, [])
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