Fix custom role creation and some other issues
What does this MR do and why?
On the Roles and Permissions
page, there's a create new role form:
This MR fixes the following issues with the form:
-
Fixed an issue where the selected permissions weren't saved because the backend needs lowercase permission names and we were sending uppercase permission names. This was causing custom roles to be created without any custom permissions assigned.
-
Fixed an issue where the
manage project access tokens
permission was shown even when the corresponding feature flag was off. -
Fixed an issue where it's possible to create a custom role with an empty role name. The backend handles this by setting the role name to
{base role} - custom
, but we should prevent this in the first place on the frontend. -
Improved a bunch of logic throughout the component (see comments).
How to set up and validate locally
- Create or go to a top-level group.
- Go to
Settings -> Roles and Permissions
. Click on theAdd new role
button. - Fill out the form and click on
Create new role
. Verify that the table shows the role with the permissions that you checked. - Click on the
Add new role
button again. Verify that themanage project access tokens
andarchive projects
permissions do not show. - Enable the
manage_project_access_tokens
feature flag. Verify that the permission for it now shows.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #431713 (closed)