Skip to content

Add controller and views for group & instance GitLab for Slack app

Luke Duncalfe requested to merge 391526-controllers-routes-views into master

What does this MR do and why?

This is a step towards the feature of supporting the GitLab for Slack app integration to be configured at group and instance-level #391526 (closed).

The change adds route, controller and view support for group and instance level configuration of the integration. This allows the GitLab for Slack app integration to be edited at the group and instance levels. It represents the Controllers, routes and views slice in #391526 (comment 1733489044). Future iterations will allow the GitLab for Slack app to be enabled via OAuth with Slack.

The changes are hidden behind a feature flag.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Group level Instance level
image image
image image

How to set up and validate locally

Set up

  1. In rails console enable the feature
    Feature.enable(:gitlab_for_slack_app_instance_and_group_level)
  2. Enable the GitLab for Slack app for your instance:
    1. Go to /admin
    2. Go Settings > General
    3. Next to GitLab for Slack app click Expand
    4. Check Enable GitLab for Slack app
    5. Enter the word secret into the form fields, and click Save

QA Group level

  1. Create data (the next iteration will include functionality to create it through the UI #391526 (comment 1733489044)):
    group = Group.find_by_full_path(...)
    integration = Integrations::GitlabSlackApplication.for_group(group).first || Integrations::GitlabSlackApplication.new(group: group)
    integration.assign_attributes(active: true)
    integration.save!(context: :manual_change)
    SlackIntegration.find_or_initialize_by(integration: integration).update(team_id: 'foo', team_name: "Foo Slack Workspace", alias: group.full_path, user_id: 'foo')
  2. Visit the group and go Settings > Integrations > GitLab for Slack app
  3. Verify that you can edit the form and click the red bin button to "unlink" the Slack app
  4. Toggle the flag off
    Feature.disable(:gitlab_for_slack_app_instance_and_group_level)
  5. Wait around 1 minute for the flag cache to clear
  6. Verify that reloading the GitLab for Slack app form you get a 404
  7. Go Settings > Integrations and verify that you do not see the GitLab for Slack app listed

QA instance level

  1. Create data (the next iteration will include functionality to create it through the UI #391526 (comment 1733489044)):
    integration = Integrations::GitlabSlackApplication.for_instance.first || Integrations::GitlabSlackApplication.new(instance: true)
    integration.assign_attributes(active: true)
    integration.save!(context: :manual_change)
    SlackIntegration.find_or_initialize_by(integration: integration).update(team_id: 'foo', team_name: "Foo Slack Workspace", alias: "instance", user_id: 'foo')
  2. Visit /admin and go Settings > Integrations > GitLab for Slack app
  3. Verify that you can edit the form and click the red bin button to "unlink" the Slack app
  4. Toggle the flag off
    Feature.disable(:gitlab_for_slack_app_instance_and_group_level)
  5. Wait around 1 minute for the flag cache to clear
  6. Verify that reloading the GitLab for Slack app form you get a 404
  7. Go Settings > Integrations and verify that you do not see the GitLab for Slack app listed

Related to #391526 (closed)

Edited by Luke Duncalfe

Merge request reports