AR namespace statistics: disable confirmation figures

What does this MR do and why?

Disabling an organization's Artifact Registry asks the owner to type the registry handle, but the confirmation says nothing about what is behind that handle. This MR names the repository count and the stored size in the confirmation body, for example Repositories: 3 and Storage used: 20.42 MiB, so the owner sees the scope of what they are turning off before confirming.

Stacked on !256610 (merged), which adds the artifactRegistry { statistics } GraphQL field this reads. This MR targets that branch and must be rebased onto master once it merges. It is a sibling of !256618 (merged) (the same figures in the repositories list header); the two touch utils.js identically and merge in either order.

No user-visible change yet: the settings page is behind the artifact_registry_ui feature flag, which is disabled by default.

What changed

  • get_artifact_registry.query.graphql selects statistics { repositoriesCount deduplicatedSizeBytes } inside the registry block the activation section already reads. No extra browser request; the server makes one additional Artifact Registry read per settings page load (about 1 ms, a single counter-row lookup), which is the only Artifact Registry call this page makes.
  • activation_section.vue passes registry.statistics from its own query to the confirmation.
  • disable_confirmation.vue takes a nullable statistics prop and renders the figures as a list after the two existing consequence sentences. Each figure is nullable on its own and renders only when known, so an unknown figure is never shown as zero in a destructive confirmation; when neither is known, or the prop is null, the list is omitted and the handle prompt and the disable action are unchanged, so a statistics read failure never blocks disabling.
  • utils.js gains humanSizeClamped, which clamps a negative deduplicatedSizeBytes (a reconciliation underflow can report one until it corrects; see namespace_statistics_type.rb) so the modal shows 0 B rather than negative bytes. Same helper as !256618 (merged).
  • Two new externalized strings; locale/gitlab.pot regenerated.

Tests

  • disable_confirmation_spec.js: both figures named, with string inputs that exercise the formatting (1,234, 2.00 KiB); negative stored size renders as zero; only the known figure renders when the other is null; figures omitted while the action is still offered when statistics is null or both figures are null.
  • activation_section_spec.js: the statistics from the section's own query reach the confirmation.

References

Screenshots or screen recordings

Captured on GDK against a real local Artifact Registry (real per-user token exchange, no stubs) with three hosted repositories in the namespace. AR reported repositories_count: 3, deduplicated_size_bytes: 21408101. The registry was not actually disabled; every run ended with Cancel.

Before After
00-before-disable-modal 03-disable-modal-closeup
Settings page and the modal in context
Activation section (unchanged by this MR) Modal over the page
01-settings-activation-enabled 02-disable-modal-with-figures
Handle typed: the disable action enables as before

04-disable-modal-handle-typed-confirm-enabled

Statistics null: figures omitted, disable still offered

Simulated by intercepting the getArtifactRegistry response in the browser and replacing artifactRegistry.statistics with null; the rest of the registry block is untouched. The confirm button still enables once the handle is typed.

05-disable-modal-statistics-null-SIMULATED

How to set up and validate locally

Requires a running Artifact Registry the monolith can reach. The steps below are what produced the screenshots.

  1. Point GDK at your local AR in config/gitlab.yml under development: and restart rails-web:

    artifact_registry:
      api_url: http://127.0.0.1:8090
      service_token:
        secret_file: /path/to/ar-gitlab-api-service-token

    AR must run with auth.token_exchange pointed at GDK's issuer (http://gdk.test:3000, JWKS http://gdk.test:3000/oauth/discovery/keys, audience gitlab-artifact-registry) and auth.gitlab_api.service_token set to the same value as the secret file above.

  2. In rails console, enable the flags and pick an organization you own that has exactly one top-level group (activation derives the billing anchor from it and rejects an organization with several, which rules out the GDK default organization):

    Feature.enable(:artifact_registry_ui)
    Feature.enable(:org_stage_experimental) # organization pages gate
    org = Organizations::Organization.find_by!(path: 'ar-e2e')
    Group.where(organization_id: org.id, parent_id: nil).count # => 1
  3. Activate the registry and create a few repositories from /api/graphql as an owner (X-GitLab-Organization-ID: <org id> header, PAT with api):

    mutation { artifactRegistryActivate(input: { slug: "gdk" }) { errors registry { slug status } } }
    mutation { artifactRegistryRepositoryCreate(input: { name: "docker-hosted", format: DOCKER, kind: HOSTED, visibility: PRIVATE }) { errors repository { name } } }

    Push something into a repository so the size is non-zero, for example oras cp --to-plain-http docker.io/library/alpine:3.20 127.0.0.1:8090/gdk/container/docker-hosted/alpine:3.20.

  4. Confirm the block the section reads resolves against the real service:

    { organization(id: "gid://gitlab/Organizations::Organization/<org id>") {
        artifactRegistry { slug status statistics { repositoriesCount deduplicatedSizeBytes } } } }

    Expected shape: {"slug":"gdk","status":"active","statistics":{"repositoriesCount":"3","deduplicatedSizeBytes":"21408101"}} (your numbers will differ).

  5. Open http://gdk.test:3000/o/<org path>/-/settings/artifact_registry and select Disable Artifact Registry. The modal body lists Repositories: <count> and Storage used: <size> matching the query above. Type the handle: the confirm button enables as before. Cancel unless you mean to disable.

  6. Frontend specs:

    yarn jest ee/spec/frontend/packages_and_registries/artifact_registry/settings ee/spec/frontend/packages_and_registries/artifact_registry/utils_spec.js

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.

Edited by Narendran

Merge request reports

Loading
Loading