Skip to content

Add ability to edit custom role

Daniel Tian requested to merge 437590-add-ability-to-edit-custom-role into master

What does this MR do and why?

We are currently working on a redesign of the Roles and Permissions page:

ksnip_20240402-012531

This MR adds the ability to edit a role by modifying the form used to create a role:

Peek_2024-04-02_01-27

and also the following:

  1. For the memberRoles query, adds a new field called editPath that's the web UI path to edit the role.
  2. Changes form validation to validate-on-change instead of validate-on-submit.

How to set up and validate locally

  1. Apply this patch to view the redesigned page:
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();
  1. Go to a top-level group, Settings -> Roles and Permissions.
  2. Click the New role button.
  3. You should be redirected to the create role page. Fill out the form, then click on Create Role to create the role.
  4. You should be redirected back to the list page. Verify that the role has been created.
  5. Click on the triple dot menu -> Edit Role.
  6. You should be redirected to the edit role page. Modify some stuff in the form, then click on Save Role to save the role.
  7. You should be redirected back to the list page. Verify that the role has been updated.
  8. Click on Admin Area -> Roles and Permissions. Repeat the same steps to test admin custom roles.

Related to #437590 (closed)

Edited by Daniel Tian

Merge request reports

Loading