Skip to content

Set up a Slack upgrade warning

Denys Mishunov requested to merge 378218-slack-integration-warning into master

What does this MR do and why?

The MR introduces the banner with the information about upgrading the GitLab for Slack application. This is required as a step in the course of Extend Slack app to support notifications (&8670 - closed) to notify the users that they have to make sure they are on the latest release of the app to be able to store the notifications.

The change is behind the :integration_slack_app_notifications feature flag and is not supposed to be publicly available at the moment.

Important note: we do not have a way of detecting whether a user is on the latest version of the app or not and whether the user's version is capable of storing the notifications. So the banner is permanently on the screen for the time being even after the upgrade. This is a known ~UX issue and is refelected in the frontend unit-tests.

Screenshots or screen recordings

Screenshot_2022-11-14_at_09.21.13

How to set up and validate locally

  1. Check that the Slack Application (/-/settings/integrations/gitlab_slack_application/edit) and Jira (-/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 08c869eca5c..d570109986e 100644
--- a/ee/app/models/integrations/gitlab_slack_application.rb
+++ b/ee/app/models/integrations/gitlab_slack_application.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Integrations
-  class GitlabSlackApplication < Integration
+  class GitlabSlackApplication < BaseChatNotification
     default_value_for :category, 'chat'
 
     has_one :slack_integration, foreign_key: :integration_id
@@ -39,7 +39,51 @@ def self.to_param
     end
 
     def fields
-      []
+      [
+        {
+          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
+    end
+
+    def sections
+      [
+        {
+          type: SECTION_TYPE_CONNECTION,
+          title: s_('Integrations|Notifications'),
+          description: help
+        }
+      ]
     end
 
     def chat_responder
  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 Slack Application one should list the sections nand the banner as showin 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 #378218 (closed), #373321 (closed)

Edited by Denys Mishunov

Merge request reports