Protected packages: Show protected label in packages list
requested to merge gitlab-community/gitlab:413641-gerardo-navarro-protected-packages-show-protected-packages-in-package-registry-list into master
What does this MR do and why?
- Read the description of the issue to get more context information, see #437926
- Feature flag switch to enable / disable the protected label
Personal notes (@gerardo-navarro)
Implementation challenge: How to efficiently check if the package is protected or not?
👎
Approach Matching on frontend - Pulling all package protection rules via GraphQL and performing the matching on the frontend in javscript is not a good option.
🛑
How are other GitLab solving this?
- In
app/views/projects/branches/_branch.html.haml
, the code checks for every branch if it is protected or notapp/helpers/branches_helper.rb
=> can I also do this with GraphQl? => maybe I need more insights. - The check of the branch is protected is partially optimized by using the
ProtectedBranches::CacheService
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.
MR Checklist (@gerardo-navarro)
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the javascript style guides -
Conforms to the database guides
Screenshots or screen recordings
The following screenshot shows the end result. All packages with at least one matching package protection rule will receive the badge "protected". For now, we disregard the information related to the access level in the protection rules.
How to set up and validate locally
- Enable the feature flag
:packages_protected_packages
Feature.enable(:packages_protected_packages)
- Go to the package registry setting of a project: http://gdk.test:3000/flightjs/Flight/-/settings/packages_and_registries
- Create a new package protection rule with package name pattern
@flightjs/npm_package_*
(<= this will match seeded packages that are already in the package registry) - Go to the package registry of the project: http://gdk.test:3000/flightjs/Flight/-/packages
- You should see the package entries with the label "protected"
Edited by Gerardo Navarro