Skip to content

Disable the integrations sections if Slack app requires upgrade

Denys Mishunov requested to merge 376240-warn-about-slack-upgrade into master

What does this MR do and why?

The MR follows the UX plan introduced in Warn user conditionally if they need to update ... (#376240 - closed) for notifying users about the need to upgrade their version of the Slack application to be able to set up the Notifications (behind the feature flag).

The MR does 2 main things:

  • Updates the type of the alert (warning to default) with some text updates according to the issue
  • Disables the fields on the GitLab for Slack app integration if user needs to upgrade Slack

the reliable way of identifying whether user needs to upgrade the app is beyond the scope of this MR and is handled in a separate effort under Record Slack app permission scopes to allow fea... (#374720 - closed). In the meantime, since the whole feature is behind a flag, we hardcode the value but it will be updated to server the real value in Replace the hardcoded value for `:should_upgrad... (#385476 - closed)

Screenshots or screen recordings

Jira screenshots are used as a blueprint to make sure the changes to not leak into other integrations.

Before After
Jira Screenshot_2022-12-13_at_11.33.58 Screenshot_2022-12-13_at_11.25.42
GitLab for Slack Screenshot_2022-12-13_at_11.33.53 Screenshot_2022-12-13_at_11.25.21

How to set up and validate locally

  1. Check that the Slack Application (for example, http://127.0.0.1:3000/flightjs/Flight/-/settings/integrations/gitlab_slack_application/edit) and Jira (for example http://127.0.0.1:3000/flightjs/Flight/-/settings/integrations/jira/edit) integrations look fine
  2. Apply the patch to get the dummy sections pushed for the Slack Application integrations:
Patch
diff --git a/ee/app/models/integrations/gitlab_slack_application.rb b/ee/app/models/integrations/gitlab_slack_application.rb
index faf86cfa2511..46f5501f2a13 100644
--- a/ee/app/models/integrations/gitlab_slack_application.rb
+++ b/ee/app/models/integrations/gitlab_slack_application.rb
@@ -58,9 +58,48 @@ 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.'
+        },
+        {
+          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
+        },
+        {
+          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.'
+        },
+        {
+          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
+    end
 
-      super
+    def sections
+      [
+        {
+          type: SECTION_TYPE_CONNECTION,
+          title: s_('Integrations|Notifications'),
+          description: help
+        }
+      ]
     end
 
     override :configurable_events
  1. Re-check the aforementioned integrations - those should look exactly as they used to
  2. Enable the feature flag in the rails console (rails c): Feature.enable(:integration_slack_app_notifications)
  3. Check the integrations again. The "GitLab for Slack Application" should list the sections and the banner, as shown in the screenshot above. Jira integration should not be affected.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #376240 (closed)

Edited by Denys Mishunov

Merge request reports