Add Duo agent platform admin request functionality to sidebar widget for self-managed

What does this MR do and why?

Adds Duo Agent Platform request functionality for self-managed DAP widget

  • Authorized Users / Instance Admins see the number of team members who have requested the Duo Agent Platform
  • Regular Users have the ability to request the Duo Agent Platform
  • Once requested the state of the widget keeps track of the request via a User Callout and increments the counter

References

Screenshots or screen recordings

I've added screen recordings for all widget states - please note that Duo text has been updated to reflect Duo Core and not DAP language in !204552 (comment 2742823490) per recent changes to what is tabbed for release this milestone.

Before After

Screen_Recording_2025-09-04_at_10.25.25_AM.mov

agent-dap-widget-request-button.mov

authorized-dap-agent-widget-variations.mov

authorized-agent-dap-with-team-member-count.mov

How to set up and validate locally

The shortcut to test all new request functionality + widget behaviors is to change these conditionals to true

# app/assets/javascripts/super_sidebar/components/super_sidebar.vue

<div v-if="showDuoAgentPlatformWidget" class="gl-p-2">
  <duo-agent-platform-widget
    class="gl-relative gl-mb-1 gl-flex gl-items-center gl-rounded-base gl-p-3 gl-leading-normal !gl-text-default !gl-no-underline"
   />
</div>

and then change these conditions to true to force the presenter you're interested in to appear

# ee/app/presenters/gitlab_subscriptions/duo/agent_platform_widget_presenter.rb

# frozen_string_literal: true

module GitlabSubscriptions
  module Duo
    class AgentPlatformWidgetPresenter
      include Gitlab::Utils::StrongMemoize

      def initialize(user)
        @user = user
      end

      def attributes
        # 
        presenter.attributes
      end

      private

      attr_reader :user

      def presenter
        if authorized_self_managed? # change these conditions to true to force the presenter you're interested in 
          GitlabSubscriptions::Duo::SelfManaged::AuthorizedAgentPlatformWidgetPresenter.new(user) # rubocop:disable CodeReuse/Presenter -- we use it in this coordinator class
        elsif self_managed? # change these conditions to true to force the presenter you're interested in 
          GitlabSubscriptions::Duo::SelfManaged::AgentPlatformWidgetPresenter.new(user) # rubocop:disable CodeReuse/Presenter -- we use it in this coordinator class
        else
          {}.tap { |h| h.define_singleton_method(:attributes) { self } } # placeholder while we iterate on the widget
        end
      end

      def authorized_self_managed?
        self_managed? && Ability.allowed?(user, :admin_all_resources)
      end

      def self_managed?
        !::Gitlab::Saas.feature_available?(:gitlab_duo_saas_only)
      end
    end
  end
end

You may also need to comment out the following line in the BaseAgentPlatformWidgetPresenter like so:

# return {} unless eligible?

Alternatively you can make the widget appear like this - and then toggle user permissions (or update the hack)

  1. Set up your GDK to point to CustomersDot Staging. In gdk.yml:
license:
 customer_portal_url: https://customers.staging.gitlab.com
 license_mode: test
  1. Also make sure you don't have GITLAB_SIMULATE_SAAS env variable as truthy, then you can reconfigure and restart GDK.
  2. Purchase a license that is at least Premium on https://customers.staging.gitlab.com
    • Follow this URL to purchase an Ultimate self-managed license (see these docs for details)
    • You can use a test credit card to complete these purchases
  3. Copy the activation code for the license from CustomersDot
  4. Go to the Admin area > Subscription and upload the activation code
  5. Comment out this line so that it is now # return false unless on_or_past_release_date?
  6. Refresh and ensure the widget is seen. If not shown, may need to purchase a duo pro/duo enterprise add on if duo core isn't automatically added due to being in local env. See here for more detail add on purchase instructions.
  7. Once uploaded, go to this path /admin/gitlab_duo/configuration in your browser. For example: http://gdk.test:3000/admin/gitlab_duo/configuration
  8. Try different combinations as shown in this table and then use the widget to enable.

MR acceptance checklist

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

Related to #565595

Edited by Buck O'Leary

Merge request reports

Loading