Skip to content

Refactor create custom role permissions into its own component

Daniel Tian requested to merge 438838-refactor-custom-role-permissions into master

What does this MR do and why?

On the Settings -> Roles and Permissions page, there's a CreateMemberRole component that shows a form to create a new custom role:

ksnip_20240403-160717

Half of the code in CreateMemberRole is just for the permissions list. To keep the component size more manageable, this MR refactors the permissions list into its own component.

How to set up and validate locally

  1. Go to any top-level group.
  2. Go to Settings -> Roles and Permissions.
  3. Click the New role button.
  4. Verify that the permissions list is shown.
  5. Do not fill out the form. Scroll to the bottom and click on Create role.
  6. Verify that the permission validate properly. All the permission names should turn red.
  7. Verify that dependent permissions are automatically checked. Check Admin vulnerability and verify that Read vulnerability is automatically checked as well.
  8. Verify that dependent permissions are automatically unchecked. Uncheck Read vulnerability and verify that Admin vulnerability is automatically unchecked as well.
  9. Verify the creation. Fill out the form properly and click on Create role. Verify that the role was successfully created with the correct permissions.

We also have a new redesign of the page that's currently in development. To switch to it, apply this patch, then run through the validation steps again:

Patch
Index: ee/app/assets/javascripts/pages/admin/application_settings/roles_and_permissions/index.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ee/app/assets/javascripts/pages/admin/application_settings/roles_and_permissions/index.js b/ee/app/assets/javascripts/pages/admin/application_settings/roles_and_permissions/index.js
--- a/ee/app/assets/javascripts/pages/admin/application_settings/roles_and_permissions/index.js	(revision b075421643ab545cfee6ed1c20d3a71f309bb6a8)
+++ b/ee/app/assets/javascripts/pages/admin/application_settings/roles_and_permissions/index.js	(date 1710884444267)
@@ -1,3 +1,4 @@
-import { initRolesAndPermissions } from 'ee/roles_and_permissions';
+import { initRolesAndPermissions, initCustomRolesApp } from 'ee/roles_and_permissions';
 
-initRolesAndPermissions();
+initCustomRolesApp();
+// initRolesAndPermissions();
Index: ee/app/assets/javascripts/pages/groups/settings/roles_and_permissions/index.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ee/app/assets/javascripts/pages/groups/settings/roles_and_permissions/index.js b/ee/app/assets/javascripts/pages/groups/settings/roles_and_permissions/index.js
--- a/ee/app/assets/javascripts/pages/groups/settings/roles_and_permissions/index.js	(revision b075421643ab545cfee6ed1c20d3a71f309bb6a8)
+++ b/ee/app/assets/javascripts/pages/groups/settings/roles_and_permissions/index.js	(date 1710884444283)
@@ -1,3 +1,4 @@
-import { initRolesAndPermissions } from 'ee/roles_and_permissions';
+import { initRolesAndPermissions, initCustomRolesApp } from 'ee/roles_and_permissions';
 
-initRolesAndPermissions();
+initCustomRolesApp();
+// initRolesAndPermissions();

Related to #438838 (closed)

Edited by Daniel Tian

Merge request reports

Loading