d5a7dec117
## Summary - Renames `ObjectMetadataItem` to `EnrichedObjectMetadataItem` across the entire frontend (~440 files) to clarify that this type includes derived fields (`readableFields`, `updatableFields`, nested `fields[]`, `indexMetadatas[]`) computed at read time from the metadata store - Creates `splitObjectMetadataGqlResponse` that goes directly from a GraphQL `ObjectMetadataItemsQuery` response to flat store items (combining the old `mapPaginatedObjectMetadataItemsToObjectMetadataItems` + `splitObjectMetadataItemWithRelated` two-step flow into one call) - Removes `ObjectMetadataItemWithRelated` type and all "WithRelated" naming - Renames `generatedMockObjectMetadataItems` to `generateTestEnrichedObjectMetadataItemsMock` to make it clear this is test-only enriched data - Deletes `useLoadMockedObjectMetadataItems` hook (consolidated into `useLoadMockedMinimalMetadata`) - Ensures nothing destined for the metadata store computes `readableFields`/`updatableFields` (preventing the localStorage bloat from #18809) ## Type hierarchy (before → after) **Before:** ``` ObjectMetadataItemsQuery → mapPaginated → ObjectMetadataItemWithRelated → enrich → ObjectMetadataItem → split → FlatObjectMetadataItem (store) ``` **After:** ``` ObjectMetadataItemsQuery → splitObjectMetadataGqlResponse → FlatObjectMetadataItem (store) → mapPaginated + enrich (tests only) → EnrichedObjectMetadataItem ``` ## Test plan - [x] `npx nx typecheck twenty-front` passes - [x] `npx nx test twenty-front` passes (767 suites, 4505 tests) - [x] `npx nx lint twenty-front` passes - [ ] CI checks pass Made with [Cursor](https://cursor.com)
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
import { isDefined } from 'twenty-shared/utils';
|
|
import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
|
|
import { TableCell } from '@/ui/layout/table/components/TableCell';
|
|
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
|
import { Checkbox } from 'twenty-ui/input';
|
|
import { useIcons } from 'twenty-ui/display';
|
|
import { styled } from '@linaria/react';
|
|
import { useContext } from 'react';
|
|
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
|
|
|
|
export const AVAILABLE_STANDARD_OBJECTS_GRID_TEMPLATE_COLUMNS =
|
|
'28px 148px 256px 80px';
|
|
|
|
type SettingsAvailableStandardObjectItemTableRowProps = {
|
|
isSelected?: boolean;
|
|
objectItem: EnrichedObjectMetadataItem;
|
|
onClick?: () => void;
|
|
};
|
|
|
|
const StyledDescription = styled.div`
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
`;
|
|
|
|
export const SettingsAvailableStandardObjectItemTableRow = ({
|
|
isSelected,
|
|
objectItem,
|
|
onClick,
|
|
}: SettingsAvailableStandardObjectItemTableRowProps) => {
|
|
const { theme } = useContext(ThemeContext);
|
|
const { getIcon } = useIcons();
|
|
const Icon = getIcon(objectItem.icon);
|
|
|
|
return (
|
|
<TableRow
|
|
gridTemplateColumns={AVAILABLE_STANDARD_OBJECTS_GRID_TEMPLATE_COLUMNS}
|
|
key={objectItem.namePlural}
|
|
isSelected={isSelected}
|
|
onClick={onClick}
|
|
>
|
|
<TableCell
|
|
align="center"
|
|
padding={`0 0 0 ${themeCssVariables.spacing[1]}`}
|
|
>
|
|
<Checkbox checked={!!isSelected} />
|
|
</TableCell>
|
|
<TableCell
|
|
color={themeCssVariables.font.color.primary}
|
|
gap={themeCssVariables.spacing[2]}
|
|
>
|
|
{isDefined(Icon) && <Icon size={theme.icon.size.md} />}
|
|
{objectItem.labelPlural}
|
|
</TableCell>
|
|
<TableCell>
|
|
<StyledDescription>{objectItem.description}</StyledDescription>
|
|
</TableCell>
|
|
<TableCell align="right">{objectItem.fields.length}</TableCell>
|
|
</TableRow>
|
|
);
|
|
};
|