Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type GenericFieldContextType = {
fieldDefinition: FieldDefinition<FieldMetadata>;
useUpdateRecord?: RecordUpdateHook;
isLabelIdentifier: boolean;
isLabelIdentifierCompact?: boolean;
clearable?: boolean;
maxWidth?: number;
isCentered?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { RecordChip } from '@/object-record/components/RecordChip';
import { useChipFieldDisplay } from '@/object-record/record-field/ui/meta-types/hooks/useChipFieldDisplay';
import { shouldCompactRecordIndexLabelIdentifierComponentState } from '@/object-record/record-index/states/shouldCompactRecordIndexLabelIdentifierComponentState';
import { useRecoilComponentValue } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValue';
import { isDefined } from 'twenty-shared/utils';
import { ChipSize } from 'twenty-ui/components';

Expand All @@ -14,14 +12,9 @@ export const ChipFieldDisplay = () => {
maxWidth,
triggerEvent,
onRecordChipClick,
isLabelIdentifierCompact,
} = useChipFieldDisplay();

const shouldCompactRecordIndexLabelIdentifier = useRecoilComponentValue(
shouldCompactRecordIndexLabelIdentifierComponentState,
);

const isLabelIdentifierCompact = shouldCompactRecordIndexLabelIdentifier;

if (!isDefined(recordValue)) {
return null;
}
Expand All @@ -33,7 +26,7 @@ export const ChipFieldDisplay = () => {
record={recordValue}
size={ChipSize.Small}
to={labelIdentifierLink}
isLabelHidden={isLabelIdentifierCompact}
isLabelHidden={isLabelIdentifierCompact ?? false}
forceDisableClick={disableChipClick}
triggerEvent={triggerEvent}
onClick={onRecordChipClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const useChipFieldDisplay = () => {
maxWidth,
triggerEvent,
onRecordChipClick,
isLabelIdentifierCompact,
} = useContext(FieldContext);

const { indexIdentifierUrl, labelIdentifierFieldMetadataItem } =
Expand Down Expand Up @@ -62,5 +63,6 @@ export const useChipFieldDisplay = () => {
maxWidth,
triggerEvent,
onRecordChipClick,
isLabelIdentifierCompact,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { getObjectPermissionsForObject } from '@/object-metadata/utils/getObject
import { isRecordFieldReadOnly } from '@/object-record/read-only/utils/isRecordFieldReadOnly';
import { FieldContext } from '@/object-record/record-field/ui/contexts/FieldContext';
import { useRecordIndexContextOrThrow } from '@/object-record/record-index/contexts/RecordIndexContext';
import { shouldCompactRecordIndexLabelIdentifierComponentState } from '@/object-record/record-index/states/shouldCompactRecordIndexLabelIdentifierComponentState';
import { RecordUpdateContext } from '@/object-record/record-table/contexts/EntityUpdateMutationHookContext';
import { RecordTableCellContext } from '@/object-record/record-table/contexts/RecordTableCellContext';
import { useRecordTableContextOrThrow } from '@/object-record/record-table/contexts/RecordTableContext';
import { useRecordTableRowContextOrThrow } from '@/object-record/record-table/contexts/RecordTableRowContext';
import { useRecoilComponentValue } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValue';
import { useContext, type ReactNode } from 'react';

type RecordTableCellFieldContextLabelIdentifierProps = {
Expand All @@ -31,6 +33,10 @@ export const RecordTableCellFieldContextLabelIdentifier = ({
objectMetadataItem.id,
);

const shouldCompactRecordIndexLabelIdentifier = useRecoilComponentValue(
shouldCompactRecordIndexLabelIdentifierComponentState,
);

const hasObjectReadPermissions = objectPermissions.canReadObjectRecords;

const updateRecord = useContext(RecordUpdateContext);
Expand All @@ -49,6 +55,7 @@ export const RecordTableCellFieldContextLabelIdentifier = ({
fieldDefinition,
useUpdateRecord: () => [updateRecord, {}],
isLabelIdentifier: true,
isLabelIdentifierCompact: shouldCompactRecordIndexLabelIdentifier,
displayedMaxRows: 1,
isRecordFieldReadOnly: isRecordFieldReadOnly({
isRecordReadOnly: isRecordReadOnly ?? false,
Expand Down