diff --git a/packages/twenty-front/src/modules/object-record/hooks/useFieldContext.tsx b/packages/twenty-front/src/modules/object-record/hooks/useFieldContext.tsx index 6599868681a0..4c14e9f17619 100644 --- a/packages/twenty-front/src/modules/object-record/hooks/useFieldContext.tsx +++ b/packages/twenty-front/src/modules/object-record/hooks/useFieldContext.tsx @@ -2,7 +2,6 @@ import { ReactNode } from 'react'; import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; import { formatFieldMetadataItemAsColumnDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsColumnDefinition'; -import { getBasePathToShowPage } from '@/object-metadata/utils/getBasePathToShowPage'; import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord'; import { FieldContext, @@ -34,10 +33,6 @@ export const useFieldContext = ({ objectNameSingular, }); - const basePathToShowPage = getBasePathToShowPage({ - objectNameSingular, - }); - const fieldMetadataItem = objectMetadataItem?.fields.find( (field) => field.name === fieldMetadataName, ); @@ -63,9 +58,6 @@ export const useFieldContext = ({ )} diff --git a/packages/twenty-front/src/modules/object-record/record-field/contexts/FieldContext.ts b/packages/twenty-front/src/modules/object-record/record-field/contexts/FieldContext.ts index e5b31be1cba8..85aedd618568 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/contexts/FieldContext.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/contexts/FieldContext.ts @@ -26,7 +26,7 @@ export type GenericFieldContextType = { recoilScopeId?: string; hotkeyScope: string; isLabelIdentifier: boolean; - basePathToShowPage?: string; + labelIdentifierLink?: string; clearable?: boolean; maxWidth?: number; isCentered?: boolean; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsx index 851460f5d24d..d43dc8f6b2e7 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsx @@ -4,8 +4,12 @@ import { RecordIdentifierChip } from '@/object-record/record-index/components/Re import { ChipSize } from 'twenty-ui'; export const ChipFieldDisplay = () => { - const { recordValue, objectNameSingular, isLabelIdentifier } = - useChipFieldDisplay(); + const { + recordValue, + objectNameSingular, + isLabelIdentifier, + labelIdentifierLink, + } = useChipFieldDisplay(); if (!recordValue) { return null; @@ -16,6 +20,7 @@ export const ChipFieldDisplay = () => { objectNameSingular={objectNameSingular} record={recordValue} size={ChipSize.Small} + to={labelIdentifierLink} /> ) : ( diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/__stories__/perf/RelationFromManyFieldDisplay.perf.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/__stories__/perf/RelationFromManyFieldDisplay.perf.stories.tsx index 2c6b1977a80e..270b36a1ae20 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/__stories__/perf/RelationFromManyFieldDisplay.perf.stories.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/__stories__/perf/RelationFromManyFieldDisplay.perf.stories.tsx @@ -65,7 +65,6 @@ const meta: Meta = { { - const { recordId, fieldDefinition, isLabelIdentifier } = + const { recordId, fieldDefinition, isLabelIdentifier, labelIdentifierLink } = useContext(FieldContext); const { chipGeneratorPerObjectPerField } = useContext( @@ -41,5 +41,6 @@ export const useChipFieldDisplay = () => { objectNameSingular, recordValue, isLabelIdentifier, + labelIdentifierLink, }; }; diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexRecordChip.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexRecordChip.tsx index c2fe3344e678..e0ffd86d9264 100644 --- a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexRecordChip.tsx +++ b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexRecordChip.tsx @@ -1,6 +1,5 @@ import { useGetStandardObjectIcon } from '@/object-metadata/hooks/useGetStandardObjectIcon'; import { useRecordChipData } from '@/object-record/hooks/useRecordChipData'; -import { useRecordIndexContextOrThrow } from '@/object-record/record-index/contexts/RecordIndexContext'; import { ObjectRecord } from '@/object-record/types/ObjectRecord'; import { AvatarChip, AvatarChipVariant, ChipSize } from 'twenty-ui'; @@ -9,6 +8,7 @@ export type RecordIdentifierChipProps = { record: ObjectRecord; variant?: AvatarChipVariant; size?: ChipSize; + to?: string; maxWidth?: number; }; @@ -17,9 +17,9 @@ export const RecordIdentifierChip = ({ record, variant, size, + to, maxWidth, }: RecordIdentifierChipProps) => { - const { indexIdentifierUrl } = useRecordIndexContextOrThrow(); const { recordChipData } = useRecordChipData({ objectNameSingular, record, @@ -33,7 +33,7 @@ export const RecordIdentifierChip = ({ name={recordChipData.name} avatarType={recordChipData.avatarType} avatarUrl={recordChipData.avatarUrl ?? ''} - to={indexIdentifierUrl ? indexIdentifierUrl(record.id) : undefined} + to={to} variant={variant} LeftIcon={LeftIcon} LeftIconColor={LeftIconColor} diff --git a/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/__stories__/RecordDetailRelationSection.stories.tsx b/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/__stories__/RecordDetailRelationSection.stories.tsx index aca53588e1be..929d9db390a0 100644 --- a/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/__stories__/RecordDetailRelationSection.stories.tsx +++ b/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/__stories__/RecordDetailRelationSection.stories.tsx @@ -35,7 +35,6 @@ const meta: Meta = { { const { objectMetadataItem } = useRecordTableContextOrThrow(); + const { indexIdentifierUrl } = useRecordIndexContextOrThrow(); + const { columnDefinition } = useContext(RecordTableCellContext); - const { recordId, pathToShowPage } = useRecordTableRowContextOrThrow(); + const { recordId } = useRecordTableRowContextOrThrow(); const updateRecord = useContext(RecordUpdateContext); @@ -44,7 +47,7 @@ export const RecordTableCellFieldContextWrapper = ({ fieldDefinition: columnDefinition, useUpdateRecord: () => [updateRecord, {}], hotkeyScope: customHotkeyScope, - basePathToShowPage: pathToShowPage, + labelIdentifierLink: indexIdentifierUrl(recordId), isLabelIdentifier: isLabelIdentifierField({ fieldMetadataItem: { id: columnDefinition.fieldMetadataId, diff --git a/packages/twenty-front/src/testing/decorators/getFieldDecorator.tsx b/packages/twenty-front/src/testing/decorators/getFieldDecorator.tsx index e61885ed9a0d..ee2906b3ba13 100644 --- a/packages/twenty-front/src/testing/decorators/getFieldDecorator.tsx +++ b/packages/twenty-front/src/testing/decorators/getFieldDecorator.tsx @@ -128,7 +128,6 @@ export const getFieldDecorator = field.name === fieldMetadataName, ); @@ -50,9 +45,6 @@ export const useMockFieldContext = ({