Gate the create dropdown and row kebab on Artifact registry list

What does this MR do and why?

This MR is part of monolith/S15. It gates two controls in the Artifact Registry repository list. The list read now carries permission verdicts at two levels. The connection carries a userPermissions block, typed ArtifactRegistryNamespacePermissions. Each repository node carries its own userPermissions block, typed ArtifactRegistryRepositoryPermissions.

The create dropdown renders only when the connection block answers true for createRepository. The row kebab renders only when the row block answers true for updateRepository. Edit repository is the kebab's only item, so a denied row loses the whole kebab instead of showing an empty menu. Both controls read their verdict through the shared permissionAllows helper. A denied control is removed, not disabled, so a user who cannot perform the action never sees a control that would only fail after the click. Artifact Registry still authorizes every request. The verdict only decides what renders. Gating happens per row, so one denied row among allowed rows loses only its own kebab. The Copy repository URL button next to it stays unaffected.

Two new fragments transcribe these permission blocks. The namespace fragment lists the seven namespace actions, and the list query spreads it on the connection. The repository fragment lists the repository actions, and the list query spreads it on each node. Both fragments are keyed on the permission block type, not on the connection or row type. Any other document that selects the same block can reuse the fragment without a second transcription. The detail and edit documents keep selecting their block inline, and do not depend on the list.

The list query uses cache-and-network. The page hands the connection block to the header and the empty state only after the query stops loading. A mount on a primed cache re-asks the network, and renders no dropdown until the answer arrives. The table stays busy and hides its rows until the same answer arrives, so no kebab can render from the cache alone either.

The list fixture stubs a permissions object on the Artifact Registry envelope and on each repository. The list read sends include_permissions=true, so the generated fixture carries both blocks. Mocks carry the same blocks, so specs build pages and rows the way the app does.

All of this stays behind the default-off artifact_registry_ui feature flag. No changelog entry is needed.

References

Screenshots or screen recordings

Screenshots of the gated state are not available yet. The dev rig's Artifact Registry answers 503 to permission reads. See the rig blocker: gitlab-org/ops/artifact-registry#1297 (closed). The behavior is covered by the Jest specs in this MR.

How to set up and validate locally

  1. In a Rails console, enable the feature flag:
    Feature.enable(:artifact_registry_ui, organization)
  2. Regenerate the frontend fixture this MR changes:
    bin/rspec ee/spec/frontend/fixtures/artifact_registry/repositories.rb
  3. Run the Jest specs this MR adds or changes:
    yarn jest ee/spec/frontend/packages_and_registries/artifact_registry/repositories/components/create_button_spec.js
    yarn jest ee/spec/frontend/packages_and_registries/artifact_registry/repositories/components/row_actions_menu_spec.js
    yarn jest ee/spec/frontend/packages_and_registries/artifact_registry/repositories/list/repositories_header_spec.js
    yarn jest ee/spec/frontend/packages_and_registries/artifact_registry/repositories/list/repositories_list_spec.js
    yarn jest ee/spec/frontend/packages_and_registries/artifact_registry/repositories/list/repositories_table_spec.js
  4. Open the organization's Artifact Registry pages. The gated controls need an Artifact Registry deployment that answers permissions.

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 Rahul Chanila

Merge request reports

Loading
Loading