Commit b5523076 authored by Markus Koller's avatar Markus Koller

Merge branch '332280-integration-settings-template-jira-backend' into 'master'

Add sections definition to integration fields

See merge request gitlab-org/gitlab!80712
parents 98b7340c d75f91a4
...@@ -22,6 +22,7 @@ function parseDatasetToProps(data) { ...@@ -22,6 +22,7 @@ function parseDatasetToProps(data) {
editProjectPath, editProjectPath,
learnMorePath, learnMorePath,
triggerEvents, triggerEvents,
sections,
fields, fields,
inheritFromId, inheritFromId,
integrationLevel, integrationLevel,
...@@ -81,6 +82,7 @@ function parseDatasetToProps(data) { ...@@ -81,6 +82,7 @@ function parseDatasetToProps(data) {
}, },
learnMorePath, learnMorePath,
triggerEvents: JSON.parse(triggerEvents), triggerEvents: JSON.parse(triggerEvents),
sections: JSON.parse(sections, { deep: true }),
fields: convertObjectPropsToCamelCase(JSON.parse(fields), { deep: true }), fields: convertObjectPropsToCamelCase(JSON.parse(fields), { deep: true }),
inheritFromId: parseInt(inheritFromId, 10), inheritFromId: parseInt(inheritFromId, 10),
integrationLevel, integrationLevel,
......
...@@ -5,6 +5,10 @@ class Admin::IntegrationsController < Admin::ApplicationController ...@@ -5,6 +5,10 @@ class Admin::IntegrationsController < Admin::ApplicationController
before_action :not_found, unless: -> { instance_level_integrations? } before_action :not_found, unless: -> { instance_level_integrations? }
before_action do
push_frontend_feature_flag(:integration_form_sections, default_enabled: :yaml)
end
feature_category :integrations feature_category :integrations
def overrides def overrides
......
...@@ -7,6 +7,10 @@ module Groups ...@@ -7,6 +7,10 @@ module Groups
before_action :authorize_admin_group! before_action :authorize_admin_group!
before_action do
push_frontend_feature_flag(:integration_form_sections, group, default_enabled: :yaml)
end
feature_category :integrations feature_category :integrations
layout 'group_settings' layout 'group_settings'
......
...@@ -13,6 +13,10 @@ class Projects::ServicesController < Projects::ApplicationController ...@@ -13,6 +13,10 @@ class Projects::ServicesController < Projects::ApplicationController
before_action :set_deprecation_notice_for_prometheus_integration, only: [:edit, :update] before_action :set_deprecation_notice_for_prometheus_integration, only: [:edit, :update]
before_action :redirect_deprecated_prometheus_integration, only: [:update] before_action :redirect_deprecated_prometheus_integration, only: [:update]
before_action do
push_frontend_feature_flag(:integration_form_sections, project, default_enabled: :yaml)
end
respond_to :html respond_to :html
layout "project_settings" layout "project_settings"
......
...@@ -83,6 +83,7 @@ module IntegrationsHelper ...@@ -83,6 +83,7 @@ module IntegrationsHelper
comment_detail: integration.comment_detail, comment_detail: integration.comment_detail,
learn_more_path: integrations_help_page_path, learn_more_path: integrations_help_page_path,
trigger_events: trigger_events_for_integration(integration), trigger_events: trigger_events_for_integration(integration),
sections: integration.sections.to_json,
fields: fields_for_integration(integration), fields: fields_for_integration(integration),
inherit_from_id: integration.inherit_from_id, inherit_from_id: integration.inherit_from_id,
integration_level: integration_level(integration), integration_level: integration_level(integration),
......
...@@ -40,6 +40,8 @@ class Integration < ApplicationRecord ...@@ -40,6 +40,8 @@ class Integration < ApplicationRecord
Integrations::BaseSlashCommands Integrations::BaseSlashCommands
].freeze ].freeze
SECTION_TYPE_CONNECTION = 'connection'
serialize :properties, JSON # rubocop:disable Cop/ActiveRecordSerialize serialize :properties, JSON # rubocop:disable Cop/ActiveRecordSerialize
attribute :type, Gitlab::Integrations::StiType.new attribute :type, Gitlab::Integrations::StiType.new
...@@ -363,6 +365,10 @@ class Integration < ApplicationRecord ...@@ -363,6 +365,10 @@ class Integration < ApplicationRecord
[] []
end end
def sections
[]
end
def password_fields def password_fields
fields.select { |f| f[:type] == 'password' }.pluck(:name) fields.select { |f| f[:type] == 'password' }.pluck(:name)
end end
......
...@@ -112,7 +112,7 @@ module Integrations ...@@ -112,7 +112,7 @@ module Integrations
def help def help
jira_doc_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: help_page_url('integration/jira/index.html') } jira_doc_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: help_page_url('integration/jira/index.html') }
s_("JiraService|You need to configure Jira before enabling this integration. For more details, read the %{jira_doc_link_start}Jira integration documentation%{link_end}.") % { jira_doc_link_start: jira_doc_link_start, link_end: '</a>'.html_safe } s_("JiraService|You must configure Jira before enabling this integration. For more details, read the %{jira_doc_link_start}Jira integration documentation%{link_end}.") % { jira_doc_link_start: jira_doc_link_start, link_end: '</a>'.html_safe }
end end
def title def title
...@@ -130,6 +130,7 @@ module Integrations ...@@ -130,6 +130,7 @@ module Integrations
def fields def fields
[ [
{ {
section: SECTION_TYPE_CONNECTION,
type: 'text', type: 'text',
name: 'url', name: 'url',
title: s_('JiraService|Web URL'), title: s_('JiraService|Web URL'),
...@@ -138,12 +139,14 @@ module Integrations ...@@ -138,12 +139,14 @@ module Integrations
required: true required: true
}, },
{ {
section: SECTION_TYPE_CONNECTION,
type: 'text', type: 'text',
name: 'api_url', name: 'api_url',
title: s_('JiraService|Jira API URL'), title: s_('JiraService|Jira API URL'),
help: s_('JiraService|If different from Web URL.') help: s_('JiraService|If different from Web URL.')
}, },
{ {
section: SECTION_TYPE_CONNECTION,
type: 'text', type: 'text',
name: 'username', name: 'username',
title: s_('JiraService|Username or Email'), title: s_('JiraService|Username or Email'),
...@@ -151,6 +154,7 @@ module Integrations ...@@ -151,6 +154,7 @@ module Integrations
required: true required: true
}, },
{ {
section: SECTION_TYPE_CONNECTION,
type: 'password', type: 'password',
name: 'password', name: 'password',
title: s_('JiraService|Password or API token'), title: s_('JiraService|Password or API token'),
...@@ -162,6 +166,16 @@ module Integrations ...@@ -162,6 +166,16 @@ module Integrations
] ]
end end
def sections
[
{
type: SECTION_TYPE_CONNECTION,
title: s_('Integrations|Connection details'),
description: help
}
].freeze
end
def web_url(path = nil, **params) def web_url(path = nil, **params)
return '' unless url.present? return '' unless url.present?
......
...@@ -4,7 +4,7 @@ class ServiceFieldEntity < Grape::Entity ...@@ -4,7 +4,7 @@ class ServiceFieldEntity < Grape::Entity
include RequestAwareEntity include RequestAwareEntity
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
expose :type, :name, :placeholder, :required, :choices, :checkbox_label expose :section, :type, :name, :placeholder, :required, :choices, :checkbox_label
expose :title do |field| expose :title do |field|
non_empty_password?(field) ? field[:non_empty_password_title] : field[:title] non_empty_password?(field) ? field[:non_empty_password_title] : field[:title]
......
---
name: integration_form_sections
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/80712
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/352827
milestone: '14.9'
type: development
group: group::integrations
default_enabled: false
...@@ -19681,6 +19681,9 @@ msgstr "" ...@@ -19681,6 +19681,9 @@ msgstr ""
msgid "Integrations|Comment settings:" msgid "Integrations|Comment settings:"
msgstr "" msgstr ""
msgid "Integrations|Connection details"
msgstr ""
msgid "Integrations|Connection failed. Please check your settings." msgid "Integrations|Connection failed. Please check your settings."
msgstr "" msgstr ""
...@@ -20932,7 +20935,7 @@ msgstr "" ...@@ -20932,7 +20935,7 @@ msgstr ""
msgid "JiraService|Work on Jira issues without leaving GitLab. Adds a Jira menu to access your list of Jira issues and view any issue as read-only." msgid "JiraService|Work on Jira issues without leaving GitLab. Adds a Jira menu to access your list of Jira issues and view any issue as read-only."
msgstr "" msgstr ""
msgid "JiraService|You need to configure Jira before enabling this integration. For more details, read the %{jira_doc_link_start}Jira integration documentation%{link_end}." msgid "JiraService|You must configure Jira before enabling this integration. For more details, read the %{jira_doc_link_start}Jira integration documentation%{link_end}."
msgstr "" msgstr ""
msgid "Job" msgid "Job"
......
...@@ -20,6 +20,7 @@ RSpec.describe ServiceFieldEntity do ...@@ -20,6 +20,7 @@ RSpec.describe ServiceFieldEntity do
it 'exposes correct attributes' do it 'exposes correct attributes' do
expected_hash = { expected_hash = {
section: 'connection',
type: 'text', type: 'text',
name: 'username', name: 'username',
title: 'Username or Email', title: 'Username or Email',
...@@ -40,6 +41,7 @@ RSpec.describe ServiceFieldEntity do ...@@ -40,6 +41,7 @@ RSpec.describe ServiceFieldEntity do
it 'exposes correct attributes but hides password' do it 'exposes correct attributes but hides password' do
expected_hash = { expected_hash = {
section: 'connection',
type: 'password', type: 'password',
name: 'password', name: 'password',
title: 'Enter new password or API token', title: 'Enter new password or API token',
...@@ -64,6 +66,7 @@ RSpec.describe ServiceFieldEntity do ...@@ -64,6 +66,7 @@ RSpec.describe ServiceFieldEntity do
it 'exposes correct attributes and casts value to Boolean' do it 'exposes correct attributes and casts value to Boolean' do
expected_hash = { expected_hash = {
section: nil,
type: 'checkbox', type: 'checkbox',
name: 'send_from_committer_email', name: 'send_from_committer_email',
title: 'Send from committer', title: 'Send from committer',
...@@ -84,6 +87,7 @@ RSpec.describe ServiceFieldEntity do ...@@ -84,6 +87,7 @@ RSpec.describe ServiceFieldEntity do
it 'exposes correct attributes' do it 'exposes correct attributes' do
expected_hash = { expected_hash = {
section: nil,
type: 'select', type: 'select',
name: 'branches_to_be_notified', name: 'branches_to_be_notified',
title: 'Branches for which notifications are to be sent', title: 'Branches for which notifications are to be sent',
......
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