Skip to content

The open alternative to Salesforce, designed for AI.

Simplify page layout manifest authoring (#25513)

Thomas des Francsd168df965e10
diff --git a/.github/workflows/ci-server.yaml b/.github/workflows/ci-server.yaml
index 2bbcbe2e8fe..f9e223734c4 100644
--- a/.github/workflows/ci-server.yaml
+++ b/.github/workflows/ci-server.yaml
@@ -175,7 +175,7 @@ jobs:
run: npx nx start:ci twenty-server &
- name: Waiting for server starting...
run: |
- for i in {1..10}; do
+ for i in {1..60}; do
if curl -f http://localhost:3000/healthz; then
echo "Server ready!"
exit 0
diff --git a/packages/twenty-apps/fixtures/rich-app/src/page-layout-tabs/extra-tab.page-layout-tab.ts b/packages/twenty-apps/fixtures/rich-app/src/page-layout-tabs/extra-tab.page-layout-tab.ts
index 89c052cfd84..252252dd048 100644
--- a/packages/twenty-apps/fixtures/rich-app/src/page-layout-tabs/extra-tab.page-layout-tab.ts
+++ b/packages/twenty-apps/fixtures/rich-app/src/page-layout-tabs/extra-tab.page-layout-tab.ts
@@ -12,18 +12,8 @@ export default definePageLayoutTab({
title: 'Extra Tab',
position: 1000,
icon: 'IconLayout',
- layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
widgets: [
- {
- universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000011',
- title: 'Extra Widget',
- type: 'FRONT_COMPONENT',
- configuration: {
- configurationType: 'FRONT_COMPONENT',
- frontComponentUniversalIdentifier:
- '370ae182-743f-4ecb-b625-7ac48e21f0e5',
- },
- },
{
universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000012',
title: 'Total Priority',
@@ -36,5 +26,16 @@ export default definePageLayoutTab({
aggregateOperation: AggregateOperations.SUM,
},
},
+ {
+ universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000011',
+ title: 'Extra Widget',
+ type: 'FRONT_COMPONENT',
+ heightBehavior: 'TAB_VIEWPORT',
+ configuration: {
+ configurationType: 'FRONT_COMPONENT',
+ frontComponentUniversalIdentifier:
+ '370ae182-743f-4ecb-b625-7ac48e21f0e5',
+ },
+ },
],
});
diff --git a/packages/twenty-codex-plugin/references/develop-app/standalone-pages.md b/packages/twenty-codex-plugin/references/develop-app/standalone-pages.md
index bb8f69d806e..dc6c3b92b47 100644
--- a/packages/twenty-codex-plugin/references/develop-app/standalone-pages.md
+++ b/packages/twenty-codex-plugin/references/develop-app/standalone-pages.md
@@ -90,7 +90,10 @@ export default defineFrontComponent({
```
```ts src/page-layouts/mission-control.page-layout.ts
-import { definePageLayout, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
+import {
+ definePageLayout,
+ PageLayoutTabLayoutMode,
+} from 'twenty-sdk/define';
import {
MISSION_CONTROL_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER,
@@ -107,13 +110,13 @@ export default definePageLayout({
title: 'Mission Control',
position: 0,
icon: 'IconRocket',
- layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
widgets: [
{
universalIdentifier: '18ce05bb-ee3c-4332-80a7-f8fb84f7f70a',
title: 'Mission Control',
type: 'FRONT_COMPONENT',
- position: { layoutMode: PageLayoutTabLayoutMode.CANVAS },
+ heightBehavior: 'TAB_VIEWPORT',
configuration: {
configurationType: 'FRONT_COMPONENT',
frontComponentUniversalIdentifier:
@@ -148,7 +151,7 @@ export default defineNavigationMenuItem({
});
```
-Use `PageLayoutTabLayoutMode.CANVAS` for the full-page renderer. Keep the 12 x 12 fill pattern as a grid fallback and editing hint; CANVAS renders the first widget as the page-sized surface.
+Use a `VERTICAL_LIST` tab and give its single widget `TAB_VIEWPORT` height behavior for a page-sized surface. The widget owns internal scrolling while the tab owns its viewport.
After the tiny page renders, replace the component body with a full-screen structure:
@@ -198,7 +201,7 @@ This section only calls out the fields that matter for standalone pages. Use `la
- Use `type: 'STANDALONE_PAGE'`.
- Do not set `objectUniversalIdentifier`; standalone pages are not record scoped.
- Define at least one tab. Use one tab unless the page needs real top-level modes.
-- Use `PageLayoutTabLayoutMode.CANVAS`; put the `FRONT_COMPONENT` first and set its `position.layoutMode` to `PageLayoutTabLayoutMode.CANVAS`.
+- Use `PageLayoutTabLayoutMode.VERTICAL_LIST`; widgets inherit the tab's layout mode and follow their order in the `widgets` array. Put the `FRONT_COMPONENT` last and set its top-level `heightBehavior` to `'TAB_VIEWPORT'`.
- Use a `FRONT_COMPONENT` widget with `configurationType: 'FRONT_COMPONENT'` and `frontComponentUniversalIdentifier`.
`defineFrontComponent` owns the actual page experience:
@@ -368,7 +371,7 @@ For a black screen, check the simplest causes first:
- Token or fetch failure: log the caught error, confirm `CoreApiClient` generation, and show an error state.
- Public asset failure: verify `getPublicAssetUrl(...)` output in the network tab and render without the asset.
- CSS layer covering content: remove absolute overlays, `zIndex`, and full-screen backgrounds until text is visible.
-- Zero-height container: add visible borders and confirm `height: '100%'`, `minHeight: '100%'`, `minHeight: 0`, and the widget canvas position.
+- Zero-height container: add visible borders and confirm `height: '100%'`, `minHeight: '100%'`, `minHeight: 0`, and the widget's `TAB_VIEWPORT` position.
- Unsupported browser or Remote DOM behavior: remove unusual DOM APIs, portals, global document access, and third-party components until the minimal UI renders.
- Stale deployed app version: confirm the installed app version is the one you just synced or deployed.
@@ -436,7 +439,7 @@ Minimal standalone page:
- One front component.
- One `STANDALONE_PAGE` page layout.
- One `PAGE_LAYOUT` navigation item.
-- One 12 x 12 `FRONT_COMPONENT` widget.
+- One `FRONT_COMPONENT` widget with `TAB_VIEWPORT` height behavior.
Full-screen operational page:
diff --git a/packages/twenty-codex-plugin/scripts/validators/cross-doc-contracts.js b/packages/twenty-codex-plugin/scripts/validators/cross-doc-contracts.js
index b986a7ace7f..11640a56ab8 100644
--- a/packages/twenty-codex-plugin/scripts/validators/cross-doc-contracts.js
+++ b/packages/twenty-codex-plugin/scripts/validators/cross-doc-contracts.js
@@ -105,9 +105,9 @@ const assertFrontComponentGuidance = (fail) => {
'There does not appear to be a separate public "page body component" API',
"type: 'STANDALONE_PAGE'",
'NavigationMenuItemType.PAGE_LAYOUT',
- 'PageLayoutTabLayoutMode.CANVAS',
- 'position: { layoutMode: PageLayoutTabLayoutMode.CANVAS }',
- '12 x 12 fill pattern',
+ 'PageLayoutTabLayoutMode.VERTICAL_LIST',
+ "heightBehavior: 'TAB_VIEWPORT'",
+ 'owns internal scrolling',
'Full-Page Layout Guidance',
'black screen',
'yarn twenty apply',
diff --git a/packages/twenty-docs/developers/extend/apps/layout/page-layouts.mdx b/packages/twenty-docs/developers/extend/apps/layout/page-layouts.mdx
index ce1b7afa4fe..0eae99b18c9 100644
--- a/packages/twenty-docs/developers/extend/apps/layout/page-layouts.mdx
+++ b/packages/twenty-docs/developers/extend/apps/layout/page-layouts.mdx
@@ -38,6 +38,7 @@ export default definePageLayout({
universalIdentifier: 'aa4234e0-2e5f-4c02-a96a-573449e2351d',
title: 'Hello World',
type: 'FRONT_COMPONENT',
+ heightBehavior: 'TAB_VIEWPORT',
configuration: {
configurationType: 'FRONT_COMPONENT',
frontComponentUniversalIdentifier:
@@ -54,8 +55,10 @@ export default definePageLayout({
- `type` is one of `'RECORD_INDEX'`, `'RECORD_PAGE'`, `'DASHBOARD'`, `'STANDALONE_PAGE'` or `'RECORD_FORM'`. Use `'RECORD_PAGE'` to customize the detail view of a specific object. `'RECORD_FORM'` describes the creation form of an object and holds `FORM_FIELD` widgets, each rendering a single field. Twenty provisions one `'RECORD_FORM'` layout per object with one widget per creatable field, so you rarely need to author one; it does not render record forms yet.
- `objectUniversalIdentifier` specifies which object this layout applies to.
-- Each `tab` defines a section of the page with a `title`, `position`, and `layoutMode`: `VERTICAL_LIST` for record pages and standalone pages, `GRID` for dashboards, and `CANVAS` for a single widget that should fill the tab viewport. A `VERTICAL_LIST` tab stacks widgets vertically. Built-in widgets that manage their own scrolling, such as timelines, files, notes, tasks, and workflows, fill one viewport; fields, front components, graphs, and other fit-content widgets render at their content or configured height. A `GRID` tab always lays its widgets out as cards on a 12-column grid. A `CANVAS` widget has no coordinates and can omit `position`; Twenty normalizes it to `{ layoutMode: PageLayoutTabLayoutMode.CANVAS }` from the tab layout mode. If a canvas tab contains multiple widgets, they render at their content height instead of filling the viewport.
-- A widget `position` matches its tab layout mode. `VERTICAL_LIST` uses `{ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index, heightBehavior? }`, `GRID` uses `{ layoutMode: PageLayoutTabLayoutMode.GRID, row, column, rowSpan, columnSpan }`, and `CANVAS` uses `{ layoutMode: PageLayoutTabLayoutMode.CANVAS }` or omits `position`. Optional `heightBehavior` values override the widget-type default: `'TAB_VIEWPORT'` fills a full tab viewport (including for front components), and `'FIT_CONTENT'` uses content or configured height. The enum `PageLayoutWidgetVerticalListHeightBehavior` is also exported from `twenty-sdk/define`. A vertical-list tab allows at most one active viewport-height widget, ordered after fit-content widgets.
+- Each `tab` defines a section of the page with a `title`, `position`, and `layoutMode`: use `VERTICAL_LIST` for record pages and standalone pages, and `GRID` for dashboards. A `VERTICAL_LIST` tab stacks widgets vertically. Built-in widgets that manage their own scrolling, such as timelines, files, notes, tasks, and workflows, fill one viewport by default; fields, front components, graphs, and other fit-content widgets render at their content or configured height. A `GRID` tab always lays its widgets out as cards on a 12-column grid.
+- Widgets in a `VERTICAL_LIST` tab inherit the tab's layout mode, and their order comes from the `widgets` array. Do not set `position`; set the optional top-level `heightBehavior` to `'TAB_VIEWPORT'` when a widget should occupy one full tab viewport and own its scrolling, or to `'FIT_CONTENT'` to override a built-in full-height default. Preceding widgets do not reduce that height. Only one active `TAB_VIEWPORT` widget is allowed per tab, and it must come after fit-content widgets.
+- `GRID` widgets continue to use `position: { layoutMode: PageLayoutTabLayoutMode.GRID, row, column, rowSpan, columnSpan }`. Top-level `heightBehavior` is only valid for `VERTICAL_LIST` tabs; using it with `GRID` or `CANVAS` is a validation error.
+- Existing Canvas tabs and explicit widget positions remain supported. The SDK shows deprecation warnings with the recommended replacements.
- Set `layoutMode` explicitly. Omitting it gives you `VERTICAL_LIST` on a `STANDALONE_PAGE` and `GRID` everywhere else, which is rarely what you want on a record page.
- Each `widget` inside a tab can render a [front component](/developers/extend/apps/layout/front-components), a relation list, or other built-in widget types.
- A `FRONT_COMPONENT` widget can set `headerCommandMenuItemUniversalIdentifiers` to an ordered array of command menu item universal identifiers from the same app. These actions appear as icon buttons in the widget card header and keep their command-level availability and permission checks. Identifiers must be unique and must resolve when the app is installed.
@@ -194,6 +197,7 @@ Use this when you only want to **add** a widget to a tab that already exists —
import {
definePageLayoutWidget,
PageLayoutTabLayoutMode,
+ PageLayoutWidgetVerticalListHeightBehavior,
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS,
} from 'twenty-sdk/define';
import { HELLO_WORLD_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER } from '../front-components/hello-world';
@@ -205,7 +209,11 @@ export default definePageLayoutWidget({
.universalIdentifier,
title: 'Hello World',
type: 'FRONT_COMPONENT',
- position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 1000 },
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 1000,
+ heightBehavior: PageLayoutWidgetVerticalListHeightBehavior.TAB_VIEWPORT,
+ },
configuration: {
configurationType: 'FRONT_COMPONENT',
frontComponentUniversalIdentifier:
@@ -236,6 +244,7 @@ export default definePageLayoutWidget({
```
- `position` is **required**, since the tab is not part of your manifest and its layout mode cannot be inferred. Match the tab's layout mode: record page tabs are vertical lists, so use `{ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index }` with an index above the built-in widgets (the Fields widget sits at 0).
+- For a vertical list, set `position.heightBehavior` to `PageLayoutWidgetVerticalListHeightBehavior.TAB_VIEWPORT` to fill one tab viewport, or `PageLayoutWidgetVerticalListHeightBehavior.FIT_CONTENT` to use the widget's content or configured height. Import this enum from `twenty-sdk/define`, as in the example above. If omitted, the widget keeps its built-in default. Only one active widget per tab can fill the viewport, and its index must place it after all fit-content widgets. `heightBehavior` is not supported in `GRID` or `CANVAS` positions.
- `configuration` works exactly like a widget defined inline in `definePageLayout` or `definePageLayoutTab`: it references [front components](/developers/extend/apps/layout/front-components), views, fields and so on.
- Use this instead of `definePageLayoutTab` when the tab already exists and you only want to place one widget on it. Use `definePageLayoutTab` when you want a tab of your own.
- `yarn twenty pull` writes a widget you added to a tab you do not own back as a `definePageLayoutWidget()` file, under the same limits as widgets of a `definePageLayout()`.
diff --git a/packages/twenty-docs/developers/extend/apps/tutorials/document-generator/building-the-ui.mdx b/packages/twenty-docs/developers/extend/apps/tutorials/document-generator/building-the-ui.mdx
index 41ef80fae8f..abc547cdc7c 100644
--- a/packages/twenty-docs/developers/extend/apps/tutorials/document-generator/building-the-ui.mdx
+++ b/packages/twenty-docs/developers/extend/apps/tutorials/document-generator/building-the-ui.mdx
@@ -225,7 +225,10 @@ Mount it with a [page layout](/developers/extend/apps/layout/page-layouts). A
`FRONT_COMPONENT` widget hosts the component full-bleed:
```ts filename="src/page-layouts/document-record.page-layout.ts"
-import { definePageLayout, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
+import {
+ definePageLayout,
+ PageLayoutTabLayoutMode,
+} from 'twenty-sdk/define';
export default definePageLayout({
universalIdentifier: DOCUMENT_PAGE_LAYOUT_UNIVERSAL_IDENTIFIER,
@@ -242,6 +245,7 @@ export default definePageLayout({
universalIdentifier: DOCUMENT_PAGE_LAYOUT_WIDGET_UNIVERSAL_IDENTIFIER,
title: 'Document preview',
type: 'FRONT_COMPONENT',
+ heightBehavior: 'TAB_VIEWPORT',
configuration: {
configurationType: 'FRONT_COMPONENT',
frontComponentUniversalIdentifier: DOCUMENT_VIEWER_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER,
diff --git a/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.ts b/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.ts
index 52c38f20171..79c32e16369 100644
--- a/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.ts
+++ b/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.ts
@@ -48,18 +48,8 @@ export const EXPECTED_MANIFEST: Manifest = {
title: 'Extra Tab',
position: 1000,
icon: 'IconLayout',
- layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
widgets: [
- {
- universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000011',
- title: 'Extra Widget',
- type: 'FRONT_COMPONENT',
- configuration: {
- configurationType: 'FRONT_COMPONENT',
- frontComponentUniversalIdentifier:
- '370ae182-743f-4ecb-b625-7ac48e21f0e5',
- },
- },
{
universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000012',
title: 'Total Priority',
@@ -72,6 +62,17 @@ export const EXPECTED_MANIFEST: Manifest = {
aggregateOperation: AggregateOperations.SUM,
},
},
+ {
+ universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000011',
+ title: 'Extra Widget',
+ type: 'FRONT_COMPONENT',
+ heightBehavior: 'TAB_VIEWPORT',
+ configuration: {
+ configurationType: 'FRONT_COMPONENT',
+ frontComponentUniversalIdentifier:
+ '370ae182-743f-4ecb-b625-7ac48e21f0e5',
+ },
+ },
],
},
],
diff --git a/packages/twenty-sdk/src/cli/utilities/build/manifest/__tests__/manifest-validate.spec.ts b/packages/twenty-sdk/src/cli/utilities/build/manifest/__tests__/manifest-validate.spec.ts
index ea69fdbd8e0..fbf9383c232 100644
--- a/packages/twenty-sdk/src/cli/utilities/build/manifest/__tests__/manifest-validate.spec.ts
+++ b/packages/twenty-sdk/src/cli/utilities/build/manifest/__tests__/manifest-validate.spec.ts
@@ -8,6 +8,7 @@ import {
import {
AggregateOperations,
FieldMetadataType,
+ PageLayoutTabLayoutMode,
RelationType,
} from 'twenty-shared/types';
import { manifestValidate } from '@/cli/utilities/build/manifest/manifest-validate';
@@ -658,6 +659,188 @@ describe('manifestValidate', () => {
});
});
+ describe('page layout deprecation warnings', () => {
+ it.each(['nested', 'standalone'])(
+ 'warns without changing a legacy %s manifest',
+ (location) => {
+ const legacyTab: PageLayoutTabManifest = {
+ universalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000012',
+ title: 'Legacy canvas',
+ position: 0,
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ widgets: [],
+ };
+ const manifest: Manifest = {
+ ...validManifest,
+ pageLayouts:
+ location === 'nested'
+ ? [
+ {
+ universalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000010',
+ name: 'Record page',
+ type: 'RECORD_PAGE',
+ tabs: [legacyTab],
+ },
+ ]
+ : [],
+ pageLayoutTabs: location === 'standalone' ? [legacyTab] : [],
+ };
+ const original = JSON.stringify(manifest);
+ const result = manifestValidate(manifest);
+
+ expect(result.isValid).toBe(true);
+ expect(result.warnings).toEqual([
+ expect.stringContaining('uses deprecated CANVAS'),
+ ]);
+ expect(result.warnings[0]).toContain(
+ "heightBehavior to 'TAB_VIEWPORT'",
+ );
+ expect(JSON.stringify(manifest)).toBe(original);
+ },
+ );
+
+ it.each(['position', 'gridPosition'])(
+ 'warns about legacy %s with a replacement',
+ (positionKey) => {
+ const result = manifestValidate({
+ ...validManifest,
+ pageLayoutTabs: [
+ {
+ universalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000012',
+ title: 'Details',
+ position: 0,
+ layoutMode:
+ positionKey === 'position'
+ ? PageLayoutTabLayoutMode.VERTICAL_LIST
+ : PageLayoutTabLayoutMode.GRID,
+ widgets: [
+ {
+ universalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000013',
+ title: 'Timeline',
+ type: 'TIMELINE',
+ configuration: { configurationType: 'TIMELINE' },
+ [positionKey]:
+ positionKey === 'position'
+ ? {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 99,
+ }
+ : { row: 2, column: 3, rowSpan: 4, columnSpan: 5 },
+ },
+ ],
+ },
+ ],
+ });
+
+ expect(result.isValid).toBe(true);
+ expect(result.warnings).toHaveLength(1);
+ expect(result.warnings[0]).toContain(
+ positionKey === 'position'
+ ? 'Order the widgets array by position.index'
+ : "Use position with layoutMode: 'GRID'",
+ );
+ },
+ );
+ });
+
+ describe('page layout widget height behavior validation', () => {
+ const makePageLayout = (
+ layoutMode: PageLayoutTabLayoutMode,
+ ): Manifest['pageLayouts'][number] => ({
+ universalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000010',
+ name: 'Record page',
+ type: 'RECORD_PAGE',
+ objectUniversalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000011',
+ tabs: [
+ {
+ universalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000012',
+ title: 'Details',
+ position: 0,
+ layoutMode,
+ widgets: [
+ {
+ universalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000013',
+ title: 'App',
+ type: 'FRONT_COMPONENT',
+ heightBehavior: 'TAB_VIEWPORT',
+ configuration: {
+ configurationType: 'FRONT_COMPONENT',
+ frontComponentUniversalIdentifier:
+ 'a0a1a2a3-a4a5-4000-8000-000000000014',
+ },
+ },
+ ],
+ },
+ ],
+ });
+
+ it('should accept heightBehavior on a VERTICAL_LIST tab', () => {
+ const result = manifestValidate({
+ ...validManifest,
+ pageLayouts: [makePageLayout(PageLayoutTabLayoutMode.VERTICAL_LIST)],
+ });
+
+ expect(result.errors).toHaveLength(0);
+ });
+
+ it.each(['nested', 'standalone'])(
+ 'rejects invalid heightBehavior in a %s tab',
+ (location) => {
+ const pageLayout = makePageLayout(
+ PageLayoutTabLayoutMode.VERTICAL_LIST,
+ );
+ const pageLayoutTab = {
+ ...pageLayout.tabs![0],
+ widgets: pageLayout.tabs![0].widgets!.map((widget) => ({
+ ...widget,
+ heightBehavior: 'TAB_VIEPORT',
+ })),
+ };
+ const manifest: Manifest = JSON.parse(
+ JSON.stringify({
+ ...validManifest,
+ pageLayouts: [
+ {
+ ...pageLayout,
+ tabs: location === 'nested' ? [pageLayoutTab] : [],
+ },
+ ],
+ pageLayoutTabs:
+ location === 'standalone'
+ ? [
+ {
+ ...pageLayoutTab,
+ pageLayoutUniversalIdentifier:
+ pageLayout.universalIdentifier,
+ },
+ ]
+ : [],
+ }),
+ );
+
+ const result = manifestValidate(manifest);
+ expect(result.isValid).toBe(false);
+ expect(result.errors).toContain(
+ 'Page layout widget "App" defines unsupported heightBehavior "TAB_VIEPORT". Expected FIT_CONTENT or TAB_VIEWPORT.',
+ );
+ },
+ );
+
+ it.each([PageLayoutTabLayoutMode.GRID, PageLayoutTabLayoutMode.CANVAS])(
+ 'should reject heightBehavior on a %s tab',
+ (layoutMode) => {
+ const result = manifestValidate({
+ ...validManifest,
+ pageLayouts: [makePageLayout(layoutMode)],
+ });
+
+ expect(result.errors).toContain(
+ `Page layout widget "App" defines heightBehavior, but its parent tab "Details" uses ${layoutMode}. heightBehavior is only supported for VERTICAL_LIST tabs.`,
+ );
+ },
+ );
+ });
+
describe('timeline activity type validation', () => {
const sourceObjectUniversalIdentifier =
'1a111111-1111-4111-8111-111111111111';
diff --git a/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-validate.ts b/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-validate.ts
index 33385aff5d0..31aabe2834e 100644
--- a/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-validate.ts
+++ b/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-validate.ts
@@ -3,7 +3,10 @@ import { validate as uuidValidate, version as uuidVersion } from 'uuid';
import {
type Manifest,
+ type PageLayoutManifest,
+ type PageLayoutTabManifest,
type PageLayoutWidgetManifest,
+ normalizePageLayoutTabManifest,
} from 'twenty-shared/application';
import {
GRAPH_WIDGET_CONFIGURATION_TYPES,
@@ -18,6 +21,7 @@ import {
MINIMUM_UNIVERSAL_IDENTIFIER_UUID_VERSION,
isRelationFieldManifest,
} from '@/cli/utilities/build/manifest/utils/manifest-validation-helpers';
+import { getPageLayoutDeprecationWarnings } from '@/cli/utilities/build/manifest/utils/get-page-layout-deprecation-warnings';
import { validateTimelineActivityTypes } from '@/cli/utilities/build/manifest/utils/validate-timeline-activity-types';
const VALID_RELATION_TYPES: string[] = [
@@ -160,6 +164,54 @@ const validateGraphWidgets = (
return errors;
};
+const validatePageLayoutTab = ({
+ pageLayoutTab,
+ pageLayoutType,
+}: {
+ pageLayoutTab: PageLayoutTabManifest;
+ pageLayoutType: PageLayoutManifest['type'] | undefined;
+}): string[] => {
+ const result = normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: pageLayoutTab,
+ pageLayoutType,
+ });
+
+ return result.status === 'fail' ? result.errors : [];
+};
+
+const validatePageLayoutTabs = (
+ manifest: Pick<Manifest, 'pageLayouts' | 'pageLayoutTabs'>,
+): string[] => {
+ const pageLayoutTypeByUniversalIdentifier = new Map(
+ manifest.pageLayouts.map((pageLayout) => [
+ pageLayout.universalIdentifier,
+ pageLayout.type,
+ ]),
+ );
+
+ const nestedTabErrors = manifest.pageLayouts.flatMap((pageLayout) =>
+ (pageLayout.tabs ?? []).flatMap((pageLayoutTab) =>
+ validatePageLayoutTab({
+ pageLayoutTab,
+ pageLayoutType: pageLayout.type,
+ }),
+ ),
+ );
+
+ const standaloneTabErrors = manifest.pageLayoutTabs.flatMap((pageLayoutTab) =>
+ validatePageLayoutTab({
+ pageLayoutTab,
+ pageLayoutType: isDefined(pageLayoutTab.pageLayoutUniversalIdentifier)
+ ? pageLayoutTypeByUniversalIdentifier.get(
+ pageLayoutTab.pageLayoutUniversalIdentifier,
+ )
+ : undefined,
+ }),
+ );
+
+ return [...nestedTabErrors, ...standaloneTabErrors];
+};
+
const invalidUniversalIdentifierVersions = (
identifiers: string[],
): string[] => {
@@ -192,7 +244,7 @@ const invalidUniversalIdentifierVersions = (
export const manifestValidate = (manifest: Manifest) => {
const errors: string[] = [];
- const warnings: string[] = [];
+ const warnings = getPageLayoutDeprecationWarnings(manifest);
const universalIdentifiers = findUniversalIdentifiers(manifest);
@@ -218,6 +270,8 @@ export const manifestValidate = (manifest: Manifest) => {
errors.push(...validateRelationFields(allFields));
+ errors.push(...validatePageLayoutTabs(manifest));
+
errors.push(...validateGraphWidgets(collectPageLayoutWidgets(manifest)));
errors.push(...validateTimelineActivityTypes(manifest));
diff --git a/packages/twenty-sdk/src/cli/utilities/build/manifest/utils/get-page-layout-deprecation-warnings.ts b/packages/twenty-sdk/src/cli/utilities/build/manifest/utils/get-page-layout-deprecation-warnings.ts
new file mode 100644
index 00000000000..74aa44d8f90
--- /dev/null
+++ b/packages/twenty-sdk/src/cli/utilities/build/manifest/utils/get-page-layout-deprecation-warnings.ts
@@ -0,0 +1,39 @@
+import { type Manifest } from 'twenty-shared/application';
+import { PageLayoutTabLayoutMode } from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
+
+export const getPageLayoutDeprecationWarnings = (
+ manifest: Pick<Manifest, 'pageLayouts' | 'pageLayoutTabs'>,
+): string[] => {
+ const warnings: string[] = [];
+ const tabs = [
+ ...manifest.pageLayouts.flatMap(({ tabs }) => tabs ?? []),
+ ...manifest.pageLayoutTabs,
+ ];
+
+ for (const tab of tabs) {
+ if (tab.layoutMode === PageLayoutTabLayoutMode.CANVAS) {
+ warnings.push(
+ `Page layout tab "${tab.title}" uses deprecated CANVAS. For a full-height widget, use VERTICAL_LIST and set the widget's heightBehavior to 'TAB_VIEWPORT'. Existing Canvas layouts remain supported and are not converted.`,
+ );
+ }
+
+ for (const widget of tab.widgets ?? []) {
+ if (
+ widget.position?.layoutMode === PageLayoutTabLayoutMode.VERTICAL_LIST
+ ) {
+ warnings.push(
+ `Page layout widget "${widget.title}" uses a deprecated vertical-list position. Order the widgets array by position.index, remove position, and move any position.heightBehavior to heightBehavior. Existing positions remain supported and keep their indices.`,
+ );
+ }
+
+ if ('gridPosition' in widget && isDefined(widget.gridPosition)) {
+ warnings.push(
+ `Page layout widget "${widget.title}" uses deprecated gridPosition. Use position with layoutMode: 'GRID' and the same row, column, rowSpan and columnSpan. Existing gridPosition remains supported.`,
+ );
+ }
+ }
+ }
+
+ return warnings;
+};
diff --git a/packages/twenty-sdk/src/cli/utilities/entity/__tests__/get-page-layout-base-file.spec.ts b/packages/twenty-sdk/src/cli/utilities/entity/__tests__/get-page-layout-base-file.spec.ts
index 337cd607826..466a08769f4 100644
--- a/packages/twenty-sdk/src/cli/utilities/entity/__tests__/get-page-layout-base-file.spec.ts
+++ b/packages/twenty-sdk/src/cli/utilities/entity/__tests__/get-page-layout-base-file.spec.ts
@@ -20,7 +20,7 @@ describe('getPageLayoutBaseFile', () => {
expect(result).toContain('tabs: [');
});
- it('should render a standalone page tab in VERTICAL_LIST so a lone widget owns the page', () => {
+ it('should render a standalone page tab in VERTICAL_LIST', () => {
const result = getPageLayoutBaseFile({
name: 'my-layout',
type: PageLayoutType.STANDALONE_PAGE,
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-page-layout-tab-to-page-layout-tab-manifest.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-page-layout-tab-to-page-layout-tab-manifest.util.spec.ts
index d3bfef2251a..150189342df 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-page-layout-tab-to-page-layout-tab-manifest.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-page-layout-tab-to-page-layout-tab-manifest.util.spec.ts
@@ -8,6 +8,7 @@ import { fromFlatPageLayoutTabToPageLayoutTabManifest } from 'src/engine/core-mo
import { fromFlatPageLayoutTabToStandalonePageLayoutTabManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-tab-to-standalone-page-layout-tab-manifest.util';
import { fromPageLayoutTabManifestToUniversalFlatPageLayoutTab } from 'src/engine/core-modules/application/application-manifest/converters/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util';
import { compareTwoFlatEntity } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/utils/compare-two-universal-flat-entity.util';
+import { normalizePageLayoutTabManifestOrThrow } from 'src/engine/core-modules/application/application-manifest/utils/__tests__/normalize-page-layout-tab-manifest-or-throw.test-util';
const APP_UID = '11111111-1111-4111-8111-111111111111';
const PAGE_LAYOUT_UID = '33333333-3333-4333-8333-333333333333';
@@ -44,9 +45,11 @@ const forward = (
pageLayoutType?: PageLayoutType,
) =>
fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
- pageLayoutTabManifest,
+ pageLayoutTabManifest: normalizePageLayoutTabManifestOrThrow({
+ pageLayoutTabManifest,
+ pageLayoutType,
+ }),
pageLayoutUniversalIdentifier: PAGE_LAYOUT_UID,
- pageLayoutType,
applicationUniversalIdentifier: APP_UID,
now: NOW,
});
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-page-layout-widget-to-page-layout-widget-manifest.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-page-layout-widget-to-page-layout-widget-manifest.util.spec.ts
index 563a098c75d..084fb9aa80d 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-page-layout-widget-to-page-layout-widget-manifest.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-page-layout-widget-to-page-layout-widget-manifest.util.spec.ts
@@ -4,6 +4,7 @@ import { PageLayoutTabLayoutMode } from 'twenty-shared/types';
import { fromFlatPageLayoutWidgetToPageLayoutWidgetManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-page-layout-widget-manifest.util';
import { fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget } from 'src/engine/core-modules/application/application-manifest/converters/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util';
import { compareTwoFlatEntity } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/utils/compare-two-universal-flat-entity.util';
+import { normalizePageLayoutTabManifestOrThrow } from 'src/engine/core-modules/application/application-manifest/utils/__tests__/normalize-page-layout-tab-manifest-or-throw.test-util';
const APP_UID = '11111111-1111-4111-8111-111111111111';
const OBJECT_UID = '22222222-2222-4222-8222-222222222222';
@@ -12,7 +13,9 @@ const TAB_UID = '44444444-4444-4444-8444-444444444444';
const WIDGET_UID = '55555555-5555-4555-8555-555555555555';
const NOW = '2026-09-08T10:00:00.000Z';
-const WIDGET_MANIFEST: Required<PageLayoutWidgetManifest> = {
+const WIDGET_MANIFEST: Required<
+ Omit<PageLayoutWidgetManifest, 'heightBehavior'>
+> = {
universalIdentifier: WIDGET_UID,
title: 'Fields',
type: 'FIELDS',
@@ -38,10 +41,17 @@ const forward = (
pageLayoutTabLayoutMode = PageLayoutTabLayoutMode.VERTICAL_LIST,
) =>
fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
- pageLayoutWidgetManifest,
+ pageLayoutWidgetManifest: normalizePageLayoutTabManifestOrThrow({
+ pageLayoutTabManifest: {
+ universalIdentifier: TAB_UID,
+ title: 'Overview',
+ position: 0,
+ layoutMode: pageLayoutTabLayoutMode,
+ widgets: [pageLayoutWidgetManifest],
+ },
+ pageLayoutType: undefined,
+ }).widgets[0],
pageLayoutTabUniversalIdentifier: TAB_UID,
- pageLayoutTabLayoutMode,
- widgetIndex: 3,
applicationUniversalIdentifier: APP_UID,
now: NOW,
});
@@ -62,7 +72,7 @@ describe('fromFlatPageLayoutWidgetToPageLayoutWidgetManifest', () => {
}),
).toEqual({
...MINIMAL_WIDGET_MANIFEST,
- position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 3 },
+ position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 0 },
});
expect(
fromFlatPageLayoutWidgetToPageLayoutWidgetManifest({
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util.spec.ts
index f67e21eaacc..b1638b7ea83 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util.spec.ts
@@ -1,4 +1,4 @@
-import { PageLayoutTabLayoutMode, PageLayoutType } from 'twenty-shared/types';
+import { PageLayoutTabLayoutMode } from 'twenty-shared/types';
import { fromPageLayoutTabManifestToUniversalFlatPageLayoutTab } from 'src/engine/core-modules/application/application-manifest/converters/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util';
@@ -13,9 +13,10 @@ describe('fromPageLayoutTabManifestToUniversalFlatPageLayoutTab', () => {
universalIdentifier: 'tab-uuid-1',
title: 'Overview',
position: 0,
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ widgets: [],
},
pageLayoutUniversalIdentifier,
- pageLayoutType: undefined,
applicationUniversalIdentifier,
now,
});
@@ -41,10 +42,10 @@ describe('fromPageLayoutTabManifestToUniversalFlatPageLayoutTab', () => {
title: 'Details',
position: 1,
icon: 'IconLayout',
+ widgets: [],
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
},
pageLayoutUniversalIdentifier,
- pageLayoutType: undefined,
applicationUniversalIdentifier,
now,
});
@@ -54,53 +55,4 @@ describe('fromPageLayoutTabManifestToUniversalFlatPageLayoutTab', () => {
expect(result.icon).toBe('IconLayout');
expect(result.layoutMode).toBe(PageLayoutTabLayoutMode.VERTICAL_LIST);
});
-
- it('should default a standalone page tab to VERTICAL_LIST', () => {
- const result = fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
- pageLayoutTabManifest: {
- universalIdentifier: 'tab-uuid-3',
- title: 'Overview',
- position: 0,
- },
- pageLayoutUniversalIdentifier,
- pageLayoutType: PageLayoutType.STANDALONE_PAGE,
- applicationUniversalIdentifier,
- now,
- });
-
- expect(result.layoutMode).toBe(PageLayoutTabLayoutMode.VERTICAL_LIST);
- });
-
- it('should default a dashboard tab to GRID', () => {
- const result = fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
- pageLayoutTabManifest: {
- universalIdentifier: 'tab-uuid-4',
- title: 'Overview',
- position: 0,
- },
- pageLayoutUniversalIdentifier,
- pageLayoutType: PageLayoutType.DASHBOARD,
- applicationUniversalIdentifier,
- now,
- });
-
- expect(result.layoutMode).toBe(PageLayoutTabLayoutMode.GRID);
- });
-
- it('should keep an explicit layoutMode on a standalone page tab', () => {
- const result = fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
- pageLayoutTabManifest: {
- universalIdentifier: 'tab-uuid-5',
- title: 'Overview',
- position: 0,
- layoutMode: PageLayoutTabLayoutMode.GRID,
- },
- pageLayoutUniversalIdentifier,
- pageLayoutType: PageLayoutType.STANDALONE_PAGE,
- applicationUniversalIdentifier,
- now,
- });
-
- expect(result.layoutMode).toBe(PageLayoutTabLayoutMode.GRID);
- });
});
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util.spec.ts
index 8c1a3c6969b..c41f9b04ca5 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util.spec.ts
@@ -1,10 +1,5 @@
-import { type PageLayoutWidgetManifest } from 'twenty-shared/application';
import { DEFAULT_WIDGET_SIZE } from 'twenty-shared/constants';
-import {
- type GridPosition,
- PageLayoutTabLayoutMode,
- WidgetType,
-} from 'twenty-shared/types';
+import { PageLayoutTabLayoutMode, WidgetType } from 'twenty-shared/types';
import { fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget } from 'src/engine/core-modules/application/application-manifest/converters/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util';
@@ -19,6 +14,13 @@ describe('fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget', () => {
universalIdentifier: 'widget-uuid-1',
title: 'My Widget',
type: WidgetType.VIEW,
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ row: 0,
+ column: 0,
+ rowSpan: DEFAULT_WIDGET_SIZE.default.h,
+ columnSpan: DEFAULT_WIDGET_SIZE.default.w,
+ },
configuration: { configurationType: 'VIEW' },
},
pageLayoutTabUniversalIdentifier,
@@ -55,6 +57,13 @@ describe('fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget', () => {
universalIdentifier: 'widget-uuid-2',
title: 'Iframe Widget',
type: 'IFRAME',
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ row: 0,
+ column: 0,
+ rowSpan: DEFAULT_WIDGET_SIZE.default.h,
+ columnSpan: DEFAULT_WIDGET_SIZE.default.w,
+ },
objectUniversalIdentifier: 'obj-uuid-1',
configuration: {
configurationType: 'IFRAME',
@@ -110,53 +119,4 @@ describe('fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget', () => {
columnSpan: 6,
});
});
-
- it('should use legacy manifest grid position when provided', () => {
- const result = fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
- pageLayoutWidgetManifest: {
- universalIdentifier: 'widget-uuid-legacy',
- title: 'Legacy Positioned Widget',
- type: WidgetType.GRAPH,
- gridPosition: {
- row: 2,
- column: 6,
- rowSpan: 4,
- columnSpan: 6,
- },
- configuration: { configurationType: 'VIEW' },
- } as PageLayoutWidgetManifest & { gridPosition: GridPosition },
- pageLayoutTabUniversalIdentifier,
- applicationUniversalIdentifier,
- now,
- });
-
- expect(result.position).toEqual({
- layoutMode: PageLayoutTabLayoutMode.GRID,
- row: 2,
- column: 6,
- rowSpan: 4,
- columnSpan: 6,
- });
- });
-
- it.each([
- { layoutMode: PageLayoutTabLayoutMode.CANVAS },
- { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 2 },
- ])('should default position for $layoutMode tabs', (expectedPosition) => {
- const result = fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
- pageLayoutWidgetManifest: {
- universalIdentifier: 'widget-uuid-4',
- title: 'Widget',
- type: WidgetType.VIEW,
- configuration: { configurationType: 'VIEW' },
- },
- pageLayoutTabUniversalIdentifier,
- pageLayoutTabLayoutMode: expectedPosition.layoutMode,
- widgetIndex: 2,
- applicationUniversalIdentifier,
- now,
- });
-
- expect(result.position).toEqual(expectedPosition);
- });
});
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util.ts
index a28f6fe3784..69d9cc3a23a 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-page-layout-tab-manifest-to-universal-flat-page-layout-tab.util.ts
@@ -1,21 +1,15 @@
-import {
- type PageLayoutManifest,
- type PageLayoutTabManifest,
-} from 'twenty-shared/application';
-import { PageLayoutTabLayoutMode, PageLayoutType } from 'twenty-shared/types';
+import { type NormalizedPageLayoutTabManifest } from 'twenty-shared/application';
import { type UniversalFlatPageLayoutTab } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/types/universal-flat-page-layout-tab.type';
export const fromPageLayoutTabManifestToUniversalFlatPageLayoutTab = ({
pageLayoutTabManifest,
pageLayoutUniversalIdentifier,
- pageLayoutType,
applicationUniversalIdentifier,
now,
}: {
- pageLayoutTabManifest: PageLayoutTabManifest;
+ pageLayoutTabManifest: NormalizedPageLayoutTabManifest;
pageLayoutUniversalIdentifier: string;
- pageLayoutType: PageLayoutManifest['type'] | undefined;
applicationUniversalIdentifier: string;
now: string;
}): UniversalFlatPageLayoutTab => {
@@ -26,11 +20,7 @@ export const fromPageLayoutTabManifestToUniversalFlatPageLayoutTab = ({
position: pageLayoutTabManifest.position,
pageLayoutUniversalIdentifier,
icon: pageLayoutTabManifest.icon ?? null,
- layoutMode:
- pageLayoutTabManifest.layoutMode ??
- (pageLayoutType === PageLayoutType.STANDALONE_PAGE
- ? PageLayoutTabLayoutMode.VERTICAL_LIST
- : PageLayoutTabLayoutMode.GRID),
+ layoutMode: pageLayoutTabManifest.layoutMode,
isActive: true,
isSystemSideEffect: false,
widgetUniversalIdentifiers: [],
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util.ts
index ae68316e2e7..0b22812c9bf 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util.ts
@@ -1,76 +1,16 @@
-import { type PageLayoutWidgetManifest } from 'twenty-shared/application';
-import { DEFAULT_WIDGET_SIZE } from 'twenty-shared/constants';
-import {
- type GridPosition,
- PageLayoutTabLayoutMode,
- type PageLayoutWidgetPosition,
- type WidgetType,
-} from 'twenty-shared/types';
-import { assertUnreachable, isDefined } from 'twenty-shared/utils';
+import { type NormalizedPageLayoutWidgetManifest } from 'twenty-shared/application';
+import { type WidgetType } from 'twenty-shared/types';
import { type UniversalFlatPageLayoutWidget } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/types/universal-flat-page-layout-widget.type';
-type PageLayoutWidgetManifestWithLegacyGridPosition =
- PageLayoutWidgetManifest & {
- gridPosition?: GridPosition;
- };
-
-const getPageLayoutWidgetPosition = ({
- pageLayoutWidgetManifest,
- pageLayoutTabLayoutMode,
- widgetIndex,
-}: {
- pageLayoutWidgetManifest: PageLayoutWidgetManifest;
- pageLayoutTabLayoutMode: PageLayoutTabLayoutMode;
- widgetIndex: number;
-}): PageLayoutWidgetPosition => {
- if (isDefined(pageLayoutWidgetManifest.position)) {
- return pageLayoutWidgetManifest.position;
- }
-
- const { gridPosition } =
- pageLayoutWidgetManifest as PageLayoutWidgetManifestWithLegacyGridPosition;
-
- if (isDefined(gridPosition)) {
- return {
- layoutMode: PageLayoutTabLayoutMode.GRID,
- ...gridPosition,
- };
- }
-
- switch (pageLayoutTabLayoutMode) {
- case PageLayoutTabLayoutMode.GRID:
- return {
- layoutMode: PageLayoutTabLayoutMode.GRID,
- row: 0,
- column: 0,
- rowSpan: DEFAULT_WIDGET_SIZE.default.h,
- columnSpan: DEFAULT_WIDGET_SIZE.default.w,
- };
- case PageLayoutTabLayoutMode.VERTICAL_LIST:
- return {
- layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
- index: widgetIndex,
- };
- case PageLayoutTabLayoutMode.CANVAS:
- return { layoutMode: PageLayoutTabLayoutMode.CANVAS };
- default:
- return assertUnreachable(pageLayoutTabLayoutMode);
- }
-};
-
export const fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget = ({
pageLayoutWidgetManifest,
pageLayoutTabUniversalIdentifier,
- pageLayoutTabLayoutMode = PageLayoutTabLayoutMode.GRID,
- widgetIndex = 0,
applicationUniversalIdentifier,
now,
}: {
- pageLayoutWidgetManifest: PageLayoutWidgetManifest;
+ pageLayoutWidgetManifest: NormalizedPageLayoutWidgetManifest;
pageLayoutTabUniversalIdentifier: string;
- pageLayoutTabLayoutMode?: PageLayoutTabLayoutMode;
- widgetIndex?: number;
applicationUniversalIdentifier: string;
now: string;
}): UniversalFlatPageLayoutWidget => {
@@ -85,11 +25,7 @@ export const fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget = ({
objectMetadataUniversalIdentifier:
pageLayoutWidgetManifest.objectUniversalIdentifier ?? null,
conditionalDisplay: pageLayoutWidgetManifest.conditionalDisplay ?? null,
- position: getPageLayoutWidgetPosition({
- pageLayoutWidgetManifest,
- pageLayoutTabLayoutMode,
- widgetIndex,
- }),
+ position: pageLayoutWidgetManifest.position,
universalConfiguration:
pageLayoutWidgetManifest.configuration as UniversalFlatPageLayoutWidget['universalConfiguration'],
createdAt: now,
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/services/compute-application-manifest-all-universal-flat-entity-maps.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/services/compute-application-manifest-all-universal-flat-entity-maps.service.ts
index dbdbe102cb5..86342b756b2 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/services/compute-application-manifest-all-universal-flat-entity-maps.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/services/compute-application-manifest-all-universal-flat-entity-maps.service.ts
@@ -2,6 +2,9 @@ import { Injectable } from '@nestjs/common';
import {
type Manifest,
+ type PageLayoutManifest,
+ type PageLayoutTabManifest,
+ normalizePageLayoutTabManifest,
serializeApplicationVariableValue,
} from 'twenty-shared/application';
import { MAX_CUSTOM_INDEXES_PER_OBJECT } from 'twenty-shared/constants';
@@ -37,6 +40,10 @@ import { fromViewFilterManifestToUniversalFlatViewFilter } from 'src/engine/core
import { fromViewGroupManifestToUniversalFlatViewGroup } from 'src/engine/core-modules/application/application-manifest/converters/from-view-group-manifest-to-universal-flat-view-group.util';
import { fromViewManifestToUniversalFlatView } from 'src/engine/core-modules/application/application-manifest/converters/from-view-manifest-to-universal-flat-view.util';
import { fromViewSortManifestToUniversalFlatViewSort } from 'src/engine/core-modules/application/application-manifest/converters/from-view-sort-manifest-to-universal-flat-view-sort.util';
+import {
+ ApplicationException,
+ ApplicationExceptionCode,
+} from 'src/engine/core-modules/application/application.exception';
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
import { fromAgentManifestToUniversalFlatAgent } from 'src/engine/core-modules/application/utils/from-agent-manifest-to-universal-flat-agent.util';
import { type PlaintextString } from 'src/engine/core-modules/secret-encryption/branded-strings/plaintext-string.type';
@@ -527,42 +534,14 @@ export class ComputeApplicationManifestAllUniversalFlatEntityMapsService {
});
for (const pageLayoutTabManifest of pageLayoutManifest.tabs ?? []) {
- const pageLayoutTab =
- fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
- pageLayoutTabManifest,
- pageLayoutUniversalIdentifier:
- pageLayoutManifest.universalIdentifier,
- pageLayoutType: pageLayoutManifest.type,
- applicationUniversalIdentifier,
- now,
- });
-
- addUniversalFlatEntityToUniversalFlatEntityMapsThroughMutationOrThrow({
- universalFlatEntity: pageLayoutTab,
- universalFlatEntityMapsToMutate:
- allUniversalFlatEntityMaps.flatPageLayoutTabMaps,
+ this.addPageLayoutTab({
+ pageLayoutTabManifest,
+ pageLayoutUniversalIdentifier: pageLayoutManifest.universalIdentifier,
+ pageLayoutType: pageLayoutManifest.type,
+ applicationUniversalIdentifier,
+ now,
+ allUniversalFlatEntityMaps,
});
-
- for (const [widgetIndex, pageLayoutWidgetManifest] of (
- pageLayoutTabManifest.widgets ?? []
- ).entries()) {
- addUniversalFlatEntityToUniversalFlatEntityMapsThroughMutationOrThrow(
- {
- universalFlatEntity:
- fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
- pageLayoutWidgetManifest,
- pageLayoutTabLayoutMode: pageLayoutTab.layoutMode,
- widgetIndex,
- pageLayoutTabUniversalIdentifier:
- pageLayoutTabManifest.universalIdentifier,
- applicationUniversalIdentifier,
- now,
- }),
- universalFlatEntityMapsToMutate:
- allUniversalFlatEntityMaps.flatPageLayoutWidgetMaps,
- },
- );
- }
}
}
@@ -579,40 +558,15 @@ export class ComputeApplicationManifestAllUniversalFlatEntityMapsService {
pageLayoutTabManifest.pageLayoutUniversalIdentifier,
);
- const pageLayoutTab =
- fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
- pageLayoutTabManifest,
- pageLayoutUniversalIdentifier:
- pageLayoutTabManifest.pageLayoutUniversalIdentifier,
- pageLayoutType: referencedPageLayoutManifest?.type,
- applicationUniversalIdentifier,
- now,
- });
-
- addUniversalFlatEntityToUniversalFlatEntityMapsThroughMutationOrThrow({
- universalFlatEntity: pageLayoutTab,
- universalFlatEntityMapsToMutate:
- allUniversalFlatEntityMaps.flatPageLayoutTabMaps,
+ this.addPageLayoutTab({
+ pageLayoutTabManifest,
+ pageLayoutUniversalIdentifier:
+ pageLayoutTabManifest.pageLayoutUniversalIdentifier,
+ pageLayoutType: referencedPageLayoutManifest?.type,
+ applicationUniversalIdentifier,
+ now,
+ allUniversalFlatEntityMaps,
});
-
- for (const [widgetIndex, pageLayoutWidgetManifest] of (
- pageLayoutTabManifest.widgets ?? []
- ).entries()) {
- addUniversalFlatEntityToUniversalFlatEntityMapsThroughMutationOrThrow({
- universalFlatEntity:
- fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
- pageLayoutWidgetManifest,
- pageLayoutTabLayoutMode: pageLayoutTab.layoutMode,
- widgetIndex,
- pageLayoutTabUniversalIdentifier:
- pageLayoutTabManifest.universalIdentifier,
- applicationUniversalIdentifier,
- now,
- }),
- universalFlatEntityMapsToMutate:
- allUniversalFlatEntityMaps.flatPageLayoutWidgetMaps,
- });
- }
}
for (const pageLayoutWidgetManifest of manifest.pageLayoutWidgets ?? []) {
@@ -715,4 +669,60 @@ export class ComputeApplicationManifestAllUniversalFlatEntityMapsService {
return allUniversalFlatEntityMaps;
}
+
+ private addPageLayoutTab({
+ pageLayoutTabManifest,
+ pageLayoutUniversalIdentifier,
+ pageLayoutType,
+ applicationUniversalIdentifier,
+ now,
+ allUniversalFlatEntityMaps,
+ }: {
+ pageLayoutTabManifest: PageLayoutTabManifest;
+ pageLayoutUniversalIdentifier: string;
+ pageLayoutType: PageLayoutManifest['type'] | undefined;
+ applicationUniversalIdentifier: string;
+ now: string;
+ allUniversalFlatEntityMaps: AllFlatEntityMaps;
+ }): void {
+ const result = normalizePageLayoutTabManifest({
+ pageLayoutTabManifest,
+ pageLayoutType,
+ });
+
+ if (result.status === 'fail') {
+ throw new ApplicationException(
+ result.errors.join('\n'),
+ ApplicationExceptionCode.INVALID_INPUT,
+ );
+ }
+
+ const { pageLayoutTab } = result;
+
+ addUniversalFlatEntityToUniversalFlatEntityMapsThroughMutationOrThrow({
+ universalFlatEntity:
+ fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
+ pageLayoutTabManifest: pageLayoutTab,
+ pageLayoutUniversalIdentifier,
+ applicationUniversalIdentifier,
+ now,
+ }),
+ universalFlatEntityMapsToMutate:
+ allUniversalFlatEntityMaps.flatPageLayoutTabMaps,
+ });
+
+ for (const pageLayoutWidgetManifest of pageLayoutTab.widgets) {
+ addUniversalFlatEntityToUniversalFlatEntityMapsThroughMutationOrThrow({
+ universalFlatEntity:
+ fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
+ pageLayoutWidgetManifest,
+ pageLayoutTabUniversalIdentifier: pageLayoutTab.universalIdentifier,
+ applicationUniversalIdentifier,
+ now,
+ }),
+ universalFlatEntityMapsToMutate:
+ allUniversalFlatEntityMaps.flatPageLayoutWidgetMaps,
+ });
+ }
+ }
}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/export-covers-compared-properties.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/export-covers-compared-properties.spec.ts
index 3629042404d..e8f7366efab 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/export-covers-compared-properties.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/export-covers-compared-properties.spec.ts
@@ -1,8 +1,8 @@
import {
type NavigationMenuItemManifest,
type PageLayoutManifest,
- type PageLayoutTabManifest,
- type PageLayoutWidgetManifest,
+ type NormalizedPageLayoutTabManifest,
+ type NormalizedPageLayoutWidgetManifest,
type StandaloneViewFieldManifest,
type ViewFieldGroupManifest,
type ViewFieldManifest,
@@ -16,7 +16,6 @@ import {
AggregateOperations,
FieldMetadataType,
PageLayoutTabLayoutMode,
- PageLayoutType,
NavigationMenuItemType,
ViewCalendarLayout,
ViewFilterGroupLogicalOperator,
@@ -156,7 +155,7 @@ const PAGE_LAYOUT_UID = 'dddddddd-dddd-4ddd-8ddd-dddddddddddd';
const PAGE_LAYOUT_TAB_UID = 'eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee';
const PAGE_LAYOUT_WIDGET_UID = 'ffffffff-ffff-4fff-8fff-ffffffffffff';
-const PAGE_LAYOUT_WIDGET_MANIFEST: PageLayoutWidgetManifest = {
+const PAGE_LAYOUT_WIDGET_MANIFEST: NormalizedPageLayoutWidgetManifest = {
universalIdentifier: PAGE_LAYOUT_WIDGET_UID,
title: 'Fields',
type: 'FIELDS',
@@ -170,7 +169,7 @@ const PAGE_LAYOUT_WIDGET_MANIFEST: PageLayoutWidgetManifest = {
},
};
-const PAGE_LAYOUT_TAB_MANIFEST: PageLayoutTabManifest = {
+const PAGE_LAYOUT_TAB_MANIFEST: NormalizedPageLayoutTabManifest = {
universalIdentifier: PAGE_LAYOUT_TAB_UID,
title: 'Overview',
position: 0,
@@ -451,7 +450,6 @@ const EXPORTED_KINDS: ExportedKind[] = [
fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
pageLayoutTabManifest: PAGE_LAYOUT_TAB_MANIFEST,
pageLayoutUniversalIdentifier: PAGE_LAYOUT_UID,
- pageLayoutType: PageLayoutType.RECORD_PAGE,
applicationUniversalIdentifier: APP_UID,
now: NOW,
}),
@@ -470,7 +468,6 @@ const EXPORTED_KINDS: ExportedKind[] = [
fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
pageLayoutWidgetManifest: PAGE_LAYOUT_WIDGET_MANIFEST,
pageLayoutTabUniversalIdentifier: PAGE_LAYOUT_TAB_UID,
- pageLayoutTabLayoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
applicationUniversalIdentifier: APP_UID,
now: NOW,
}),
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/normalize-page-layout-tab-manifest-or-throw.test-util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/normalize-page-layout-tab-manifest-or-throw.test-util.ts
new file mode 100644
index 00000000000..eca952b24bb
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/normalize-page-layout-tab-manifest-or-throw.test-util.ts
@@ -0,0 +1,13 @@
+import { normalizePageLayoutTabManifest } from 'twenty-shared/application';
+
+export const normalizePageLayoutTabManifestOrThrow = (
+ args: Parameters<typeof normalizePageLayoutTabManifest>[0],
+) => {
+ const result = normalizePageLayoutTabManifest(args);
+
+ if (result.status === 'fail') {
+ throw new Error(result.errors.join('\n'));
+ }
+
+ return result.pageLayoutTab;
+};
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/reconstruct-page-layouts-manifest.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/reconstruct-page-layouts-manifest.util.spec.ts
index d00ccf2259f..30cb086a1d2 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/reconstruct-page-layouts-manifest.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/reconstruct-page-layouts-manifest.util.spec.ts
@@ -32,6 +32,7 @@ import { type FlatPageLayout } from 'src/engine/metadata-modules/flat-page-layou
import { type FlatFrontComponent } from 'src/engine/metadata-modules/flat-front-component/types/flat-front-component.type';
import { type FlatView } from 'src/engine/metadata-modules/flat-view/types/flat-view.type';
import { WidgetConfigurationType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-configuration-type.type';
+import { normalizePageLayoutTabManifestOrThrow } from 'src/engine/core-modules/application/application-manifest/utils/__tests__/normalize-page-layout-tab-manifest-or-throw.test-util';
const APP_ID = 'application-id';
const WORKSPACE_ID = 'workspace-id';
@@ -204,9 +205,11 @@ const buildFlatPageLayoutTab = ({
pageLayoutUniversalIdentifier: string;
} & Partial<FlatPageLayoutTab>): FlatPageLayoutTab => ({
...fromPageLayoutTabManifestToUniversalFlatPageLayoutTab({
- pageLayoutTabManifest,
+ pageLayoutTabManifest: normalizePageLayoutTabManifestOrThrow({
+ pageLayoutTabManifest,
+ pageLayoutType: PageLayoutType.RECORD_PAGE,
+ }),
pageLayoutUniversalIdentifier,
- pageLayoutType: PageLayoutType.RECORD_PAGE,
applicationUniversalIdentifier: APP_UID,
now: NOW,
}),
@@ -227,9 +230,19 @@ const buildFlatPageLayoutWidget = ({
pageLayoutTabUniversalIdentifier: string;
} & Partial<FlatPageLayoutWidget>): FlatPageLayoutWidget => ({
...fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
- pageLayoutWidgetManifest,
+ pageLayoutWidgetManifest: normalizePageLayoutTabManifestOrThrow({
+ pageLayoutTabManifest: {
+ universalIdentifier: pageLayoutTabUniversalIdentifier,
+ title: 'Overview',
+ position: 0,
+ layoutMode:
+ pageLayoutWidgetManifest.position?.layoutMode ??
+ PageLayoutTabLayoutMode.VERTICAL_LIST,
+ widgets: [pageLayoutWidgetManifest],
+ },
+ pageLayoutType: PageLayoutType.RECORD_PAGE,
+ }).widgets[0],
pageLayoutTabUniversalIdentifier,
- pageLayoutTabLayoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
applicationUniversalIdentifier: APP_UID,
now: NOW,
}),
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-update-page-layout-tab.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-update-page-layout-tab.integration-spec.ts
index 851c7b261d0..435a49605a9 100644
--- a/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-update-page-layout-tab.integration-spec.ts
+++ b/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-update-page-layout-tab.integration-spec.ts
@@ -35,6 +35,11 @@ const PAGE_LAYOUT_WIDGET_GQL_FIELDS = `
pageLayoutTabId
title
type
+ position {
+ ... on PageLayoutWidgetCanvasPosition {
+ layoutMode
+ }
+ }
configuration {
... on TimelineConfiguration {
configurationType
@@ -174,13 +179,91 @@ describe('Manifest update - page layout tabs (standalone)', () => {
});
}, 60000);
- it('should migrate a standalone tab from canvas to vertical list without replacing its widget', async () => {
- const buildPageLayoutTab = (layoutMode: PageLayoutTabLayoutMode) => ({
+ describe.each(['nested', 'standalone'])('invalid %s tab', (location) => {
+ it.each([
+ {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ heightBehavior: 'TAB_VIEPORT',
+ message: 'unsupported heightBehavior "TAB_VIEPORT"',
+ },
+ {
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ heightBehavior: 'TAB_VIEWPORT',
+ message: 'heightBehavior is only supported for VERTICAL_LIST tabs',
+ },
+ ])(
+ 'returns an input error for $layoutMode with $heightBehavior',
+ async ({ layoutMode, heightBehavior, message }) => {
+ const pageLayoutTab = {
+ universalIdentifier: TEST_TAB_ID,
+ title: 'Invalid tab',
+ position: 1000,
+ layoutMode,
+ widgets: [
+ {
+ universalIdentifier: TEST_WIDGET_ID,
+ title: 'Timeline',
+ type: 'TIMELINE',
+ heightBehavior,
+ configuration: { configurationType: 'TIMELINE' },
+ },
+ ],
+ };
+ const manifest: Manifest = JSON.parse(
+ JSON.stringify({
+ ...buildManifest(),
+ pageLayouts:
+ location === 'nested'
+ ? [
+ {
+ universalIdentifier: uuidv4(),
+ name: 'Invalid page',
+ type: 'STANDALONE_PAGE',
+ tabs: [pageLayoutTab],
+ },
+ ]
+ : [],
+ pageLayoutTabs:
+ location === 'standalone'
+ ? [
+ {
+ ...pageLayoutTab,
+ pageLayoutUniversalIdentifier:
+ STANDARD_PERSON_PAGE_LAYOUT_UNIVERSAL_ID,
+ },
+ ]
+ : [],
+ }),
+ );
+
+ const { errors } = await syncApplication({
+ manifest,
+ expectToFail: true,
+ });
+
+ expect(errors).toEqual([
+ expect.objectContaining({
+ message: expect.stringContaining(message),
+ extensions: expect.objectContaining({ code: 'BAD_USER_INPUT' }),
+ }),
+ ]);
+ const applicationTabs = await globalThis.testDataSource.query(
+ `SELECT id FROM core."pageLayoutTab" WHERE "applicationId" = $1`,
+ [testApplicationId],
+ );
+
+ expect(applicationTabs).toHaveLength(0);
+ },
+ );
+ });
+
+ it('should preserve a legacy Canvas tab without replacing its widget on subsequent sync', async () => {
+ const buildLegacyCanvasPageLayoutTab = () => ({
universalIdentifier: TEST_TAB_ID,
pageLayoutUniversalIdentifier: STANDARD_PERSON_PAGE_LAYOUT_UNIVERSAL_ID,
title: 'Timeline',
position: 1000,
- layoutMode,
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
widgets: [
{
universalIdentifier: TEST_WIDGET_ID,
@@ -195,7 +278,7 @@ describe('Manifest update - page layout tabs (standalone)', () => {
await syncApplication({
manifest: buildManifest({
- pageLayoutTabs: [buildPageLayoutTab(PageLayoutTabLayoutMode.CANVAS)],
+ pageLayoutTabs: [buildLegacyCanvasPageLayoutTab()],
}),
expectToFail: false,
});
@@ -228,6 +311,9 @@ describe('Manifest update - page layout tabs (standalone)', () => {
pageLayoutTabId: tabAfterFirstSync.id,
title: 'Timeline',
type: 'TIMELINE',
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ },
configuration: {
configurationType: 'TIMELINE',
},
@@ -235,9 +321,7 @@ describe('Manifest update - page layout tabs (standalone)', () => {
await syncApplication({
manifest: buildManifest({
- pageLayoutTabs: [
- buildPageLayoutTab(PageLayoutTabLayoutMode.VERTICAL_LIST),
- ],
+ pageLayoutTabs: [buildLegacyCanvasPageLayoutTab()],
}),
expectToFail: false,
});
@@ -251,7 +335,7 @@ describe('Manifest update - page layout tabs (standalone)', () => {
expect(tabAfterSecondSync).toMatchObject({
id: tabAfterFirstSync.id,
universalIdentifier: TEST_TAB_ID,
- layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
});
const { data: widgetsAfterSecondSyncData } = await findPageLayoutWidgets({
@@ -268,6 +352,9 @@ describe('Manifest update - page layout tabs (standalone)', () => {
pageLayoutTabId: tabAfterSecondSync.id,
title: 'Timeline',
type: 'TIMELINE',
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ },
configuration: {
configurationType: 'TIMELINE',
},
diff --git a/packages/twenty-shared/src/application/__tests__/normalizePageLayoutTabManifest.test.ts b/packages/twenty-shared/src/application/__tests__/normalizePageLayoutTabManifest.test.ts
new file mode 100644
index 00000000000..6c02df6cf7f
--- /dev/null
+++ b/packages/twenty-shared/src/application/__tests__/normalizePageLayoutTabManifest.test.ts
@@ -0,0 +1,640 @@
+import { normalizePageLayoutTabManifest } from '../normalizePageLayoutTabManifest';
+import {
+ type PageLayoutTabManifest,
+ type PageLayoutWidgetManifest,
+} from '../pageLayoutManifestType';
+import {
+ PageLayoutTabLayoutMode,
+ PageLayoutType,
+ PageLayoutWidgetVerticalListHeightBehavior,
+} from '../../types';
+import { DEFAULT_WIDGET_SIZE } from '../../constants';
+
+const widget: PageLayoutWidgetManifest = {
+ universalIdentifier: 'widget',
+ title: 'App',
+ type: 'FRONT_COMPONENT',
+ configuration: {
+ configurationType: 'FRONT_COMPONENT',
+ frontComponentUniversalIdentifier: 'component',
+ },
+};
+const tab: PageLayoutTabManifest = {
+ universalIdentifier: 'tab',
+ title: 'Details',
+ position: 0,
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ widgets: [widget],
+};
+
+describe('normalizePageLayoutTabManifest', () => {
+ describe.each(['UNSUPPORTED', '', 42, {}])(
+ 'with invalid layoutMode %s in JSON input',
+ (layoutMode) => {
+ it.each([{ widgets: [] }, { widgets: [widget] }])(
+ 'returns a validation error with widgets $widgets',
+ ({ widgets }) => {
+ const pageLayoutTabManifest = JSON.parse(
+ JSON.stringify({ ...tab, layoutMode, widgets }),
+ );
+
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest,
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'fail',
+ errors: [
+ `Page layout tab "Details" defines unsupported layoutMode "${layoutMode}". Expected GRID, VERTICAL_LIST or CANVAS.`,
+ ],
+ });
+ },
+ );
+ },
+ );
+
+ it('derives omitted positions and preserves explicit indices without changing its input', () => {
+ const input: PageLayoutTabManifest = {
+ ...tab,
+ widgets: [
+ { ...widget, heightBehavior: 'FIT_CONTENT' as const },
+ {
+ ...widget,
+ universalIdentifier: 'second-widget',
+ heightBehavior: 'TAB_VIEWPORT' as const,
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 99,
+ heightBehavior:
+ PageLayoutWidgetVerticalListHeightBehavior.FIT_CONTENT,
+ },
+ },
+ ],
+ };
+ const original = JSON.stringify(input);
+ const result = normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: input,
+ pageLayoutType: 'RECORD_PAGE',
+ });
+
+ expect(result).toEqual({
+ status: 'success',
+ pageLayoutTab: {
+ ...tab,
+ widgets: [
+ {
+ ...widget,
+ position: {
+ layoutMode: 'VERTICAL_LIST',
+ index: 0,
+ heightBehavior: 'FIT_CONTENT',
+ },
+ },
+ {
+ ...widget,
+ universalIdentifier: 'second-widget',
+ position: {
+ layoutMode: 'VERTICAL_LIST',
+ index: 99,
+ heightBehavior: 'TAB_VIEWPORT',
+ },
+ },
+ ],
+ },
+ });
+ expect(JSON.stringify(input)).toBe(original);
+ });
+
+ it('preserves a legacy nested height behavior and index', () => {
+ const result = normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ widgets: [
+ {
+ ...widget,
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 99,
+ heightBehavior:
+ PageLayoutWidgetVerticalListHeightBehavior.TAB_VIEWPORT,
+ },
+ },
+ ],
+ },
+ pageLayoutType: undefined,
+ });
+
+ expect(result).toMatchObject({
+ status: 'success',
+ pageLayoutTab: {
+ widgets: [
+ {
+ position: {
+ layoutMode: 'VERTICAL_LIST',
+ index: 99,
+ heightBehavior: 'TAB_VIEWPORT',
+ },
+ },
+ ],
+ },
+ });
+ });
+
+ it('uses explicit indices rather than array order for legacy viewport placement', () => {
+ const pageLayoutTabManifest: PageLayoutTabManifest = {
+ ...tab,
+ widgets: [
+ {
+ ...widget,
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 99,
+ heightBehavior:
+ PageLayoutWidgetVerticalListHeightBehavior.TAB_VIEWPORT,
+ },
+ },
+ {
+ ...widget,
+ universalIdentifier: 'second-widget',
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 2,
+ },
+ },
+ ],
+ };
+
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest,
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'success',
+ pageLayoutTab: pageLayoutTabManifest,
+ });
+ });
+
+ it('keeps omitted height behavior implicit', () => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: tab,
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'success',
+ pageLayoutTab: {
+ ...tab,
+ widgets: [
+ { ...widget, position: { layoutMode: 'VERTICAL_LIST', index: 0 } },
+ ],
+ },
+ });
+ });
+
+ describe.each<{ name: string; viewport: Partial<PageLayoutWidgetManifest> }>([
+ { name: 'explicit height', viewport: { heightBehavior: 'TAB_VIEWPORT' } },
+ {
+ name: 'legacy nested height',
+ viewport: {
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 0,
+ heightBehavior:
+ PageLayoutWidgetVerticalListHeightBehavior.TAB_VIEWPORT,
+ },
+ },
+ },
+ {
+ name: 'widget type default',
+ viewport: {
+ type: 'TIMELINE',
+ configuration: { configurationType: 'TIMELINE' },
+ },
+ },
+ ])('viewport constraints with $name', ({ viewport }) => {
+ it('rejects a fit-content sibling with the same explicit index', () => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ widgets: [
+ {
+ ...widget,
+ universalIdentifier: 'fit-content-widget',
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 0,
+ },
+ },
+ {
+ ...widget,
+ ...viewport,
+ position: {
+ ...viewport.position,
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 0,
+ },
+ },
+ ],
+ },
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'fail',
+ errors: [
+ 'Page layout tab "Details" must place its TAB_VIEWPORT widget last.',
+ ],
+ });
+ });
+
+ it.each([
+ { duplicate: true, error: 'can contain only one TAB_VIEWPORT widget' },
+ { duplicate: false, error: 'must place its TAB_VIEWPORT widget last' },
+ ])('rejects a layout that $error', ({ duplicate, error }) => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ widgets: [
+ { ...widget, ...viewport },
+ {
+ ...widget,
+ ...(duplicate ? viewport : {}),
+ universalIdentifier: 'second-widget',
+ },
+ ],
+ },
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'fail',
+ errors: [`Page layout tab "Details" ${error}.`],
+ });
+ });
+ });
+
+ it('accepts an explicit fit-content override followed by a default viewport widget', () => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ widgets: [
+ {
+ ...widget,
+ type: 'TIMELINE',
+ configuration: { configurationType: 'TIMELINE' },
+ heightBehavior: 'FIT_CONTENT',
+ },
+ {
+ ...widget,
+ universalIdentifier: 'second-widget',
+ type: 'TIMELINE',
+ configuration: { configurationType: 'TIMELINE' },
+ },
+ ],
+ },
+ pageLayoutType: undefined,
+ }),
+ ).toMatchObject({ status: 'success' });
+ });
+
+ it.each([PageLayoutTabLayoutMode.GRID, PageLayoutTabLayoutMode.CANVAS])(
+ 'rejects a vertical-list position in an authored %s tab',
+ (layoutMode) => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ layoutMode,
+ widgets: [
+ {
+ ...widget,
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 0,
+ },
+ },
+ { ...widget, universalIdentifier: 'second-widget' },
+ ],
+ },
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'fail',
+ errors: [
+ `Page layout widget "App" uses a VERTICAL_LIST position, but its parent tab "Details" uses ${layoutMode}.`,
+ ],
+ });
+ },
+ );
+
+ it('rejects a conflicting grid position instead of changing its layout', () => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ widgets: [
+ {
+ ...widget,
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ row: 0,
+ column: 0,
+ rowSpan: 1,
+ columnSpan: 12,
+ },
+ },
+ ],
+ },
+ pageLayoutType: undefined,
+ }),
+ ).toMatchObject({
+ status: 'fail',
+ errors: [
+ 'Page layout widget "App" uses a GRID position, but its parent tab "Details" uses VERTICAL_LIST.',
+ ],
+ });
+ });
+
+ it.each([
+ undefined,
+ PageLayoutType.DASHBOARD,
+ PageLayoutType.RECORD_PAGE,
+ PageLayoutType.STANDALONE_PAGE,
+ ])('resolves omitted layout mode for page type %s', (pageLayoutType) => {
+ const result = normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ layoutMode: undefined,
+ widgets: undefined,
+ },
+ pageLayoutType,
+ });
+ expect(result).toMatchObject({
+ status: 'success',
+ pageLayoutTab: {
+ layoutMode:
+ pageLayoutType === PageLayoutType.STANDALONE_PAGE
+ ? 'VERTICAL_LIST'
+ : 'GRID',
+ widgets: [],
+ },
+ });
+ });
+
+ it('keeps an explicit grid mode and supplies its default position', () => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ },
+ pageLayoutType: 'STANDALONE_PAGE',
+ }),
+ ).toMatchObject({
+ status: 'success',
+ pageLayoutTab: {
+ layoutMode: 'GRID',
+ widgets: [
+ {
+ position: {
+ layoutMode: 'GRID',
+ row: 0,
+ column: 0,
+ rowSpan: DEFAULT_WIDGET_SIZE.default.h,
+ columnSpan: DEFAULT_WIDGET_SIZE.default.w,
+ },
+ },
+ ],
+ },
+ });
+ });
+
+ it.each(['position', 'gridPosition'])(
+ 'preserves legacy grid coordinates in %s',
+ (positionKey) => {
+ const gridPosition = { row: 2, column: 6, rowSpan: 4, columnSpan: 6 };
+ const result = normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ widgets: [
+ {
+ ...widget,
+ [positionKey]:
+ positionKey === 'position'
+ ? {
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ ...gridPosition,
+ }
+ : gridPosition,
+ },
+ ],
+ },
+ pageLayoutType: undefined,
+ });
+ expect(result).toEqual({
+ status: 'success',
+ pageLayoutTab: {
+ ...tab,
+ layoutMode: 'GRID',
+ widgets: [
+ { ...widget, position: { layoutMode: 'GRID', ...gridPosition } },
+ ],
+ },
+ });
+ },
+ );
+
+ it.each<PageLayoutWidgetManifest['position']>([
+ {
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ row: 1,
+ column: 2,
+ rowSpan: 3,
+ columnSpan: 4,
+ },
+ { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 0 },
+ ])(
+ 'rejects a conflicting position %j on a single-widget Canvas tab',
+ (position) => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ widgets: [{ ...widget, position }],
+ },
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'fail',
+ errors: [
+ `Page layout widget "App" uses a ${position?.layoutMode} position, but its parent tab "Details" uses CANVAS.`,
+ ],
+ });
+ },
+ );
+
+ it.each<PageLayoutWidgetManifest['position']>([
+ undefined,
+ { layoutMode: PageLayoutTabLayoutMode.CANVAS },
+ ])('preserves single-widget Canvas with position %s', (position) => {
+ const result = normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ widgets: [{ ...widget, position }],
+ },
+ pageLayoutType: undefined,
+ });
+ expect(result).toMatchObject({
+ status: 'success',
+ pageLayoutTab: {
+ layoutMode: 'CANVAS',
+ widgets: [
+ {
+ position: {
+ layoutMode: 'CANVAS',
+ },
+ },
+ ],
+ },
+ });
+ });
+
+ it.each([0, 2])(
+ 'keeps a Canvas tab with %i widgets unchanged',
+ (widgetCount) => {
+ const result = normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ layoutMode: PageLayoutTabLayoutMode.CANVAS,
+ widgets: Array.from({ length: widgetCount }, (_, index) => ({
+ ...widget,
+ universalIdentifier: `widget-${index}`,
+ })),
+ },
+ pageLayoutType: undefined,
+ });
+ expect(result).toMatchObject({
+ status: 'success',
+ pageLayoutTab: {
+ layoutMode: 'CANVAS',
+ widgets: Array.from({ length: widgetCount }, () => ({
+ position: { layoutMode: 'CANVAS' },
+ })),
+ },
+ });
+ },
+ );
+
+ it.each([PageLayoutTabLayoutMode.GRID, PageLayoutTabLayoutMode.CANVAS])(
+ 'rejects heightBehavior on authored %s before normalization',
+ (layoutMode) => {
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest: {
+ ...tab,
+ layoutMode,
+ widgets: [{ ...widget, heightBehavior: 'TAB_VIEWPORT' }],
+ },
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'fail',
+ errors: [
+ `Page layout widget "App" defines heightBehavior, but its parent tab "Details" uses ${layoutMode}. heightBehavior is only supported for VERTICAL_LIST tabs.`,
+ ],
+ });
+ },
+ );
+
+ it.each(['TAB_VIEPORT', '', 42, {}])(
+ 'rejects invalid heightBehavior %s in JSON input',
+ (heightBehavior) => {
+ const pageLayoutTabManifest = JSON.parse(
+ JSON.stringify({ ...tab, widgets: [{ ...widget, heightBehavior }] }),
+ );
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest,
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'fail',
+ errors: [
+ `Page layout widget "App" defines unsupported heightBehavior "${heightBehavior}". Expected FIT_CONTENT or TAB_VIEWPORT.`,
+ ],
+ });
+ },
+ );
+
+ it.each([
+ {
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ row: 0,
+ column: 0,
+ rowSpan: 1,
+ columnSpan: 1,
+ },
+ { layoutMode: PageLayoutTabLayoutMode.CANVAS },
+ ])(
+ 'rejects nested heightBehavior in $layoutMode JSON positions',
+ (position) => {
+ const pageLayoutTabManifest = JSON.parse(
+ JSON.stringify({
+ ...tab,
+ layoutMode: position.layoutMode,
+ widgets: [
+ {
+ ...widget,
+ position: { ...position, heightBehavior: 'TAB_VIEWPORT' },
+ },
+ ],
+ }),
+ );
+
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest,
+ pageLayoutType: undefined,
+ }),
+ ).toEqual({
+ status: 'fail',
+ errors: [
+ `Page layout widget "App" defines heightBehavior, but its parent tab "Details" uses ${position.layoutMode}. heightBehavior is only supported for VERTICAL_LIST tabs.`,
+ ],
+ });
+ },
+ );
+
+ it('rejects an invalid nested height behavior', () => {
+ const pageLayoutTabManifest = JSON.parse(
+ JSON.stringify({
+ ...tab,
+ widgets: [
+ {
+ ...widget,
+ position: {
+ layoutMode: 'VERTICAL_LIST',
+ index: 0,
+ heightBehavior: 'INVALID',
+ },
+ },
+ ],
+ }),
+ );
+ expect(
+ normalizePageLayoutTabManifest({
+ pageLayoutTabManifest,
+ pageLayoutType: undefined,
+ }),
+ ).toMatchObject({
+ status: 'fail',
+ errors: [expect.stringContaining('unsupported heightBehavior "INVALID"')],
+ });
+ });
+});
diff --git a/packages/twenty-shared/src/application/index.ts b/packages/twenty-shared/src/application/index.ts
index 35a04a41c97..f0c7fff8cd6 100644
--- a/packages/twenty-shared/src/application/index.ts
+++ b/packages/twenty-shared/src/application/index.ts
@@ -148,6 +148,11 @@ export type {
} from './logicFunctionManifestType';
export type { TranslationsManifest, Manifest } from './manifestType';
export type { NavigationMenuItemManifest } from './navigationMenuItemManifestType';
+export type {
+ NormalizedPageLayoutWidgetManifest,
+ NormalizedPageLayoutTabManifest,
+} from './normalizedPageLayoutManifestType';
+export { normalizePageLayoutTabManifest } from './normalizePageLayoutTabManifest';
export type { OAuthConnectionProviderConfig } from './oauthConnectionProviderConfigType';
export type { OAuthProviderTokenRequestContentType } from './oauthProviderTokenRequestContentType.type';
export type { ObjectFieldManifest } from './objectFieldManifest.type';
diff --git a/packages/twenty-shared/src/application/normalizePageLayoutTabManifest.ts b/packages/twenty-shared/src/application/normalizePageLayoutTabManifest.ts
new file mode 100644
index 00000000000..b0ddd8d8d28
--- /dev/null
+++ b/packages/twenty-shared/src/application/normalizePageLayoutTabManifest.ts
@@ -0,0 +1,217 @@
+import {
+ type NormalizedPageLayoutTabManifest,
+ type NormalizedPageLayoutWidgetManifest,
+} from '@/application/normalizedPageLayoutManifestType';
+import {
+ type PageLayoutManifest,
+ type PageLayoutTabManifest,
+ type PageLayoutWidgetManifest,
+} from '@/application/pageLayoutManifestType';
+import { DEFAULT_WIDGET_SIZE } from '@/constants';
+import {
+ type GridPosition,
+ PageLayoutTabLayoutMode,
+ PageLayoutType,
+ PageLayoutWidgetVerticalListHeightBehavior,
+ WidgetType,
+} from '@/types';
+import {
+ assertUnreachable,
+ getPageLayoutWidgetHeightBehavior,
+ isDefined,
+ isPlainObject,
+} from '@/utils';
+
+export const normalizePageLayoutTabManifest = ({
+ pageLayoutTabManifest,
+ pageLayoutType,
+}: {
+ pageLayoutTabManifest: PageLayoutTabManifest;
+ pageLayoutType: PageLayoutManifest['type'] | undefined;
+}):
+ | { status: 'success'; pageLayoutTab: NormalizedPageLayoutTabManifest }
+ | { status: 'fail'; errors: string[] } => {
+ const layoutMode =
+ pageLayoutTabManifest.layoutMode ??
+ (pageLayoutType === PageLayoutType.STANDALONE_PAGE
+ ? PageLayoutTabLayoutMode.VERTICAL_LIST
+ : PageLayoutTabLayoutMode.GRID);
+ const widgets = pageLayoutTabManifest.widgets ?? [];
+ const errors: string[] = [];
+
+ if (
+ !Object.values(PageLayoutTabLayoutMode).some(
+ (supportedLayoutMode) => supportedLayoutMode === layoutMode,
+ )
+ ) {
+ return {
+ status: 'fail',
+ errors: [
+ `Page layout tab "${pageLayoutTabManifest.title}" defines unsupported layoutMode "${layoutMode}". Expected GRID, VERTICAL_LIST or CANVAS.`,
+ ],
+ };
+ }
+
+ for (const widget of widgets) {
+ const heightBehaviors = [
+ widget.heightBehavior,
+ isPlainObject(widget.position) && 'heightBehavior' in widget.position
+ ? widget.position.heightBehavior
+ : undefined,
+ ].filter(isDefined);
+
+ if (
+ heightBehaviors.length > 0 &&
+ layoutMode !== PageLayoutTabLayoutMode.VERTICAL_LIST
+ ) {
+ errors.push(
+ `Page layout widget "${widget.title}" defines heightBehavior, but its parent tab "${pageLayoutTabManifest.title}" uses ${layoutMode}. heightBehavior is only supported for VERTICAL_LIST tabs.`,
+ );
+ }
+
+ for (const heightBehavior of heightBehaviors) {
+ if (
+ !Object.values(PageLayoutWidgetVerticalListHeightBehavior).some(
+ (supportedHeightBehavior) =>
+ supportedHeightBehavior === heightBehavior,
+ )
+ ) {
+ errors.push(
+ `Page layout widget "${widget.title}" defines unsupported heightBehavior "${heightBehavior}". Expected FIT_CONTENT or TAB_VIEWPORT.`,
+ );
+ }
+ }
+ }
+
+ if (errors.length > 0) {
+ return { status: 'fail', errors };
+ }
+
+ const pageLayoutTab: NormalizedPageLayoutTabManifest = {
+ ...pageLayoutTabManifest,
+ layoutMode,
+ widgets: widgets.map(
+ (
+ {
+ heightBehavior,
+ position,
+ gridPosition,
+ ...widget
+ }: PageLayoutWidgetManifest & { gridPosition?: GridPosition },
+ index,
+ ): NormalizedPageLayoutWidgetManifest => {
+ if (isDefined(position)) {
+ return {
+ ...widget,
+ position:
+ position.layoutMode === PageLayoutTabLayoutMode.VERTICAL_LIST &&
+ isDefined(heightBehavior)
+ ? {
+ ...position,
+ heightBehavior:
+ PageLayoutWidgetVerticalListHeightBehavior[
+ heightBehavior
+ ],
+ }
+ : position,
+ };
+ }
+
+ if (isDefined(gridPosition)) {
+ return {
+ ...widget,
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ ...gridPosition,
+ },
+ };
+ }
+
+ switch (layoutMode) {
+ case PageLayoutTabLayoutMode.GRID:
+ return {
+ ...widget,
+ position: {
+ layoutMode,
+ row: 0,
+ column: 0,
+ rowSpan: DEFAULT_WIDGET_SIZE.default.h,
+ columnSpan: DEFAULT_WIDGET_SIZE.default.w,
+ },
+ };
+ case PageLayoutTabLayoutMode.VERTICAL_LIST:
+ return {
+ ...widget,
+ position: {
+ layoutMode,
+ index,
+ ...(isDefined(heightBehavior)
+ ? {
+ heightBehavior:
+ PageLayoutWidgetVerticalListHeightBehavior[
+ heightBehavior
+ ],
+ }
+ : {}),
+ },
+ };
+ case PageLayoutTabLayoutMode.CANVAS:
+ return {
+ ...widget,
+ position: { layoutMode },
+ };
+ default:
+ return assertUnreachable(layoutMode);
+ }
+ },
+ ),
+ };
+
+ for (const widget of pageLayoutTab.widgets) {
+ if (widget.position.layoutMode !== layoutMode) {
+ errors.push(
+ `Page layout widget "${widget.title}" uses a ${widget.position.layoutMode} position, but its parent tab "${pageLayoutTab.title}" uses ${layoutMode}.`,
+ );
+ }
+ }
+
+ if (layoutMode === PageLayoutTabLayoutMode.VERTICAL_LIST) {
+ const viewportWidgets = pageLayoutTab.widgets.filter(
+ ({ type, position }) =>
+ position.layoutMode === PageLayoutTabLayoutMode.VERTICAL_LIST &&
+ getPageLayoutWidgetHeightBehavior({
+ widgetType: WidgetType[type],
+ heightBehavior: position.heightBehavior,
+ }) === PageLayoutWidgetVerticalListHeightBehavior.TAB_VIEWPORT,
+ );
+
+ if (viewportWidgets.length > 1) {
+ errors.push(
+ `Page layout tab "${pageLayoutTab.title}" can contain only one TAB_VIEWPORT widget.`,
+ );
+ }
+
+ if (
+ viewportWidgets.length === 1 &&
+ pageLayoutTab.widgets.some(
+ (widget) =>
+ widget !== viewportWidgets[0] &&
+ widget.position.layoutMode ===
+ PageLayoutTabLayoutMode.VERTICAL_LIST &&
+ viewportWidgets[0].position.layoutMode ===
+ PageLayoutTabLayoutMode.VERTICAL_LIST &&
+ widget.position.index >= viewportWidgets[0].position.index,
+ )
+ ) {
+ errors.push(
+ `Page layout tab "${pageLayoutTab.title}" must place its TAB_VIEWPORT widget last.`,
+ );
+ }
+ }
+
+ if (errors.length > 0) {
+ return { status: 'fail', errors };
+ }
+
+ return { status: 'success', pageLayoutTab };
+};
diff --git a/packages/twenty-shared/src/application/normalizedPageLayoutManifestType.ts b/packages/twenty-shared/src/application/normalizedPageLayoutManifestType.ts
new file mode 100644
index 00000000000..cc814774ad4
--- /dev/null
+++ b/packages/twenty-shared/src/application/normalizedPageLayoutManifestType.ts
@@ -0,0 +1,23 @@
+import {
+ type PageLayoutTabManifest,
+ type PageLayoutWidgetManifest,
+} from '@/application/pageLayoutManifestType';
+import {
+ type PageLayoutTabLayoutMode,
+ type PageLayoutWidgetPosition,
+} from '@/types';
+
+export type NormalizedPageLayoutWidgetManifest = Omit<
+ PageLayoutWidgetManifest,
+ 'position' | 'heightBehavior'
+> & {
+ position: PageLayoutWidgetPosition;
+};
+
+export type NormalizedPageLayoutTabManifest = Omit<
+ PageLayoutTabManifest,
+ 'layoutMode' | 'widgets'
+> & {
+ layoutMode: PageLayoutTabLayoutMode;
+ widgets: NormalizedPageLayoutWidgetManifest[];
+};
diff --git a/packages/twenty-shared/src/application/pageLayoutManifestType.ts b/packages/twenty-shared/src/application/pageLayoutManifestType.ts
index bbd928647ed..bd756a7f41c 100644
--- a/packages/twenty-shared/src/application/pageLayoutManifestType.ts
+++ b/packages/twenty-shared/src/application/pageLayoutManifestType.ts
@@ -5,6 +5,7 @@ import {
type PageLayoutWidgetConditionalDisplay,
type PageLayoutWidgetPosition,
type PageLayoutWidgetUniversalConfiguration,
+ type PageLayoutWidgetVerticalListHeightBehavior,
type WidgetType,
} from '@/types';
@@ -14,6 +15,7 @@ export type PageLayoutWidgetManifest = SyncableEntityOptions & {
objectUniversalIdentifier?: string;
conditionalDisplay?: PageLayoutWidgetConditionalDisplay;
position?: PageLayoutWidgetPosition;
+ heightBehavior?: `${PageLayoutWidgetVerticalListHeightBehavior}`;
configuration: PageLayoutWidgetUniversalConfiguration;
};