From f210d274bf55e48c6ab076c3c2c511882baaa7f4 Mon Sep 17 00:00:00 2001 From: Weiko Date: Tue, 27 May 2025 17:58:55 +0200 Subject: [PATCH] Role page various fixes (#12324) Various fixes from fast follows - Sort roles by alphabetical order - Change some tooltips - During role creation, role should have all permissions enabled by default - Changed Permission icons design and refactored duplicating logic in a dedicated component - Changed "Revoked by" design - Display role icon in default role picker - Workspace member avatar was missing in role list and member picker - Set "seeded" member role as editable for new workspaces - Various css fixes --- .../components/SettingsRolesDefaultRole.tsx | 15 ++-- .../roles/components/SettingsRolesList.tsx | 15 ++-- .../components/SettingsRolesTableRow.tsx | 7 +- .../components/SettingsRoleAssignment.tsx | 3 +- .../SettingsRoleAssignmentTableRow.tsx | 2 +- ...ntWorkspaceMemberPickerDropdownContent.tsx | 3 +- ...RolePermissionsObjectLevelOverrideCell.tsx | 73 +++++-------------- ...tingsRolePermissionsObjectLevelSection.tsx | 1 + ...jectLevelObjectFormObjectLevelTableRow.tsx | 67 +++++++++-------- .../components/PermissionIcon.tsx | 51 +++++++++++++ ...SettingsRolePermissionsObjectsTableRow.tsx | 62 +++++++++------- .../settingsRoleObjectPermissionIconConfig.ts | 8 +- .../components/SettingsRoleCreateEffect.tsx | 10 +-- .../metadata-modules/role/role.module.ts | 2 + .../metadata-modules/role/role.resolver.ts | 30 +++++++- .../metadata-modules/role/role.service.ts | 2 +- 16 files changed, 214 insertions(+), 137 deletions(-) create mode 100644 packages/twenty-front/src/modules/settings/roles/role-permissions/objects-permissions/components/PermissionIcon.tsx diff --git a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesDefaultRole.tsx b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesDefaultRole.tsx index f5507c427..0ab4afc86 100644 --- a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesDefaultRole.tsx +++ b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesDefaultRole.tsx @@ -7,7 +7,7 @@ import { Select } from '@/ui/input/components/Select'; import { t } from '@lingui/core/macro'; import { useRecoilState } from 'recoil'; import { isDefined } from 'twenty-shared/utils'; -import { H2Title, IconUserPin } from 'twenty-ui/display'; +import { H2Title, IconUserPin, useIcons } from 'twenty-ui/display'; import { Card, Section } from 'twenty-ui/layout'; import { Role, @@ -51,10 +51,18 @@ export const SettingsRoleDefaultRole = ({ }); }; + const { getIcon } = useIcons(); + if (!currentWorkspace || !defaultRole) { return null; } + const options = roles.map((role) => ({ + label: role.label, + value: role.id, + Icon: getIcon(role.icon), + })); + return (
({ - label: role.label, - value: role.id, - }))} + options={options} value={defaultRole?.id ?? ''} onChange={(value) => updateDefaultRole(value as string, currentWorkspace) diff --git a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx index 33e4ae3f9..797f04f04 100644 --- a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx +++ b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx @@ -9,11 +9,12 @@ import { SettingsPath } from '@/types/SettingsPath'; import { TableCell } from '@/ui/layout/table/components/TableCell'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useRecoilValue } from 'recoil'; +import { H2Title, IconPlus } from 'twenty-ui/display'; +import { Button } from 'twenty-ui/input'; +import { Section } from 'twenty-ui/layout'; import { FeatureFlagKey } from '~/generated/graphql'; import { useNavigateSettings } from '~/hooks/useNavigateSettings'; -import { Button } from 'twenty-ui/input'; -import { H2Title, IconPlus } from 'twenty-ui/display'; -import { Section } from 'twenty-ui/layout'; +import { sortByAscString } from '~/utils/array/sortByAscString'; const StyledCreateRoleSection = styled(Section)` border-top: 1px solid ${({ theme }) => theme.border.color.light}; @@ -40,6 +41,10 @@ export const SettingsRolesList = () => { const settingsAllRoles = useRecoilValue(settingsAllRolesSelector); + const sortedSettingsAllRoles = [...settingsAllRoles].sort((a, b) => + sortByAscString(a.label, b.label), + ); + return (
{ - {settingsAllRoles.length === 0 ? ( + {sortedSettingsAllRoles.length === 0 ? ( {t`No roles found`} ) : ( - settingsAllRoles.map((role) => ( + sortedSettingsAllRoles.map((role) => ( )) )} diff --git a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesTableRow.tsx b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesTableRow.tsx index c638e9859..10c0a4a18 100644 --- a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesTableRow.tsx +++ b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesTableRow.tsx @@ -111,11 +111,8 @@ export const SettingsRolesTableRow = ({ role }: SettingsRolesTableRowProps) => { {role.workspaceMembers.length} - - + + ); diff --git a/packages/twenty-front/src/modules/settings/roles/role-assignment/components/SettingsRoleAssignment.tsx b/packages/twenty-front/src/modules/settings/roles/role-assignment/components/SettingsRoleAssignment.tsx index d91842700..1b2851867 100644 --- a/packages/twenty-front/src/modules/settings/roles/role-assignment/components/SettingsRoleAssignment.tsx +++ b/packages/twenty-front/src/modules/settings/roles/role-assignment/components/SettingsRoleAssignment.tsx @@ -243,6 +243,7 @@ export const SettingsRoleAssignment = ({
@@ -256,7 +257,7 @@ export const SettingsRoleAssignment = ({