From c868347552b40595178c78225e93a71dd482ce4a Mon Sep 17 00:00:00 2001 From: Thomas Trompette Date: Thu, 18 Jan 2024 18:22:26 +0100 Subject: [PATCH] Show page - disable click for workspace member relation (#3464) * [Draft] Add disable logic + failing test * Fix test * Remove hook --------- Co-authored-by: Thomas Trompette Co-authored-by: Charles Bochet --- .../utils/getObjectRecordIdentifier.ts | 7 +- .../__stories__/ChipFieldDisplay.stories.tsx | 67 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 packages/twenty-front/src/modules/object-record/field/meta-types/display/components/__stories__/ChipFieldDisplay.stories.tsx diff --git a/packages/twenty-front/src/modules/object-metadata/utils/getObjectRecordIdentifier.ts b/packages/twenty-front/src/modules/object-metadata/utils/getObjectRecordIdentifier.ts index aed686c6e1..c41e2122db 100644 --- a/packages/twenty-front/src/modules/object-metadata/utils/getObjectRecordIdentifier.ts +++ b/packages/twenty-front/src/modules/object-metadata/utils/getObjectRecordIdentifier.ts @@ -56,7 +56,12 @@ export const getObjectRecordIdentifier = ({ objectMetadataItem, }); - const linkToShowPage = `${basePathToShowPage}${record.id}`; + const isWorkspaceMemberObjectMetadata = + objectMetadataItem.nameSingular === CoreObjectNameSingular.WorkspaceMember; + + const linkToShowPage = isWorkspaceMemberObjectMetadata + ? '' + : `${basePathToShowPage}${record.id}`; return { id: record.id, diff --git a/packages/twenty-front/src/modules/object-record/field/meta-types/display/components/__stories__/ChipFieldDisplay.stories.tsx b/packages/twenty-front/src/modules/object-record/field/meta-types/display/components/__stories__/ChipFieldDisplay.stories.tsx new file mode 100644 index 0000000000..348c82b627 --- /dev/null +++ b/packages/twenty-front/src/modules/object-record/field/meta-types/display/components/__stories__/ChipFieldDisplay.stories.tsx @@ -0,0 +1,67 @@ +import { useEffect } from 'react'; +import { MemoryRouter } from 'react-router-dom'; +import { Meta, StoryObj } from '@storybook/react'; +import { useSetRecoilState } from 'recoil'; + +import { ChipFieldDisplay } from '@/object-record/field/meta-types/display/components/ChipFieldDisplay'; +import { entityFieldsFamilyState } from '@/object-record/field/states/entityFieldsFamilyState'; +import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator'; + +import { FieldContext } from '../../../../contexts/FieldContext'; + +const ChipFieldValueSetterEffect = () => { + const setEntityFields = useSetRecoilState(entityFieldsFamilyState('123')); + + useEffect(() => { + setEntityFields({ + id: 'henry', + name: { + firstName: 'Henry', + lastName: 'Cavill', + }, + }); + }, [setEntityFields]); + + return null; +}; + +const meta: Meta = { + title: 'UI/Data/Field/Display/ChipFieldDisplay', + decorators: [ + (Story) => ( + + + + + + + ), + ComponentDecorator, + ], + component: ChipFieldDisplay, + argTypes: { value: { control: 'date' } }, + args: {}, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {};