Moved the upgrade alert out of the `hasSections` condition
What does this MR do and why?
The MR introduces a minor refactoring for the "GitLab for Slack app" alert, introduced in !102661 (merged).
Previously, the alert has been placed within the hasSections
condition. However, it might happen that the integration doesn't have sections even thought the fields are passed down the component.
This MR fixes this scenario by moving the markup outside of hasSections
condition to show it even if there are only fields without a section.
Screenshots or screen recordings
Before | After | |
---|---|---|
With sections | ||
Without sections |
How to set up and validate locally
- Enable the feature flag in the rails console (
rails c
):Feature.enable(:integration_slack_app_notifications)
- The simplest to get sections and fields without the sections is to apply one of the patches below:
Patch for fields only
diff --git a/ee/app/models/integrations/gitlab_slack_application.rb b/ee/app/models/integrations/gitlab_slack_application.rb
index 80b83db36cdb..ad7cf2497ca8 100644
--- a/ee/app/models/integrations/gitlab_slack_application.rb
+++ b/ee/app/models/integrations/gitlab_slack_application.rb
@@ -41,7 +41,38 @@ def editable?
override :fields
def fields
- return [] unless editable?
+ # return [] unless editable?
+ [
+ {
+ type: 'checkbox',
+ name: 'notify_only_broken_pipelines',
+ section: SECTION_TYPE_CONNECTION,
+ help: 'Do not send notifications for successful pipelines.'
+ }.freeze,
+ {
+ type: 'select',
+ name: 'branches_to_be_notified',
+ section: SECTION_TYPE_CONNECTION,
+ title: s_('Integrations|Branches for which notifications are to be sent'),
+ choices: Integrations::Slack.branch_choices
+ }.freeze,
+ {
+ type: 'text',
+ name: 'labels_to_be_notified',
+ section: SECTION_TYPE_CONNECTION,
+ placeholder: '~backend,~frontend',
+ help: 'Send notifications for issue, merge request, and comment events with the listed labels only. Leave blank to receive notifications for all events.'
+ }.freeze,
+ {
+ type: 'select',
+ section: SECTION_TYPE_CONNECTION,
+ name: 'labels_to_be_notified_behavior',
+ choices: [
+ ['Match any of the labels', MATCH_ANY_LABEL],
+ ['Match all of the labels', MATCH_ALL_LABELS]
+ ]
+ }.freeze
+ ].freeze
super
end
Patch for fields with sections
diff --git a/ee/app/models/integrations/gitlab_slack_application.rb b/ee/app/models/integrations/gitlab_slack_application.rb
index 80b83db36cdb..21eaccdf7b0a 100644
--- a/ee/app/models/integrations/gitlab_slack_application.rb
+++ b/ee/app/models/integrations/gitlab_slack_application.rb
@@ -41,11 +41,53 @@ def editable?
override :fields
def fields
- return [] unless editable?
+ # return [] unless editable?
+ [
+ {
+ type: 'checkbox',
+ name: 'notify_only_broken_pipelines',
+ section: SECTION_TYPE_CONNECTION,
+ help: 'Do not send notifications for successful pipelines.'
+ }.freeze,
+ {
+ type: 'select',
+ name: 'branches_to_be_notified',
+ section: SECTION_TYPE_CONNECTION,
+ title: s_('Integrations|Branches for which notifications are to be sent'),
+ choices: Integrations::Slack.branch_choices
+ }.freeze,
+ {
+ type: 'text',
+ name: 'labels_to_be_notified',
+ section: SECTION_TYPE_CONNECTION,
+ placeholder: '~backend,~frontend',
+ help: 'Send notifications for issue, merge request, and comment events with the listed labels only. Leave blank to receive notifications for all events.'
+ }.freeze,
+ {
+ type: 'select',
+ section: SECTION_TYPE_CONNECTION,
+ name: 'labels_to_be_notified_behavior',
+ choices: [
+ ['Match any of the labels', MATCH_ANY_LABEL],
+ ['Match all of the labels', MATCH_ALL_LABELS]
+ ]
+ }.freeze
+ ].freeze
super
end
+ def sections
+ [
+ {
+ type: SECTION_TYPE_CONNECTION,
+ title: s_('Integrations|Notifications'),
+ description: help
+ }
+ ]
+ end
+
+
override :configurable_events
def configurable_events
return [] unless editable?
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #378218 (closed)
Edited by Denys Mishunov