Skip to content

Add Code Suggestions tab to conditionally render in CE

What does this MR do and why?

This implements Add Code Suggestions Tab (Duo Pro) to condition... (#440193 - closed)

After we finish with #440195 (closed), i.e. after we merge !143633 (merged) and !143637 (merged), we're now able to migrate other tabs. The migration here is simpler because we just need to conditionally render this tab.

In other words: This tab will be hooked to an App that is in CE but will only render in EE.

  • This piece is under usage_quotas_for_all_editions Feature Flag.
  • The Duo Pro tab only shows under the following conditions:
    • Your Group has a valid paid subscription
    • Your GDK has the Feature Flag hamilton_seat_management
    • the above is represented by the show_code_suggestions_tab? method

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

usage_quotas_for_all_editions off usage_quotas_for_all_editions on
uq_duo-pro_ff-off-master uq_duo-pro_ff-on

How to set up and validate locally

How to enable Usage Quotas Duo Pro Tab

  1. Needs both gdk and CustomersDot running (setup guide)
  2. In Rails console, enable Code Suggestions Feature.enable(:hamilton_seat_management)
  3. In Rails console, enable the filtering capabilities Feature.enable(:enable_add_on_users_filtering)

To assign Code Suggestions seats to your group:

  1. Pick (or create) a Group with a paid Subscription (e.g., Premium)
  2. In Rails console: add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
  3. In Rails console: GitlabSubscriptions::AddOnPurchase.create!(add_on: add_on, namespace: Namespace.find(<you-name-space-id>), expires_on: 21.month.from_now, quantity: 5, purchase_xid: 'A-S0002')
  4. Visit your group usage quotas page https://gdk.test:3443/groups/<your-group-here>/-/usage_quotas
  5. Check the expected behavior

The expected behavior

We need to validate this in 4 scenarios:

  1. GitLab EE Unlicensed: this is probably how your GDK is right now. If you have a license in your GDK, remove it in https://gdk.test:3443/admin/subscription
  2. GitLab EE: by having a test license in your GDK.
  3. GitLab SaaS: setup a license like the above and simulate SaaS
  4. GitLab CE: by executing
    1. export FOSS_ONLY=1
    2. gdk restart
    3. Tanuki gdk website icon (the one in the browser tab) should be blue, then you're in CE

Now go to your Group Usage Quotas: https://gdk.test:3443/groups/<your-group-here>/-/usage_quotas and check if your local setup matches the expected behavior.

  • To enable the FF: Feature.enable(:usage_quotas_for_all_editions)
  • To disable the FF: Feature.disable(:usage_quotas_for_all_editions)

Expected behavior:

GitLab Distribution Expected behavior FF off Expected behavior FF on
GitLab EE Unlicensed Renders a 404 page Renders the GitLab Duo Pro tab alongside the others
GitLab EE Loads the page normally Renders the GitLab Duo Pro tab alongside the others
GitLab SaaS Page loads normally Renders the GitLab Duo Pro tab alongside the others
GitLab CE Renders a 404 page Renders only the storage tab
Edited by Sheldon Led

Merge request reports