Show page - disable click for workspace member relation (#3464)

* [Draft] Add disable logic + failing test

* Fix test

* Remove hook

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Thomas Trompette 2024-01-18 18:22:26 +01:00 committed by GitHub
parent d8c9a94e14
commit c868347552
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 73 additions and 1 deletions

View File

@ -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,

View File

@ -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) => (
<MemoryRouter>
<FieldContext.Provider
value={{
entityId: '123',
basePathToShowPage: '/object-record/',
isLabelIdentifier: false,
fieldDefinition: {
fieldMetadataId: 'full name',
label: 'Henry Cavill',
type: 'FULL_NAME',
iconName: 'IconCalendarEvent',
metadata: {
fieldName: 'full name',
objectMetadataNameSingular: 'person',
},
},
hotkeyScope: 'hotkey-scope',
}}
>
<ChipFieldValueSetterEffect />
<Story />
</FieldContext.Provider>
</MemoryRouter>
),
ComponentDecorator,
],
component: ChipFieldDisplay,
argTypes: { value: { control: 'date' } },
args: {},
};
export default meta;
type Story = StoryObj<typeof ChipFieldDisplay>;
export const Default: Story = {};