From f11ba60f289652eb27f3548bb31ef3b5830c1e44 Mon Sep 17 00:00:00 2001 From: Tiago Fonseca Date: Tue, 17 Dec 2024 11:08:50 -0300 Subject: [PATCH 01/10] feat: Displays what entity is being edited in side modal Signed-off-by: Tiago Fonseca --- frontend/web/components/EditPermissions.tsx | 82 ++++++++++--------- frontend/web/components/PermissionsTabs.tsx | 4 + .../web/components/RolePermissionsList.tsx | 2 +- frontend/web/components/modals/CreateRole.tsx | 3 + 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/frontend/web/components/EditPermissions.tsx b/frontend/web/components/EditPermissions.tsx index 229f6afaa0c3..ee8a356f3fcf 100644 --- a/frontend/web/components/EditPermissions.tsx +++ b/frontend/web/components/EditPermissions.tsx @@ -467,7 +467,7 @@ const _EditPermissionsModal: FC = withAdminPermissions( }) } //eslint-disable-next-line - }, []) + }, []) const admin = () => entityPermissions && entityPermissions.admin @@ -804,9 +804,24 @@ const _EditPermissionsModal: FC = withAdminPermissions( }) } + const getEditText = () => { + if (isGroup) { + return `the ${group?.name || ''} group` + } + if (user) { + return `${user.first_name || ''} ${user.last_name || ''}` + } + if (role) { + return role.name + } + return name + } + const rolesAdded = getRoles(roles, rolesSelected || []) const isAdmin = admin() + console.log('aosidjaosijaosijosi', level) + return !permissions || !entityPermissions ? (
@@ -826,15 +841,15 @@ const _EditPermissionsModal: FC = withAdminPermissions( { - toggleAdmin() - setValueChanged(true) - }} - checked={isAdmin} - /> - -
- )} + onChange={() => { + toggleAdmin() + setValueChanged(true) + }} + checked={isAdmin} + /> + + + )} { const name = Format.enumeration.get(item.key).toLowerCase() @@ -844,24 +859,24 @@ const _EditPermissionsModal: FC = withAdminPermissions( className='no-pad mb-2 overflow-visible' items={permissions} renderRow={(p: AvailablePermission, index: number) => { - const levelUpperCase = level.toUpperCase() - const disabled = - level !== 'organisation' && - p.key !== `VIEW_${levelUpperCase}` && - !hasPermission(`VIEW_${levelUpperCase}`) + const levelUpperCase = level.toUpperCase() + const disabled = + level !== 'organisation' && + p.key !== `VIEW_${levelUpperCase}` && + !hasPermission(`VIEW_${levelUpperCase}`) const permission = entityPermissions.permissions.find( (v) => v.permission_key === p.key, ) const permissionType = getPermissionType(p.key) - return ( - - - - {Format.enumeration.get(p.key)} + > + + + {Format.enumeration.get(p.key)}
{p.description}
@@ -875,7 +890,7 @@ const _EditPermissionsModal: FC = withAdminPermissions( }} /> )} -
+
{tagBasedPermissions ? (
= withAdminPermissions( />
) : ( - { setValueChanged(true) togglePermission(p.key)