Update package registry list to show accurate number of error packages

What does this MR do and why?

Context

As part of Filter package registry UI to show packages wit... (#451054 - closed) we updated the error package alert to show the number of error packages & add a link to the packages page with error status filter.

This was a MVC implementation which computes this number based on the current page results. This is not accurate since we don't know the errored packages from all the pages.

Implementation

  • Adds new graphql query to request for packages with error status.
  • Updates PackageErrorsCount to use graphql query.
  • Render errors count component above search component as per design
  • Update error packages href to ignore existing filters since the component does not exist within the search context anymore.

Noticed that the default error message when there is only one package does not match the message in the package list entry. I've updated the text so that the Delete this package and try again text shows up regardless of error message.

Changelog: added

Closes #460583 (closed)

References

Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

Reference to all possible error messages: !122299 (merged)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Before After
Screenshot_2024-10-31_at_3.31.37_PM Screenshot_2024-10-31_at_3.11.49_PM
Screenshot_2024-10-31_at_3.31.44_PM Screenshot_2024-10-31_at_3.29.26_PM

How to set up and validate locally

  1. On your rails console bundle exec rails c
    1. def fixture_file_upload(*args, **kwargs) Rack::Test::UploadedFile.new(*args, **kwargs) end
    2. Find the project where you want to work with the package registry p = Project.find(<project_id>)
    3. Create 10 packages: FactoryBot.create_list(:npm_package, 10, project: p)
  2. Go to the package registry using the sidebar or via the URL <hostname>/<project>/-/packages & visit the package detail page
  3. Back in your rails console Update the status of one package to ERROR Packages::Package.find(<package-id-from-details-page-url>).update(status: :error)
  4. Re-visit the list page & you should be able to see the error alert with alert message for only one package.
    1. Clicking on the button should show the confirmation to delete the package.
  5. Back in your rails console Update the status of two packages to ERROR
  6. Re-visit the list page & you should be able to see the error alert with alert message for only multiple packages.
    1. Clicking on the button redirect to the list page with Status filter set to Error

Other verification

  1. Verify that list page with Status filter set to Error does not show the error alert message.
  2. On the list page with Status filter set, change the query param value to uppercase & confirm the page filters by status correctly.
  3. Trying updating the status message for one of the error packages using .update(status_message: 'custom error message') & make sure the custom error message shows up.
Edited by Rahul Chanila

Merge request reports

Loading