From 65bd1d7775e33c71ed3651d7324a9cd7b43d7e8f Mon Sep 17 00:00:00 2001 From: Weiko Date: Wed, 19 Feb 2025 18:58:19 +0100 Subject: [PATCH] Role permissions tab should display object permissions from API result (#10344) ## Context Role all-objects permissions were mocked. Now that the backend returns it, we are using its values. Screenshot 2025-02-19 at 18 39 07 --- .../twenty-front/src/generated/graphql.tsx | 10 +++++++--- .../roles/graphql/fragments/roleFragment.ts | 4 ++++ .../roles/components/RolePermissions.tsx | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/twenty-front/src/generated/graphql.tsx b/packages/twenty-front/src/generated/graphql.tsx index e5deadd85..2626d2bfc 100644 --- a/packages/twenty-front/src/generated/graphql.tsx +++ b/packages/twenty-front/src/generated/graphql.tsx @@ -2321,7 +2321,7 @@ export type UpdateLabPublicFeatureFlagMutationVariables = Exact<{ export type UpdateLabPublicFeatureFlagMutation = { __typename?: 'Mutation', updateLabPublicFeatureFlag: { __typename?: 'FeatureFlag', id: any, key: FeatureFlagKey, value: boolean } }; -export type RoleFragmentFragment = { __typename?: 'Role', id: string, label: string, description?: string | null, canUpdateAllSettings: boolean, isEditable: boolean }; +export type RoleFragmentFragment = { __typename?: 'Role', id: string, label: string, description?: string | null, canUpdateAllSettings: boolean, isEditable: boolean, canReadAllObjectRecords: boolean, canUpdateAllObjectRecords: boolean, canSoftDeleteAllObjectRecords: boolean, canDestroyAllObjectRecords: boolean }; export type UpdateWorkspaceMemberRoleMutationVariables = Exact<{ workspaceMemberId: Scalars['String']; @@ -2329,12 +2329,12 @@ export type UpdateWorkspaceMemberRoleMutationVariables = Exact<{ }>; -export type UpdateWorkspaceMemberRoleMutation = { __typename?: 'Mutation', updateWorkspaceMemberRole: { __typename?: 'WorkspaceMember', id: any, colorScheme: string, avatarUrl?: string | null, locale?: string | null, userEmail: string, timeZone?: string | null, dateFormat?: WorkspaceMemberDateFormatEnum | null, timeFormat?: WorkspaceMemberTimeFormatEnum | null, roles?: Array<{ __typename?: 'Role', id: string, label: string, description?: string | null, canUpdateAllSettings: boolean, isEditable: boolean }> | null, name: { __typename?: 'FullName', firstName: string, lastName: string } } }; +export type UpdateWorkspaceMemberRoleMutation = { __typename?: 'Mutation', updateWorkspaceMemberRole: { __typename?: 'WorkspaceMember', id: any, colorScheme: string, avatarUrl?: string | null, locale?: string | null, userEmail: string, timeZone?: string | null, dateFormat?: WorkspaceMemberDateFormatEnum | null, timeFormat?: WorkspaceMemberTimeFormatEnum | null, roles?: Array<{ __typename?: 'Role', id: string, label: string, description?: string | null, canUpdateAllSettings: boolean, isEditable: boolean, canReadAllObjectRecords: boolean, canUpdateAllObjectRecords: boolean, canSoftDeleteAllObjectRecords: boolean, canDestroyAllObjectRecords: boolean }> | null, name: { __typename?: 'FullName', firstName: string, lastName: string } } }; export type GetRolesQueryVariables = Exact<{ [key: string]: never; }>; -export type GetRolesQuery = { __typename?: 'Query', getRoles: Array<{ __typename?: 'Role', id: string, label: string, description?: string | null, canUpdateAllSettings: boolean, isEditable: boolean, workspaceMembers: Array<{ __typename?: 'WorkspaceMember', id: any, colorScheme: string, avatarUrl?: string | null, locale?: string | null, userEmail: string, timeZone?: string | null, dateFormat?: WorkspaceMemberDateFormatEnum | null, timeFormat?: WorkspaceMemberTimeFormatEnum | null, name: { __typename?: 'FullName', firstName: string, lastName: string } }> }> }; +export type GetRolesQuery = { __typename?: 'Query', getRoles: Array<{ __typename?: 'Role', id: string, label: string, description?: string | null, canUpdateAllSettings: boolean, isEditable: boolean, canReadAllObjectRecords: boolean, canUpdateAllObjectRecords: boolean, canSoftDeleteAllObjectRecords: boolean, canDestroyAllObjectRecords: boolean, workspaceMembers: Array<{ __typename?: 'WorkspaceMember', id: any, colorScheme: string, avatarUrl?: string | null, locale?: string | null, userEmail: string, timeZone?: string | null, dateFormat?: WorkspaceMemberDateFormatEnum | null, timeFormat?: WorkspaceMemberTimeFormatEnum | null, name: { __typename?: 'FullName', firstName: string, lastName: string } }> }> }; export type CreateOidcIdentityProviderMutationVariables = Exact<{ input: SetupOidcSsoInput; @@ -2616,6 +2616,10 @@ export const RoleFragmentFragmentDoc = gql` description canUpdateAllSettings isEditable + canReadAllObjectRecords + canUpdateAllObjectRecords + canSoftDeleteAllObjectRecords + canDestroyAllObjectRecords } `; export const WorkspaceMemberQueryFragmentFragmentDoc = gql` diff --git a/packages/twenty-front/src/modules/settings/roles/graphql/fragments/roleFragment.ts b/packages/twenty-front/src/modules/settings/roles/graphql/fragments/roleFragment.ts index 17c90f40d..d99ed6788 100644 --- a/packages/twenty-front/src/modules/settings/roles/graphql/fragments/roleFragment.ts +++ b/packages/twenty-front/src/modules/settings/roles/graphql/fragments/roleFragment.ts @@ -7,5 +7,9 @@ export const ROLE_FRAGMENT = gql` description canUpdateAllSettings isEditable + canReadAllObjectRecords + canUpdateAllObjectRecords + canSoftDeleteAllObjectRecords + canDestroyAllObjectRecords } `; diff --git a/packages/twenty-front/src/pages/settings/roles/components/RolePermissions.tsx b/packages/twenty-front/src/pages/settings/roles/components/RolePermissions.tsx index 25b70f2c5..746256319 100644 --- a/packages/twenty-front/src/pages/settings/roles/components/RolePermissions.tsx +++ b/packages/twenty-front/src/pages/settings/roles/components/RolePermissions.tsx @@ -22,7 +22,15 @@ const StyledRolePermissionsContainer = styled.div` `; type RolePermissionsProps = { - role: Pick; + role: Pick< + Role, + | 'id' + | 'canUpdateAllSettings' + | 'canReadAllObjectRecords' + | 'canUpdateAllObjectRecords' + | 'canSoftDeleteAllObjectRecords' + | 'canDestroyAllObjectRecords' + >; }; export const RolePermissions = ({ role }: RolePermissionsProps) => { @@ -31,25 +39,25 @@ export const RolePermissions = ({ role }: RolePermissionsProps) => { key: 'seeRecords', label: 'See Records on All Objects', icon: , - value: true, + value: role.canReadAllObjectRecords, }, { key: 'editRecords', label: 'Edit Records on All Objects', icon: , - value: true, + value: role.canUpdateAllObjectRecords, }, { key: 'deleteRecords', label: 'Delete Records on All Objects', icon: , - value: true, + value: role.canSoftDeleteAllObjectRecords, }, { key: 'destroyRecords', label: 'Destroy Records on All Objects', icon: , - value: true, + value: role.canDestroyAllObjectRecords, }, ];