Commit 6e386414 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'justin_ho-refine-ui-of-integration-form' into 'master'

Refine UI of integration form

See merge request gitlab-org/gitlab!34707
parents 79eda21d 6c31a649
...@@ -135,8 +135,11 @@ export default { ...@@ -135,8 +135,11 @@ export default {
:label-for="fieldId" :label-for="fieldId"
:invalid-feedback="__('This field is required.')" :invalid-feedback="__('This field is required.')"
:state="valid" :state="valid"
:description="help"
> >
<template #description>
<span v-html="help"></span>
</template>
<template v-if="isCheckbox"> <template v-if="isCheckbox">
<input :name="fieldName" type="hidden" value="false" /> <input :name="fieldName" type="hidden" value="false" />
<gl-form-checkbox v-model="model" v-bind="sharedProps"> <gl-form-checkbox v-model="model" v-bind="sharedProps">
......
...@@ -54,9 +54,8 @@ module IntegrationsActions ...@@ -54,9 +54,8 @@ module IntegrationsActions
end end
def integration 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 ServiceParams.
# and app/views/shared/_service_settings.html.haml. Should be removed once # Should be removed once that is refactored to use `@integration`.
# those 2 are refactored to use `@integration`.
@integration = @service ||= find_or_initialize_integration(params[:id]) # rubocop:disable Gitlab/ModuleWithInstanceVariables @integration = @service ||= find_or_initialize_integration(params[:id]) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
......
...@@ -44,13 +44,6 @@ module ServicesHelper ...@@ -44,13 +44,6 @@ module ServicesHelper
end end
end end
def event_action_description(action)
case action
when "comment"
s_("ProjectService|Comment will be posted on each event")
end
end
def service_save_button def service_save_button
button_tag(class: 'btn btn-success', type: 'submit', data: { qa_selector: 'save_changes_button' }) do button_tag(class: 'btn btn-success', type: 'submit', data: { qa_selector: 'save_changes_button' }) do
icon('spinner spin', class: 'hidden js-btn-spinner') + icon('spinner spin', class: 'hidden js-btn-spinner') +
...@@ -90,7 +83,7 @@ module ServicesHelper ...@@ -90,7 +83,7 @@ module ServicesHelper
def scoped_test_integration_path(integration) def scoped_test_integration_path(integration)
if @project.present? if @project.present?
test_project_settings_integration_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
...@@ -102,22 +95,36 @@ module ServicesHelper ...@@ -102,22 +95,36 @@ module ServicesHelper
Feature.enabled?(:integration_form_refactor, @project) Feature.enabled?(:integration_form_refactor, @project)
end end
def trigger_events_for_service def integration_form_data(integration)
{
show_active: integration.show_active_box?.to_s,
activated: (integration.active || integration.new_record?).to_s,
type: integration.to_param,
merge_request_events: integration.merge_requests_events.to_s,
commit_events: integration.commit_events.to_s,
enable_comments: integration.comment_on_event_enabled.to_s,
comment_detail: integration.comment_detail,
trigger_events: trigger_events_for_service(integration),
fields: fields_for_service(integration)
}
end
def trigger_events_for_service(integration)
return [] unless integration_form_refactor? return [] unless integration_form_refactor?
ServiceEventSerializer.new(service: @service).represent(@service.configurable_events).to_json ServiceEventSerializer.new(service: integration).represent(integration.configurable_events).to_json
end end
def fields_for_service def fields_for_service(integration)
return [] unless integration_form_refactor? return [] unless integration_form_refactor?
ServiceFieldSerializer.new(service: @service).represent(@service.global_fields).to_json ServiceFieldSerializer.new(service: integration).represent(integration.global_fields).to_json
end end
def show_service_trigger_events? def show_service_trigger_events?(integration)
return false if @service.is_a?(JiraService) || integration_form_refactor? return false if integration.is_a?(JiraService) || integration_form_refactor?
@service.configurable_events.present? integration.configurable_events.present?
end end
extend self extend self
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
%p #{@service.description} template. %p #{@service.description} template.
= form_for :service, url: admin_application_settings_service_path, method: :put, html: { class: 'fieldset-form' } do |form| = form_for :service, url: admin_application_settings_service_path, method: :put, html: { class: 'fieldset-form' } do |form|
= render 'shared/service_settings', form: form, service: @service = render 'shared/service_settings', form: form, integration: @service
.footer-block.row-content-block .footer-block.row-content-block
= form.submit 'Save', class: 'btn btn-success' = form.submit 'Save', class: 'btn btn-success'
- add_to_breadcrumbs "Service Templates", admin_application_settings_services_path - add_to_breadcrumbs "Service Templates", admin_application_settings_services_path
- breadcrumb_title @service.title - breadcrumb_title @service.title
- page_title @service.title, "Service Templates" - page_title @service.title, "Service Templates"
- @content_class = 'limit-container-width' unless fluid_layout
= render 'form' = render 'form'
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Appearance') = _('Appearance')
= nav_link(controller: :application_settings) do = nav_link(controller: [:application_settings, :integrations]) do
= link_to general_admin_application_settings_path do = link_to general_admin_application_settings_path do
.nav-icon-container .nav-icon-container
= sprite_icon('settings') = sprite_icon('settings')
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
= _('Settings') = _('Settings')
%ul.sidebar-sub-level-items.qa-admin-sidebar-settings-submenu %ul.sidebar-sub-level-items.qa-admin-sidebar-settings-submenu
= nav_link(controller: :application_settings, html_options: { class: "fly-out-top-item" } ) do = nav_link(controller: [:application_settings, :integrations], html_options: { class: "fly-out-top-item" } ) do
= link_to general_admin_application_settings_path do = link_to general_admin_application_settings_path do
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Settings') = _('Settings')
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
= link_to general_admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do = link_to general_admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do
%span %span
= _('General') = _('General')
= nav_link(path: 'application_settings#integrations') do = nav_link(path: ['application_settings#integrations', 'integrations#edit']) do
= link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do = link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do
%span %span
= _('Integrations') = _('Integrations')
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
%p= @service.detailed_description %p= @service.detailed_description
.col-lg-8 .col-lg-8
= 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: { 'can-test' => @service.can_test?, 'test-url' => test_project_service_path(@project, @service) } }) do |form| = 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: { 'can-test' => @service.can_test?, 'test-url' => test_project_service_path(@project, @service) } }) do |form|
= render 'shared/service_settings', form: form, service: @service = render 'shared/service_settings', form: form, integration: @service
.footer-block.row-content-block .footer-block.row-content-block
%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 }
= service_save_button = service_save_button
......
= form_errors(@service) = form_errors(integration)
- if lookup_context.template_exists?('help', "projects/services/#{@service.to_param}", true) - if lookup_context.template_exists?('help', "projects/services/#{integration.to_param}", true)
= render "projects/services/#{@service.to_param}/help", subject: @service = render "projects/services/#{integration.to_param}/help", subject: integration
- elsif @service.help.present? - elsif integration.help.present?
.info-well .info-well
.well-segment .well-segment
= markdown @service.help = markdown integration.help
.service-settings .service-settings
.js-vue-integration-settings{ data: { show_active: @service.show_active_box?.to_s, activated: (@service.active || @service.new_record?).to_s, type: @service.to_param, merge_request_events: @service.merge_requests_events.to_s, .js-vue-integration-settings{ data: integration_form_data(integration) }
commit_events: @service.commit_events.to_s, enable_comments: @service.comment_on_event_enabled.to_s, comment_detail: @service.comment_detail, trigger_events: trigger_events_for_service, fields: fields_for_service } }
- if show_service_trigger_events? - if show_service_trigger_events?(integration)
.form-group.row .form-group.row
%label.col-form-label.col-sm-2= _('Trigger') %label.col-form-label.col-sm-2= _('Trigger')
.col-sm-10 .col-sm-10
- @service.configurable_events.each do |event| - integration.configurable_events.each do |event|
.form-group .form-group
.form-check .form-check
= form.check_box service_event_field_name(event), class: 'form-check-input' = form.check_box service_event_field_name(event), class: 'form-check-input'
...@@ -24,14 +23,14 @@ commit_events: @service.commit_events.to_s, enable_comments: @service.comment_on ...@@ -24,14 +23,14 @@ commit_events: @service.commit_events.to_s, enable_comments: @service.comment_on
%strong %strong
= event.humanize = event.humanize
- field = @service.event_field(event) - field = integration.event_field(event)
- if field - if field
= form.text_field field[:name], class: "form-control", placeholder: field[:placeholder] = form.text_field field[:name], class: "form-control", placeholder: field[:placeholder]
%p.text-muted %p.text-muted
= @service.class.event_description(event) = integration.class.event_description(event)
- unless integration_form_refactor? - unless integration_form_refactor?
- @service.global_fields.each do |field| - integration.global_fields.each do |field|
= render 'shared/field', form: form, field: field = render 'shared/field', form: form, field: field
- add_to_breadcrumbs _('Integrations'), scoped_integrations_path - add_to_breadcrumbs _('Integrations'), scoped_integrations_path
- 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
= render 'shared/integrations/form', integration: @integration = render 'shared/integrations/form', integration: @integration
---
title: Refine UI of integration form
merge_request: 34707
author:
type: changed
...@@ -17449,9 +17449,6 @@ msgstr "" ...@@ -17449,9 +17449,6 @@ msgstr ""
msgid "ProjectService|Comment" msgid "ProjectService|Comment"
msgstr "" msgstr ""
msgid "ProjectService|Comment will be posted on each event"
msgstr ""
msgid "ProjectService|Perform common operations on GitLab project: %{project_name}" msgid "ProjectService|Perform common operations on GitLab project: %{project_name}"
msgstr "" msgstr ""
......
...@@ -147,6 +147,20 @@ describe('DynamicField', () => { ...@@ -147,6 +147,20 @@ describe('DynamicField', () => {
.text(), .text(),
).toBe(defaultProps.help); ).toBe(defaultProps.help);
}); });
it('renders description with help text as HTML', () => {
const helpHTML = 'The <strong>URL</strong> of the project';
createComponent({
help: helpHTML,
});
expect(
findGlFormGroup()
.find('small')
.html(),
).toContain(helpHTML);
});
}); });
describe('label text', () => { describe('label text', () => {
......
...@@ -7,9 +7,4 @@ describe ServicesHelper do ...@@ -7,9 +7,4 @@ describe ServicesHelper do
it { expect(event_action_title('comment')).to eq 'Comment' } it { expect(event_action_title('comment')).to eq 'Comment' }
it { expect(event_action_title('something')).to eq 'Something' } it { expect(event_action_title('something')).to eq 'Something' }
end end
describe 'event_action_description' do
it { expect(event_action_description('comment')).to eq 'Comment will be posted on each event' }
it { expect(event_action_description('something')).to eq nil }
end
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