Mark License Usage Banner as Dismissable After API Export

What does this MR do and why?

When using offline cloud licensing, the admin of a self managed instance is reminded to export license usage data to send to GitLab monthly. There are two methods to do the export, UI and API, but only the UI workflow will mark this banner as dismissable.

This MR updates the /license/usage_export API endpoint to update the license_usage_data_exported admin setting to true after the CSV export is generated. This will then allow the banner to be dismissed by the admin user, similar to the set_license_usage_data_exported action in the Admin::Licenses::UsageExportsController used by the UI

References

Screenshots or screen recordings

Before After
banner_not_dismissible banner_dismissible

Database Review

Including the below information as recommended in this bot comment

Raw SQL Query

UPDATE
    "application_settings"
SET
    "updated_at" = '2025-03-25 15:12:32.985770',
    "license_usage_data_exported" = TRUE
WHERE
    "application_settings"."id" = 1

Query Plan

https://console.postgres.ai/gitlab/gitlab-production-main/sessions/37707/commands/115201

How to set up and validate locally

  1. Connect your GDK instance to either a local CustomersDot instance or CustomersDot Staging
  2. Follow these docs to create a subscription in Zuora for a Self-Managed - Ultimate - 1 year plan, with the following adjustments:
    • Change Turn on Cloud Licensing field to Offline
    • Change the Order Date to at least 2 months in the past, ex: 2025-01-25. This is needed to pass this check here in order to display the banner
  3. Once CustomersDot has the license key available, log in as an admin to GDK and upload the license key to your instance
  4. Verify you can see the license usage data banner after uploading by visiting an admin page, such as /admin/subscription
  5. Send the following cURL request to your GDK instance to export your license usage data via API:
curl --location 'http://<YOUR_GDK_URL>/api/v4/license/usage_export.csv' \
--header 'PRIVATE-TOKEN: <YOUR_GDK_ADMIN_API_TOKEN>'
  1. Verify the export request is successful and visit the /admin/subscription page again
  2. Verify the close icon displays on the banner and can now be dismissed

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 #431208 (closed)

Edited by Valerie Burton

Merge request reports

Loading