Skip to content
Snippets Groups Projects

Protect integration sections for Slack App with a feature flag

Merged Denys Mishunov requested to merge 375345-slack-app-vue-ff into master
1 unresolved thread

What does this MR do and why?

The MR introduces the support for the :integration_slack_app_notifications feature flag in the frontend and uses it to protect sections in Slack Application integration form while there's an ongoing process of merging the Slack Notifications integration into the Slack Application.

For the reference, here's the flowchart for the conditions taken from #372410 (comment 1127170652):

flowchart TB;
  id1["show help HTML + sections"]
  id2["show ONLY sections"]
  id3["show ONLY help HTML"]

  A{"Are we on 'gitlab_slack_application'?"} --> |Yes|B{is FF turned ON?}
  B -->|Yes|id1;
  B -->|No|id3;

  D{Do we have sections?};
  A --> |No|D;
  D --> |"No"|id3;
  D --> |"Yes"|id2

Screenshots or screen recordings

Route Before After with the flag OFF After with the flag ON
Slack Application without sections Screenshot_2022-10-06_at_13.14.37 Screenshot_2022-10-06_at_13.14.37 Screenshot_2022-10-06_at_13.15.55
Slack Application with mocked sections (see patch below) Screenshot_2022-10-10_at_14.53.27 Screenshot_2022-10-10_at_14.53.27 Screenshot_2022-10-06_at_12.49.37
Jira Screenshot_2022-10-06_at_13.13.13 Screenshot_2022-10-06_at_13.13.13 Screenshot_2022-10-06_at_12.57.42

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_TRIGGER,
+          title: s_('Integrations|Notifications trigger')
+        },
+        {
+          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 two sections now below the grey "Install Slack app" section (keep in mind that in production the sections should never be shown if the Slack application has not been installed yet - here, we're simply mocking the things). The Jira one should not be changed

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 #375046 (closed) and #372410 (closed)

Edited by Denys Mishunov

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 ---
2 name: integration_slack_app_notifications
3 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/98663
4 rollout_issue_url:
  • 🤖 GitLab Bot 🤖 added devopsmanage label and removed 1 deleted label

    added devopsmanage label and removed 1 deleted label

  • Please register or sign in to reply
    Loading