Apply review follow-ups for Artifact Registry deletes and view options

What does this MR do and why?

This merge request (MR) applies the non-blocking review follow-ups from two merged Artifact Registry frontend MRs. The reviewer left three follow-up items on each MR. This MR makes all six changes.

All changes are in the EE (Enterprise Edition) frontend, under ee/app/assets/javascripts/packages_and_registries/artifact_registry/, and in the matching spec files.

From merge request 253848, "Add delete action to the artifact version list heading":

  • After the delete mutation is accepted, artifact_actions.vue runs a network-only read of the repository detail query, so the detail page shows a current artifact count on return. The component catches a failure of this read on its own, so it does not change the result of the deletion.
  • The spec file delete_artifact_spec.js moves into the graphql/utils/ folder, next to cache_update_spec.js. This matches the folder of the code it tests.
  • The toggle-text spec table for the artifact actions menu now includes an OCI (Open Container Initiative) row, in addition to MAVEN, NPM, and DOCKER.

From merge request 254184, "Add view options to the Artifact Registry repositories list":

  • The repositories list columns storage key moves out of repositories_list.vue. It is now the constant REPOSITORIES_COLUMNS_STORAGE_KEY in constants.js. The stored value does not change.
  • The component versions/view_options.vue is renamed to versions/version_list_view_options.vue, with its spec. This removes a name clash with components/view_options.vue. version_list.vue registers it as VersionListViewOptions.
  • The duplicate logic in repositories_list.vue and version_list.vue that reads stored hidden columns is now one function, storedHiddenColumns(storageKey, optionalColumns), in utils.js. New unit tests cover it in utils_spec.js.

Why the refetch differs from the review suggestion

The review comment suggested using refetchQueries with the bare query document, as artifacts_table.vue does. That works on the repository detail page, because the detail query is active there.

On the version list route, the detail component is not mounted, so the query has no active observer. Apollo Client (the GraphQL client library) is on version 3.5 in this project. In that version, refetchQueries with a bare document only refetches active queries. Otherwise, it logs a warning during development.

Passing the document with variables to refetchQueries would run a one-time fetch. But with awaitRefetchQueries, the mutation promise then also rejects if that fetch fails. The delete would have already succeeded on the server. Yet the user would see the "Something went wrong" alert and stay on the page. A GitLab Duo review comment on this MR pointed this out: !254329 (comment 3805992853)

So the component now awaits the delete mutation first. Only after the mutation is accepted does it run a separate network-only query for the repository detail. This writes the fresh result into the cache. That read has its own error handling. A failure there falls back to the cached count, and never masks a successful deletion. A spec covers the case where the deletion succeeds and the refetch fails.

No changelog entry: the UI is behind the default-off artifact_registry_ui feature flag.

References

Screenshots or screen recordings

There is no visual change. The only behavior change is that the repository artifact count is now current after a delete from the version list page, with no page reload needed.

Before After
n/a n/a

How to set up and validate locally

  1. Enable the feature flag in a Rails console: Feature.enable(:artifact_registry_ui).
  2. Go to the organization Artifact Registry repositories page. Open a repository that has at least two artifacts. Note the artifact count in the sidebar.
  3. Open one artifact's version list page. Open the "More actions" menu in the heading. Choose Delete, and confirm.
  4. Check that you return to the repository page. The artifact count in the sidebar is now lower, with no reload.
  5. On the repositories list, hide a column using the view options popover. Reload the page. Check that the choice persists, since the stored value did not change.
  6. Run the specs: yarn jest ee/spec/frontend/packages_and_registries/artifact_registry.

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