From 1df0603aaae8143fbbfa03304aeec0d3e9318daf Mon Sep 17 00:00:00 2001 From: Thomas Trompette Date: Thu, 16 Jan 2025 17:16:42 +0100 Subject: [PATCH] Fix filter displayed value from query params (#9693) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Filter displayed value that use query params was broken. Recently we added a new type of filters using the schema `{ selectedRecordIds: string[] }` while before we were using `string[]` directly. In that case, when fetching relation record name, we need to fix the findManyRecord query. Before Capture d’écran 2025-01-16 à 16 10 33 After Capture d’écran 2025-01-16 à 16 04 43 --- .../hooks/internal/useViewFromQueryParams.ts | 20 +++++++++++++++++-- .../hooks/useDeactivateWorkflowVersion.ts | 8 ++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/twenty-front/src/modules/views/hooks/internal/useViewFromQueryParams.ts b/packages/twenty-front/src/modules/views/hooks/internal/useViewFromQueryParams.ts index 820648808..42d305566 100644 --- a/packages/twenty-front/src/modules/views/hooks/internal/useViewFromQueryParams.ts +++ b/packages/twenty-front/src/modules/views/hooks/internal/useViewFromQueryParams.ts @@ -112,12 +112,18 @@ export const useViewFromQueryParams = () => { .getValue() : null; + const satisfiesRelationFilterSchema = + relationFilterValueSchemaObject.safeParse( + filterValueFromURL, + )?.success; + const relationRecordNames = []; if ( isNonEmptyString(relationObjectMetadataNamePlural) && isDefined(relationObjectMetadataItem) && - Array.isArray(filterValueFromURL) + (Array.isArray(filterValueFromURL) || + satisfiesRelationFilterSchema) ) { const queryResult = await apolloClient.query< Record @@ -127,7 +133,17 @@ export const useViewFromQueryParams = () => { objectMetadataItems, }), variables: { - filter: { id: { in: filterValueFromURL } }, + filter: { + id: { + in: satisfiesRelationFilterSchema + ? ( + filterValueFromURL as { + selectedRecordIds: string[]; + } + )?.selectedRecordIds + : filterValueFromURL, + }, + }, }, }); diff --git a/packages/twenty-front/src/modules/workflow/hooks/useDeactivateWorkflowVersion.ts b/packages/twenty-front/src/modules/workflow/hooks/useDeactivateWorkflowVersion.ts index 298146800..7a03426a0 100644 --- a/packages/twenty-front/src/modules/workflow/hooks/useDeactivateWorkflowVersion.ts +++ b/packages/twenty-front/src/modules/workflow/hooks/useDeactivateWorkflowVersion.ts @@ -5,15 +5,15 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordFromCache'; import { DEACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/deactivateWorkflowVersion'; import { - ActivateWorkflowVersionMutation, - ActivateWorkflowVersionMutationVariables, + DeactivateWorkflowVersionMutation, + DeactivateWorkflowVersionMutationVariables, } from '~/generated/graphql'; export const useDeactivateWorkflowVersion = () => { const apolloClient = useApolloClient(); const [mutate] = useMutation< - ActivateWorkflowVersionMutation, - ActivateWorkflowVersionMutationVariables + DeactivateWorkflowVersionMutation, + DeactivateWorkflowVersionMutationVariables >(DEACTIVATE_WORKFLOW_VERSION, { client: apolloClient, });