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
- !202833 (merged)
- https://gitlab.com/gitlab-org/gitlab/-/issues/565473
- https://gitlab.com/gitlab-org/gitlab/-/issues/565595 (Original issue)
- !204552 (comment 2742823490) - Duo related late breaking text updates
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 |
|---|---|
|
agent-dap-widget-request-button.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)
- Set up your GDK to point to CustomersDot Staging. In
gdk.yml:
license:
customer_portal_url: https://customers.staging.gitlab.com
license_mode: test
- Also make sure you don't have GITLAB_SIMULATE_SAAS env variable as truthy, then you can reconfigure and restart GDK.
- 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
- Copy the activation code for the license from CustomersDot
- Go to the Admin area > Subscription and upload the activation code
- Comment out this line so that it is now
# return false unless on_or_past_release_date? - 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.
- Once uploaded, go to this path
/admin/gitlab_duo/configurationin your browser. For example:http://gdk.test:3000/admin/gitlab_duo/configuration - 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