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.vueruns 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.jsmoves into thegraphql/utils/folder, next tocache_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 constantREPOSITORIES_COLUMNS_STORAGE_KEYinconstants.js. The stored value does not change. - The component
versions/view_options.vueis renamed toversions/version_list_view_options.vue, with its spec. This removes a name clash withcomponents/view_options.vue.version_list.vueregisters it asVersionListViewOptions. - The duplicate logic in
repositories_list.vueandversion_list.vuethat reads stored hidden columns is now one function,storedHiddenColumns(storageKey, optionalColumns), inutils.js. New unit tests cover it inutils_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
- Merge request 253848, "Add delete action to the artifact version list heading": !253848 (merged)
- Stale sidebar count after delete: !253848 (comment 3804835538)
- Spec file location: !253848 (comment 3804835615)
- Missing OCI row: !253848 (comment 3804835636)
- Merge request 254184, "Add view options to the Artifact Registry repositories list": !254184 (merged)
- Storage key as a literal: !254184 (comment 3805046749)
- Duplicate component name: !254184 (comment 3805046839)
- Duplicate hidden-columns logic: !254184 (comment 3805046850)
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
- Enable the feature flag in a Rails console:
Feature.enable(:artifact_registry_ui). - Go to the organization Artifact Registry repositories page. Open a repository that has at least two artifacts. Note the artifact count in the sidebar.
- Open one artifact's version list page. Open the "More actions" menu in the heading. Choose Delete, and confirm.
- Check that you return to the repository page. The artifact count in the sidebar is now lower, with no reload.
- 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.
- 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.