Skip to content

Fix custom role creation and some other issues

Daniel Tian requested to merge 431713-fix-custom-role-creation into master

What does this MR do and why?

On the Roles and Permissions page, there's a create new role form:

ksnip_20231217-021246

This MR fixes the following issues with the form:

  1. 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.

  2. Fixed an issue where the manage project access tokens permission was shown even when the corresponding feature flag was off.

  3. 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.

  4. Improved a bunch of logic throughout the component (see comments).

How to set up and validate locally

  1. Create or go to a top-level group.
  2. Go to Settings -> Roles and Permissions. Click on the Add new role button.
  3. Fill out the form and click on Create new role. Verify that the table shows the role with the permissions that you checked.
  4. Click on the Add new role button again. Verify that the manage project access tokens and archive projects permissions do not show.
  5. 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.

Related to #431713 (closed)

Edited by Daniel Tian

Merge request reports