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_create hides Add new token.
  • can_rotate, from the same manage_resource_access_tokens check 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

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

State Before After
Group, token creation disabled (owner) group-creation-disabled before, light group-creation-disabled after, light
Project, token creation disabled (owner) project-creation-disabled before, light project-creation-disabled after, light
Project in a personal namespace, auditor project-auditor before, light project-auditor after, light
Project, trial token limit reached (SaaS) project-trial-limit before, light project-trial-limit after, light
Group on the Free plan, premium offer (SaaS) group-premium-offer before, light group-premium-offer after, light
Project on the Free plan, upgrade card (SaaS) project-upgrade-card before, light project-upgrade-card after, light
Group, owner who can create (baseline, unchanged) group-can-create before, light group-can-create after, light

Dark mode

State Before After
Group, token creation disabled (owner) group-creation-disabled before, dark group-creation-disabled after, dark
Project, token creation disabled (owner) project-creation-disabled before, dark project-creation-disabled after, dark
Project in a personal namespace, auditor project-auditor before, dark project-auditor after, dark
Project, trial token limit reached (SaaS) project-trial-limit before, dark project-trial-limit after, dark
Group on the Free plan, premium offer (SaaS) group-premium-offer before, dark group-premium-offer after, dark
Project on the Free plan, upgrade card (SaaS) project-upgrade-card before, dark project-upgrade-card after, dark
Group, owner who can create (baseline, unchanged) group-can-create before, dark group-can-create after, dark

How to set up and validate locally

  1. Enable the flag:
    Feature.enable(:migrate_grats_and_prats)
  2. Make sure a group you own has at least one group access token and one of its projects has a project access token.
  3. Disable token creation for the group:
    Group.find_by_full_path('<group>').namespace_settings.update!(resource_access_token_creation_allowed: false)
  4. Visit /groups/<group>/-/settings/access_tokens and /<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.
  5. Re-enable creation (resource_access_token_creation_allowed: true) and confirm Add new token and Rotate return.
  6. Sign in as an auditor and visit a project's access tokens page: the message and the table render, without Add new token.
  7. 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.

Merge request reports

Loading
Loading