Files
twenty/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx
T
Raphaël Bosi 8034c7725f Reorganize twenty-ui into best-practice component domains and per-component folders (#21745)
Reorganizes `twenty-ui`'s component organization to follow how the best
UI libraries (MUI, Mantine, Base UI, Polaris) structure their source,
now that the package has stabilized.

**Taxonomy** — dissolves the meaningless `components/` junk-drawer and
the 107-file `display/` mega-category. New domains/subpaths:
`data-display`, `typography`, `icon`, `surfaces`; `feedback` and
`layout` absorb the rest (banners/callout/info + placeholders →
feedback; modal/card → surfaces; motion + separators → layout).

**Per-component layout** — every component is now
`<domain>/<ComponentName>/<ComponentName>.tsx` with colocated
styles/stories/types, `internal/` for private helpers and `parts/` for
re-exported compound sub-parts. The redundant inner `/components/` is
gone. `icon` and `json-visualizer` are kept as cohesive subsystems.

**Also:** adds a tree-shakeable root barrel (`import { Button } from
'twenty-ui'`), the generator now owns `individual-entry.ts`, and a real
barrel-leak bug is fixed (private `internals/` parts were leaking into
the public API).

Consumer imports (~1.2k files) and the `twenty-sdk` UI aggregator were
updated by codemod. The change is **export-neutral** except 16
intentionally-removed private internals symbols (all verified
unconsumed). Gates green: typecheck, lint, build, size-limit, storybook.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21745?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
2026-06-18 10:31:29 +02:00

120 lines
3.6 KiB
TypeScript

import { isDDLLockedState } from '@/client-config/states/isDDLLockedState';
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
import { SettingsDiscoveryHeroCard } from '@/settings/components/SettingsDiscoveryHeroCard';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { SettingsPageLayout } from '@/settings/components/layout/SettingsPageLayout';
import { useLingui } from '@lingui/react/macro';
import { SettingsPath } from 'twenty-shared/types';
import { getSettingsPath } from 'twenty-shared/utils';
import {
IconEye,
IconHierarchy2,
IconLink,
IconList,
IconPlus,
} from 'twenty-ui/icon';
import { H2Title } from 'twenty-ui/typography';
import { Button } from 'twenty-ui/input';
import { Section } from 'twenty-ui/layout';
import { UndecoratedLink } from 'twenty-ui/navigation';
import DarkCoverImage from '@/settings/data-model/assets/cover-dark.png';
import LightCoverImage from '@/settings/data-model/assets/cover-light.png';
import { SettingsObjectTable } from '~/pages/settings/data-model/SettingsObjectTable';
const SETTINGS_DATA_MODEL_HERO_INSTANCE_ID_PREFIX = 'settings-data-model-hero';
export const SettingsObjects = () => {
const { t } = useLingui();
const { objectMetadataItems } = useFilteredObjectMetadataItems();
const isDDLLocked = useAtomStateValue(isDDLLockedState);
const heroTabs = [
{
id: 'objects',
title: t`Objects`,
Icon: IconHierarchy2,
vimeoId: '926288174',
},
{
id: 'fields',
title: t`Fields`,
Icon: IconList,
vimeoId: '927628219',
},
{
id: 'relations',
title: t`Relations`,
Icon: IconLink,
vimeoId: '1185511827',
},
];
return (
<SettingsPageLayout
title={t`Data model`}
actionButton={
isDDLLocked ? (
<Button
Icon={IconPlus}
title={t`Add object`}
accent="blue"
size="small"
disabled
/>
) : (
<UndecoratedLink to={getSettingsPath(SettingsPath.NewObject)}>
<Button
Icon={IconPlus}
title={t`Add object`}
accent="blue"
size="small"
/>
</UndecoratedLink>
)
}
links={[
{
children: t`Workspace`,
href: getSettingsPath(SettingsPath.General),
},
{ children: t`Objects` },
]}
>
<SettingsPageContainer>
<Section>
<SettingsDiscoveryHeroCard
lightSrc={LightCoverImage}
darkSrc={DarkCoverImage}
instanceIdPrefix={SETTINGS_DATA_MODEL_HERO_INSTANCE_ID_PREFIX}
tabs={heroTabs}
playButtonAriaLabel={t`Watch data model demo`}
/>
</Section>
<Section>
<H2Title
title={t`Existing objects`}
description={t`Manage objects, fields and relationships`}
/>
<SettingsObjectTable objectMetadataItems={objectMetadataItems} />
</Section>
<Section>
<H2Title
title={t`Visualize data model`}
description={t`See your data structure as an interactive diagram`}
/>
<UndecoratedLink to={getSettingsPath(SettingsPath.ObjectOverview)}>
<Button
title={t`Visualize`}
variant="secondary"
size="medium"
Icon={IconEye}
/>
</UndecoratedLink>
</Section>
</SettingsPageContainer>
</SettingsPageLayout>
);
};