From b928e94e515669da8b4fe70d28de37284340a898 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 12 Jul 2025 23:26:50 -0600 Subject: [PATCH] refactor(users): improve role assignment UI and logic - Enhanced the role assignment component by conditionally rendering roles and disabling the owner role in the selection. - Updated the display of role permissions and descriptions for better clarity and user experience. - Changed the button label from "Assign Role" to "Save Role" to better reflect the action being performed. --- .../settings/users/add-permissions-v2.tsx | 102 ++++++++++-------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/apps/dokploy/components/dashboard/settings/users/add-permissions-v2.tsx b/apps/dokploy/components/dashboard/settings/users/add-permissions-v2.tsx index 53ed26f97..e92d48c9b 100644 --- a/apps/dokploy/components/dashboard/settings/users/add-permissions-v2.tsx +++ b/apps/dokploy/components/dashboard/settings/users/add-permissions-v2.tsx @@ -142,7 +142,7 @@ export const AddUserPermissionsV2 = ({ userId }: Props) => { const isFullAccessRole = selectedRole && - (selectedRole.name === "owner" || selectedRole.name === "admin"); // Owner permission indicator + (selectedRole.name === "owner" || selectedRole.name === "admin"); const onAssignRole = async (data: AssignRoleForm) => { try { @@ -266,49 +266,63 @@ export const AddUserPermissionsV2 = ({ userId }: Props) => {

Default Roles

- {defaultRoles?.roles?.map((role) => ( - - - - - -
- - {role.name} - - {role.name === "owner" && ( - - Full Access - + {defaultRoles?.roles?.map((role) => { + const isOwner = role.name === "owner"; + const isAdmin = role.name === "admin"; + if (isOwner) { + return null; + } + return ( + + + + + +
+ + {role.name} + + {isAdmin && ( + + Full Access + + )} +
+
+ {role.description} +
+ {!isOwner && ( +
+ {role.permissions?.map( + (permission) => ( + + {permission.description} + + ), + )} +
)} -
-
- {role.description} -
-
- {role.permissions?.map((permission) => ( - - {permission.description} - - ))} -
-
-
- ))} + + + ); + })} @@ -608,7 +622,7 @@ export const AddUserPermissionsV2 = ({ userId }: Props) => {