Show read-only token table when user cannot create
What does this MR do and why?
Follow-up to !195535. With migrate_grats_and_prats enabled, the group and
project access token pages mounted the shared access tokens app only for users
who can create tokens. Users who cannot create tokens lost the token table, so
they could not view or revoke existing tokens, which the legacy page allows:
- token creation disabled in the group settings
- auditors
- groups and projects on the Free plan (premium offer or upgrade card on GitLab.com)
- projects on a trial that reached the token limit
This MR mounts the shared app for everyone and passes two permissions to it:
can_createhides Add new token.can_rotate, from the samemanage_resource_access_tokenscheck as the rotate API, hides Rotate. Revoke stays available.
When token creation is disabled, both are false. For a project on a trial
that reached the token limit, can_create is false and the page shows the
existing Access token limit reached alert, while Rotate stays
available, as on the legacy page.
Everything is behind the default-off migrate_grats_and_prats feature flag.
No changelog entry.
References
- Parent MR: !195535 (this MR targets its branch)
- Review thread: !195535 (comment 4031886467)
- Related to #551094
- Rollout: #551192 (this MR is a prerequisite)
Screenshots or screen recordings
All states with migrate_grats_and_prats enabled. Each row has one token, and
the token's row menu is opened to show the available actions.
Light mode
Dark mode
How to set up and validate locally
- Enable the flag:
Feature.enable(:migrate_grats_and_prats) - Make sure a group you own has at least one group access token and one of its projects has a project access token.
- Disable token creation for the group:
Group.find_by_full_path('<group>').namespace_settings.update!(resource_access_token_creation_allowed: false) - Visit
/groups/<group>/-/settings/access_tokensand/<group>/<project>/-/settings/access_tokens. Confirm the "creation is disabled" message, the token table, no Add new token button, and only Revoke in the row menu. Revoke a token. - Re-enable creation (
resource_access_token_creation_allowed: true) and confirm Add new token and Rotate return. - Sign in as an auditor and visit a project's access tokens page: the message and the table render, without Add new token.
- Disable the flag and confirm the legacy pages are unchanged.
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.





















