Skip to content

The open alternative to Salesforce, designed for AI.

Add a standalone page layout widget slot to the manifest and export widgets placed on existing tabs (#25651)

Weiko654be6189c81
diff --git a/packages/twenty-apps/fixtures/rich-app/src/page-layout-widgets/extra-widget.page-layout-widget.ts b/packages/twenty-apps/fixtures/rich-app/src/page-layout-widgets/extra-widget.page-layout-widget.ts
new file mode 100644
index 00000000000..f50d1c12536
--- /dev/null
+++ b/packages/twenty-apps/fixtures/rich-app/src/page-layout-widgets/extra-widget.page-layout-widget.ts
@@ -0,0 +1,19 @@
+import {
+ definePageLayoutWidget,
+ PageLayoutTabLayoutMode,
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS,
+} from 'twenty-sdk/define';
+
+export default definePageLayoutWidget({
+ universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000013',
+ pageLayoutTabUniversalIdentifier:
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.companyRecordPage.tabs.home
+ .universalIdentifier,
+ title: 'Extra Home Widget',
+ type: 'FRONT_COMPONENT',
+ position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 1000 },
+ configuration: {
+ configurationType: 'FRONT_COMPONENT',
+ frontComponentUniversalIdentifier: '370ae182-743f-4ecb-b625-7ac48e21f0e5',
+ },
+});
diff --git a/packages/twenty-docs/developers/extend/apps/getting-started/scaffolding.mdx b/packages/twenty-docs/developers/extend/apps/getting-started/scaffolding.mdx
index 68b39bbf0dc..aacadf9d6ab 100644
--- a/packages/twenty-docs/developers/extend/apps/getting-started/scaffolding.mdx
+++ b/packages/twenty-docs/developers/extend/apps/getting-started/scaffolding.mdx
@@ -35,6 +35,7 @@ yarn twenty dev:add frontComponent
| Navigation menu item | `yarn twenty dev:add navigationMenuItem` | `src/navigation-menu-items/<name>.ts` |
| Page layout | `yarn twenty dev:add pageLayout` | `src/page-layouts/<name>.ts` |
| Page layout tab | `yarn twenty dev:add pageLayoutTab` | `src/page-layout-tabs/<name>.ts` |
+| Page layout widget | `yarn twenty dev:add pageLayoutWidget` | `src/page-layout-widgets/<name>.ts` |
| Command menu item | `yarn twenty dev:add commandMenuItem` | `src/command-menu-items/<name>.ts` |
| View field | `yarn twenty dev:add viewField` | `src/view-fields/<name>.ts` |
| Connection provider | `yarn twenty dev:add connectionProvider` | `src/connection-providers/<name>.ts` |
diff --git a/packages/twenty-docs/developers/extend/apps/layout/overview.mdx b/packages/twenty-docs/developers/extend/apps/layout/overview.mdx
index 4e5f2915272..31a740392a4 100644
--- a/packages/twenty-docs/developers/extend/apps/layout/overview.mdx
+++ b/packages/twenty-docs/developers/extend/apps/layout/overview.mdx
@@ -33,7 +33,7 @@ A Twenty app's **layout layer** is everything the user sees: where the app surfa
`defineNavigationMenuItem` — sidebar entries pointing at views or external URLs.
</Card>
<Card title="Page Layouts" icon="table-columns" href="/developers/extend/apps/layout/page-layouts">
- `definePageLayout` and `definePageLayoutTab` — tabs and widgets on a record's detail page.
+ `definePageLayout`, `definePageLayoutTab` and `definePageLayoutWidget` — tabs and widgets on a record's detail page.
</Card>
<Card title="Front Components" icon="window-maximize" href="/developers/extend/apps/layout/front-components">
`defineFrontComponent` — sandboxed React components that render inside Twenty.
@@ -49,7 +49,7 @@ A Twenty app's **layout layer** is everything the user sees: where the app surfa
|---------|------------------|--------|
| **Sidebar** | A custom entry linking to a saved view or external URL | `defineNavigationMenuItem` |
| **Record list** | A saved configuration for an object — visible columns, order, filters, groups | `defineView` |
-| **Record detail page** | The tabs and widgets on a record page (your own object's, or a standard one) | `definePageLayout`, `definePageLayoutTab` |
+| **Record detail page** | The tabs and widgets on a record page (your own object's, or a standard one) | `definePageLayout`, `definePageLayoutTab`, `definePageLayoutWidget` |
| **Inside any of the above** | A custom React widget — buttons, forms, dashboards, integrations | `defineFrontComponent` |
| **App settings** | A custom configuration section inside the app's Settings tab, in place of the default variables UI | `defineSettingsFrontComponent` |
| **Command menu (Cmd+K)** | A pinned quick action or hidden command | `defineCommandMenuItem` |
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 26ef08965e5..a0c9858d333 100644
--- a/packages/twenty-docs/developers/extend/apps/layout/page-layouts.mdx
+++ b/packages/twenty-docs/developers/extend/apps/layout/page-layouts.mdx
@@ -1,15 +1,16 @@
---
title: Page Layouts
-description: Customize record detail pages — tabs, widgets, and where front components render — using definePageLayout and definePageLayoutTab.
+description: Customize record detail pages — tabs, widgets, and where front components render — using definePageLayout, definePageLayoutTab and definePageLayoutWidget.
icon: 'table-columns'
---
-A **page layout** controls how a record's detail page is arranged: which tabs appear and what widgets they contain. Use `definePageLayout()` to declare a layout for an object you own, or `definePageLayoutTab()` to add a single tab to a layout that already exists (yours or a standard Twenty one).
+A **page layout** controls how a record's detail page is arranged: which tabs appear and what widgets they contain. Use `definePageLayout()` to declare a layout for an object you own, `definePageLayoutTab()` to add a single tab to a layout that already exists (yours or a standard Twenty one), or `definePageLayoutWidget()` to add a single widget to a tab that already exists.
| Use case | Entity |
| ---------------------------------------------------------------------- | --------------------- |
| Define the entire layout for a record page on an object you own | `definePageLayout` |
| Add one tab to an existing layout (your own object, or a standard one) | `definePageLayoutTab` |
+| Add one widget to an existing tab (the Home tab of a record page, or a tab you defined) | `definePageLayoutWidget` |
## definePageLayout
@@ -184,3 +185,57 @@ export default definePageLayoutTab({
- `position` controls ordering against existing tabs on the targeted layout. Pick a value that places your tab where you want it relative to built-in tabs.
- Use this instead of `definePageLayout` when you only want to add to an existing layout. Use `definePageLayout` when you own the entire layout.
- `yarn twenty pull` writes a tab you added to a page layout you do not own back as a `definePageLayoutTab()` file, with its widgets inline, under the same limits as widgets of a `definePageLayout()`.
+
+## definePageLayoutWidget
+
+Use this when you only want to **add** a widget to a tab that already exists — for example, a front component on the Home tab of the standard Company page, or a chart on the Home tab of your own object's record page.
+
+```ts src/page-layout-widgets/example-home-widget.ts
+import {
+ definePageLayoutWidget,
+ PageLayoutTabLayoutMode,
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS,
+} from 'twenty-sdk/define';
+import { HELLO_WORLD_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER } from '../front-components/hello-world';
+
+export default definePageLayoutWidget({
+ universalIdentifier: 'b1b2b3b4-b5b6-4000-8000-000000000003',
+ pageLayoutTabUniversalIdentifier:
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.companyRecordPage.tabs.home
+ .universalIdentifier,
+ title: 'Hello World',
+ type: 'FRONT_COMPONENT',
+ position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 1000 },
+ configuration: {
+ configurationType: 'FRONT_COMPONENT',
+ frontComponentUniversalIdentifier:
+ HELLO_WORLD_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER,
+ },
+});
+```
+
+### Key points
+
+- `pageLayoutTabUniversalIdentifier` is **required** and must point to a tab that already exists at install time: a standard Twenty tab (`STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.<object>RecordPage.tabs.<tab>.universalIdentifier`), a tab of one of your own layouts, or a tab of the record page Twenty generates for one of your objects. The generated tabs have deterministic identifiers, so you can compute them:
+
+ ```ts
+ import {
+ getSystemPageLayoutTabUniversalIdentifier,
+ getSystemRecordPageLayoutUniversalIdentifier,
+ } from 'twenty-sdk/define';
+
+ const EXAMPLE_HOME_TAB_UNIVERSAL_IDENTIFIER =
+ getSystemPageLayoutTabUniversalIdentifier({
+ objectMetadataApplicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ pageLayoutUniversalIdentifier: getSystemRecordPageLayoutUniversalIdentifier({
+ objectMetadataApplicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ objectUniversalIdentifier: EXAMPLE_OBJECT_UNIVERSAL_IDENTIFIER,
+ }),
+ title: 'Home',
+ });
+ ```
+
+- `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).
+- `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` does not write `definePageLayoutWidget()` files yet. A widget on a tab your app does not own is carried by the export but reported rather than written, so keep pushing such a tree with `yarn twenty apply --no-delete`; see [what pull does not write](/developers/extend/apps/operations/sync-and-recovery#pulling-an-installed-app-back-to-source).
diff --git a/packages/twenty-docs/developers/extend/apps/operations/sync-and-recovery.mdx b/packages/twenty-docs/developers/extend/apps/operations/sync-and-recovery.mdx
index 8bdbb77d70f..569171c0fca 100644
--- a/packages/twenty-docs/developers/extend/apps/operations/sync-and-recovery.mdx
+++ b/packages/twenty-docs/developers/extend/apps/operations/sync-and-recovery.mdx
@@ -128,7 +128,7 @@ Each entity goes to the file that already defines it, so a second pull rewrites
- **Not exported yet** — roles and permissions, navigation, command menu items, logic functions and front components, and the stored source of your functions.
- **Derived by the engine** — system fields, default relations, default views and backing indexes, and the default page layouts of each object. The server rebuilds them on apply. An object may still point its label identifier at one of them, as junction objects created in the UI do; the pointer is written and the build resolves it without adding a field.
- **Placed on a default or foreign view** — filters, filter groups, sorts, groups and field groups added to an engine default view, or to a view owned by another application, have no source form yet and are reported. View fields added there are written as standalone files, since the view's identifier is known.
-- **Placed on a default or foreign page layout** — widgets added to a tab of an engine default page layout, or of a page layout owned by another application, have no source form yet and are reported. Tabs added there are written as standalone files, since the layout's identifier is known.
+- **Placed on a default or foreign page layout** — a widget added to a tab of an engine default page layout, or of a page layout owned by another application, has a source form, `definePageLayoutWidget()`, and the export carries it, but this version of pull does not write it to a file yet, so it is reported. Tabs added there are written as standalone files, since the layout's identifier is known.
- **Widgets the export cannot carry yet** — on any layout, including your own, a widget of the deprecated `VIEW` type, a widget showing one of your app's own front components or command menu items, or a widget without a position for its tab's layout mode is reported, and the layout or tab is written without it.
- **Workspace runtime state** — member and API-key role assignments, webhooks and per-user navigation, all excluded by design.
- **Owned by another application** — reported, never pulled.
diff --git a/packages/twenty-sdk/src/cli/__tests__/apps/minimal-app/__integration__/app-dev/expected-manifest.ts b/packages/twenty-sdk/src/cli/__tests__/apps/minimal-app/__integration__/app-dev/expected-manifest.ts
index d6e8412c8ca..ffc2c0fb57c 100644
--- a/packages/twenty-sdk/src/cli/__tests__/apps/minimal-app/__integration__/app-dev/expected-manifest.ts
+++ b/packages/twenty-sdk/src/cli/__tests__/apps/minimal-app/__integration__/app-dev/expected-manifest.ts
@@ -86,6 +86,7 @@ export const EXPECTED_MANIFEST: Manifest = {
navigationMenuItems: [],
pageLayouts: [],
pageLayoutTabs: [],
+ pageLayoutWidgets: [],
roles: [
{
universalIdentifier: 'e1e2e3e4-e5e6-4000-8000-000000000040',
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 5179ec3489f..52c38f20171 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
@@ -1,3 +1,4 @@
+import { STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS } from 'twenty-shared/metadata';
import { FieldType } from '@/sdk/define';
import type { Manifest } from 'twenty-shared/application';
import { SystemPermissionFlag } from 'twenty-shared/constants';
@@ -74,6 +75,25 @@ export const EXPECTED_MANIFEST: Manifest = {
],
},
],
+ pageLayoutWidgets: [
+ {
+ universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000013',
+ pageLayoutTabUniversalIdentifier:
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.companyRecordPage.tabs.home
+ .universalIdentifier,
+ title: 'Extra Home Widget',
+ type: 'FRONT_COMPONENT',
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 1000,
+ },
+ configuration: {
+ configurationType: 'FRONT_COMPONENT',
+ frontComponentUniversalIdentifier:
+ '370ae182-743f-4ecb-b625-7ac48e21f0e5',
+ },
+ },
+ ],
publicAssets: [
{
checksum: '99496069dcc2a1488e1cae9f826d2707',
diff --git a/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/tests/manifest.tests.ts b/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/tests/manifest.tests.ts
index d182ae51b9c..afefe6d9a5a 100644
--- a/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/tests/manifest.tests.ts
+++ b/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/tests/manifest.tests.ts
@@ -27,6 +27,7 @@ export const defineManifestTests = (appPath: string): void => {
expect(manifest.views).toHaveLength(5);
expect(manifest.navigationMenuItems).toHaveLength(3);
expect(manifest.pageLayoutTabs).toHaveLength(1);
+ expect(manifest.pageLayoutWidgets).toHaveLength(1);
expect(normalizeManifestForComparison(manifest)).toEqual(
normalizeManifestForComparison(EXPECTED_MANIFEST),
diff --git a/packages/twenty-sdk/src/cli/__tests__/integration/utils/normalize-manifest.util.ts b/packages/twenty-sdk/src/cli/__tests__/integration/utils/normalize-manifest.util.ts
index f54dc539bbe..bde3de1ca36 100644
--- a/packages/twenty-sdk/src/cli/__tests__/integration/utils/normalize-manifest.util.ts
+++ b/packages/twenty-sdk/src/cli/__tests__/integration/utils/normalize-manifest.util.ts
@@ -33,6 +33,7 @@ export const normalizeManifestForComparison = <T extends Manifest>(
navigationMenuItems: sortById(manifest.navigationMenuItems),
pageLayouts: sortById(manifest.pageLayouts),
pageLayoutTabs: sortById(manifest.pageLayoutTabs ?? []),
+ pageLayoutWidgets: sortById(manifest.pageLayoutWidgets ?? []),
commandMenuItems: sortById(manifest.commandMenuItems ?? []),
logicFunctions: sortById(
manifest.logicFunctions?.map((fn) => ({
diff --git a/packages/twenty-sdk/src/cli/commands/dev/add.ts b/packages/twenty-sdk/src/cli/commands/dev/add.ts
index 47960660c04..afe7ffda82f 100644
--- a/packages/twenty-sdk/src/cli/commands/dev/add.ts
+++ b/packages/twenty-sdk/src/cli/commands/dev/add.ts
@@ -25,6 +25,7 @@ import { getObjectBaseFile } from '@/cli/utilities/entity/entity-object-template
import { getCommandMenuItemBaseFile } from '@/cli/utilities/entity/entity-command-menu-item-template';
import { getPageLayoutBaseFile } from '@/cli/utilities/entity/entity-page-layout-template';
import { getPageLayoutTabBaseFile } from '@/cli/utilities/entity/entity-page-layout-tab-template';
+import { getPageLayoutWidgetBaseFile } from '@/cli/utilities/entity/entity-page-layout-widget-template';
import { getRecordPageLayoutBaseFile } from '@/cli/utilities/entity/entity-record-page-layout-template';
import { getRoleBaseFile } from '@/cli/utilities/entity/entity-role-template';
import { getAgentBaseFile } from '@/cli/utilities/entity/entity-agent-template';
@@ -265,6 +266,15 @@ export class EntityAddCommand {
return { name, file };
}
+ case SyncableEntity.PageLayoutWidget: {
+ const name = await this.getEntityName(entity);
+
+ const file = getPageLayoutWidgetBaseFile({
+ name,
+ });
+ return { name, file };
+ }
+
case SyncableEntity.CommandMenuItem: {
const name = await this.getEntityName(entity);
diff --git a/packages/twenty-sdk/src/cli/utilities/build/common/plugins/__tests__/__snapshots__/stub-twenty-sdk-define.plugin.spec.ts.snap b/packages/twenty-sdk/src/cli/utilities/build/common/plugins/__tests__/__snapshots__/stub-twenty-sdk-define.plugin.spec.ts.snap
index 69996c0ed2c..de831e84f6a 100644
--- a/packages/twenty-sdk/src/cli/utilities/build/common/plugins/__tests__/__snapshots__/stub-twenty-sdk-define.plugin.spec.ts.snap
+++ b/packages/twenty-sdk/src/cli/utilities/build/common/plugins/__tests__/__snapshots__/stub-twenty-sdk-define.plugin.spec.ts.snap
@@ -45,6 +45,8 @@ exports[`stub-twenty-sdk-define plugin > matches the recorded export partition 1
"favoriteRecordIds",
"featureFlags",
"getFieldUniversalIdentifier",
+ "getSystemPageLayoutTabUniversalIdentifier",
+ "getSystemRecordPageLayoutUniversalIdentifier",
"getSystemRelationFieldUniversalIdentifier",
"getSystemViewFieldUniversalIdentifier",
"getSystemViewUniversalIdentifier",
@@ -89,6 +91,7 @@ exports[`stub-twenty-sdk-define plugin > matches the recorded export partition 1
"defineObject",
"definePageLayout",
"definePageLayoutTab",
+ "definePageLayoutWidget",
"definePermissionFlag",
"definePostInstallLogicFunction",
"definePreInstallLogicFunction",
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 5b55ce0996d..ea69fdbd8e0 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
@@ -48,6 +48,7 @@ const validManifest: Manifest = {
navigationMenuItems: [],
pageLayouts: [],
pageLayoutTabs: [],
+ pageLayoutWidgets: [],
};
describe('manifestValidate', () => {
diff --git a/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-build.ts b/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-build.ts
index 263c585d7b8..b31e17e8ed8 100644
--- a/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-build.ts
+++ b/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-build.ts
@@ -50,6 +50,7 @@ import {
type UninstallLogicFunctionApplicationManifest,
type RoleManifest,
type SkillManifest,
+ type StandalonePageLayoutWidgetManifest,
type StandaloneViewFieldManifest,
type TimelineActivityTypeManifest,
type ViewManifest,
@@ -118,6 +119,7 @@ export const buildManifest = async (
const navigationMenuItems: NavigationMenuItemManifest[] = [];
const pageLayouts: PageLayoutManifest[] = [];
const pageLayoutTabs: PageLayoutTabManifest[] = [];
+ const pageLayoutWidgets: StandalonePageLayoutWidgetManifest[] = [];
const commandMenuItems: CommandMenuItemManifest[] = [];
const timelineActivityTypes: TimelineActivityTypeManifest[] = [];
const postInstallLogicFunctions: PostInstallLogicFunctionApplicationManifest[] =
@@ -145,6 +147,7 @@ export const buildManifest = async (
const navigationMenuItemsFilePaths: string[] = [];
const pageLayoutsFilePaths: string[] = [];
const pageLayoutTabsFilePaths: string[] = [];
+ const pageLayoutWidgetsFilePaths: string[] = [];
const commandMenuItemsFilePaths: string[] = [];
const timelineActivityTypesFilePaths: string[] = [];
@@ -482,6 +485,19 @@ export const buildManifest = async (
pageLayoutTabsFilePaths.push(relativePath);
break;
}
+ case ManifestEntityKey.PageLayoutWidgets: {
+ const extract =
+ await extractManifestFromFile<StandalonePageLayoutWidgetManifest>({
+ appPath,
+ filePath,
+ });
+
+ pageLayoutWidgets.push(extract.config);
+ errors.push(...extract.errors);
+ warnings.push(...(extract.warnings ?? []));
+ pageLayoutWidgetsFilePaths.push(relativePath);
+ break;
+ }
case ManifestEntityKey.CommandMenuItems: {
const extract = await extractManifestFromFile<CommandMenuItemConfig>({
appPath,
@@ -686,6 +702,7 @@ export const buildManifest = async (
navigationMenuItems: navigationMenuItems.sort(byId),
pageLayouts: pageLayouts.sort(byId),
pageLayoutTabs: pageLayoutTabs.sort(byId),
+ pageLayoutWidgets: pageLayoutWidgets.sort(byId),
commandMenuItems: commandMenuItems.sort(byId),
timelineActivityTypes: timelineActivityTypes.sort(byId),
};
@@ -708,6 +725,7 @@ export const buildManifest = async (
navigationMenuItems: navigationMenuItemsFilePaths,
pageLayouts: pageLayoutsFilePaths,
pageLayoutTabs: pageLayoutTabsFilePaths,
+ pageLayoutWidgets: pageLayoutWidgetsFilePaths,
commandMenuItems: commandMenuItemsFilePaths,
timelineActivityTypes: timelineActivityTypesFilePaths,
};
diff --git a/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-extract-config.ts b/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-extract-config.ts
index 8bffad78b58..49987260045 100644
--- a/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-extract-config.ts
+++ b/packages/twenty-sdk/src/cli/utilities/build/manifest/manifest-extract-config.ts
@@ -22,6 +22,7 @@ export enum TargetFunction {
DefineNavigationMenuItem = 'defineNavigationMenuItem',
DefinePageLayout = 'definePageLayout',
DefinePageLayoutTab = 'definePageLayoutTab',
+ DefinePageLayoutWidget = 'definePageLayoutWidget',
DefineCommandMenuItem = 'defineCommandMenuItem',
DefineTimelineActivityType = 'defineTimelineActivityType',
}
@@ -44,6 +45,7 @@ export enum ManifestEntityKey {
NavigationMenuItems = 'navigationMenuItems',
PageLayouts = 'pageLayouts',
PageLayoutTabs = 'pageLayoutTabs',
+ PageLayoutWidgets = 'pageLayoutWidgets',
CommandMenuItems = 'commandMenuItems',
TimelineActivityTypes = 'timelineActivityTypes',
}
@@ -81,6 +83,7 @@ export const TARGET_FUNCTION_TO_ENTITY_KEY_MAPPING: Record<
ManifestEntityKey.NavigationMenuItems,
[TargetFunction.DefinePageLayout]: ManifestEntityKey.PageLayouts,
[TargetFunction.DefinePageLayoutTab]: ManifestEntityKey.PageLayoutTabs,
+ [TargetFunction.DefinePageLayoutWidget]: ManifestEntityKey.PageLayoutWidgets,
[TargetFunction.DefineCommandMenuItem]: ManifestEntityKey.CommandMenuItems,
[TargetFunction.DefineTimelineActivityType]:
ManifestEntityKey.TimelineActivityTypes,
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 99fb7275b9c..33385aff5d0 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
@@ -113,7 +113,7 @@ const validateRelationFields = (fields: ManifestField[]): string[] => {
};
const collectPageLayoutWidgets = (
- manifest: Pick<Manifest, 'pageLayouts' | 'pageLayoutTabs'>,
+ manifest: Pick<Manifest, 'pageLayouts' | 'pageLayoutTabs' | 'pageLayoutWidgets'>,
): PageLayoutWidgetManifest[] => {
const widgetsFromPageLayouts = manifest.pageLayouts.flatMap(
(pageLayout) => pageLayout.tabs?.flatMap((tab) => tab.widgets ?? []) ?? [],
@@ -123,7 +123,11 @@ const collectPageLayoutWidgets = (
(tab) => tab.widgets ?? [],
);
- return [...widgetsFromPageLayouts, ...widgetsFromStandaloneTabs];
+ return [
+ ...widgetsFromPageLayouts,
+ ...widgetsFromStandaloneTabs,
+ ...(manifest.pageLayoutWidgets ?? []),
+ ];
};
const validateGraphWidgets = (
diff --git a/packages/twenty-sdk/src/cli/utilities/dev/orchestrator/dev-mode-orchestrator-state.ts b/packages/twenty-sdk/src/cli/utilities/dev/orchestrator/dev-mode-orchestrator-state.ts
index 392ec0ec426..68d9225e022 100644
--- a/packages/twenty-sdk/src/cli/utilities/dev/orchestrator/dev-mode-orchestrator-state.ts
+++ b/packages/twenty-sdk/src/cli/utilities/dev/orchestrator/dev-mode-orchestrator-state.ts
@@ -79,6 +79,7 @@ const ENTITY_TYPE_TO_SYNCABLE: Record<string, SyncableEntity | undefined> = {
navigationMenuItems: SyncableEntity.NavigationMenuItem,
pageLayouts: SyncableEntity.PageLayout,
pageLayoutTabs: SyncableEntity.PageLayoutTab,
+ pageLayoutWidgets: SyncableEntity.PageLayoutWidget,
commandMenuItems: SyncableEntity.CommandMenuItem,
timelineActivityTypes: SyncableEntity.TimelineActivityType,
};
diff --git a/packages/twenty-sdk/src/cli/utilities/dev/ui/dev-ui-constants.ts b/packages/twenty-sdk/src/cli/utilities/dev/ui/dev-ui-constants.ts
index 01b3a89e697..acf6406788f 100644
--- a/packages/twenty-sdk/src/cli/utilities/dev/ui/dev-ui-constants.ts
+++ b/packages/twenty-sdk/src/cli/utilities/dev/ui/dev-ui-constants.ts
@@ -95,6 +95,7 @@ export const ENTITY_LABELS: Record<SyncableEntity, string> = {
[SyncableEntity.NavigationMenuItem]: 'Navigation menu items',
[SyncableEntity.PageLayout]: 'Page layouts',
[SyncableEntity.PageLayoutTab]: 'Page layout tabs',
+ [SyncableEntity.PageLayoutWidget]: 'Page layout widgets',
[SyncableEntity.Agent]: 'Agents',
[SyncableEntity.ConnectionProvider]: 'Connection providers',
[SyncableEntity.TimelineActivityType]: 'Timeline activity types',
diff --git a/packages/twenty-sdk/src/cli/utilities/entity/__tests__/get-page-layout-widget-base-file.spec.ts b/packages/twenty-sdk/src/cli/utilities/entity/__tests__/get-page-layout-widget-base-file.spec.ts
new file mode 100644
index 00000000000..a254737301a
--- /dev/null
+++ b/packages/twenty-sdk/src/cli/utilities/entity/__tests__/get-page-layout-widget-base-file.spec.ts
@@ -0,0 +1,45 @@
+import { getPageLayoutWidgetBaseFile } from '@/cli/utilities/entity/entity-page-layout-widget-template';
+
+describe('getPageLayoutWidgetBaseFile', () => {
+ it('should render proper file using definePageLayoutWidget', () => {
+ const result = getPageLayoutWidgetBaseFile({
+ name: 'My Custom Widget',
+ });
+
+ expect(result).toContain('definePageLayoutWidget,');
+ expect(result).toContain("} from 'twenty-sdk/define';");
+ expect(result).toContain('export default definePageLayoutWidget({');
+ expect(result).toContain("title: 'My Custom Widget'");
+ expect(result).toContain('pageLayoutTabUniversalIdentifier:');
+ expect(result).toContain(
+ 'position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 1000 }',
+ );
+ expect(result).toContain("configurationType: 'IFRAME'");
+ });
+
+ it('should generate a valid UUID for the widget', () => {
+ const result = getPageLayoutWidgetBaseFile({
+ name: 'widget',
+ });
+
+ const uuidRegex =
+ /universalIdentifier: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'/g;
+ const matches = result.match(uuidRegex);
+
+ expect(matches).toHaveLength(1);
+ });
+
+ it('should generate unique UUIDs across calls', () => {
+ const result1 = getPageLayoutWidgetBaseFile({ name: 'widget-1' });
+ const result2 = getPageLayoutWidgetBaseFile({ name: 'widget-2' });
+
+ const uuidRegex =
+ /universalIdentifier: '([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})'/;
+ const uuid1 = result1.match(uuidRegex)?.[1];
+ const uuid2 = result2.match(uuidRegex)?.[1];
+
+ expect(uuid1).toBeDefined();
+ expect(uuid2).toBeDefined();
+ expect(uuid1).not.toBe(uuid2);
+ });
+});
diff --git a/packages/twenty-sdk/src/cli/utilities/entity/entity-page-layout-widget-template.ts b/packages/twenty-sdk/src/cli/utilities/entity/entity-page-layout-widget-template.ts
new file mode 100644
index 00000000000..30aadccf7ff
--- /dev/null
+++ b/packages/twenty-sdk/src/cli/utilities/entity/entity-page-layout-widget-template.ts
@@ -0,0 +1,21 @@
+import { v4 as uuidv4 } from 'uuid';
+
+export const getPageLayoutWidgetBaseFile = ({ name }: { name: string }) => {
+ return `import {
+ definePageLayoutWidget,
+ PageLayoutTabLayoutMode,
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS,
+} from 'twenty-sdk/define';
+
+export default definePageLayoutWidget({
+ universalIdentifier: '${uuidv4()}',
+ pageLayoutTabUniversalIdentifier:
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.companyRecordPage.tabs.home
+ .universalIdentifier,
+ title: '${name}',
+ type: 'IFRAME',
+ position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 1000 },
+ configuration: { configurationType: 'IFRAME', url: 'https://example.com' },
+});
+`;
+};
diff --git a/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts b/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts
index ab482c74d7f..f9bf8f1b515 100644
--- a/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts
+++ b/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts
@@ -102,6 +102,7 @@ describe('collectTranslatableStrings', () => {
pageLayoutTabs: [
{ title: 'Telemetry', widgets: [{ title: 'Trip log' }] },
],
+ pageLayoutWidgets: [{ title: 'Odometer' }],
commandMenuItems: [{ label: 'Launch Rocket', shortLabel: 'Launch' }],
navigationMenuItems: [{ name: 'Missions' }],
timelineActivityTypes: [{ label: 'Launched a rocket' }],
@@ -123,6 +124,7 @@ describe('collectTranslatableStrings', () => {
{ message: 'All Rockets', context: 'view.name' },
{ message: 'Telemetry', context: 'pageLayoutTab.title' },
{ message: 'Trip log', context: 'pageLayoutWidget.title' },
+ { message: 'Odometer', context: 'pageLayoutWidget.title' },
{ message: 'Launch Rocket', context: 'commandMenuItem.label' },
{ message: 'Launch', context: 'commandMenuItem.shortLabel' },
{ message: 'Missions', context: 'navigationMenuItem.name' },
diff --git a/packages/twenty-sdk/src/cli/utilities/translations/collect-translatable-strings.ts b/packages/twenty-sdk/src/cli/utilities/translations/collect-translatable-strings.ts
index 8e6217f2bdf..7f82ccd8007 100644
--- a/packages/twenty-sdk/src/cli/utilities/translations/collect-translatable-strings.ts
+++ b/packages/twenty-sdk/src/cli/utilities/translations/collect-translatable-strings.ts
@@ -17,6 +17,7 @@ const MANIFEST_KEY_BY_METADATA_NAME = {
view: 'views',
pageLayout: 'pageLayouts',
pageLayoutTab: 'pageLayoutTabs',
+ pageLayoutWidget: 'pageLayoutWidgets',
commandMenuItem: 'commandMenuItems',
navigationMenuItem: 'navigationMenuItems',
timelineActivityType: 'timelineActivityTypes',
diff --git a/packages/twenty-sdk/src/sdk/define/common/types/define-entity.type.ts b/packages/twenty-sdk/src/sdk/define/common/types/define-entity.type.ts
index b4e3dfc6634..582d0827993 100644
--- a/packages/twenty-sdk/src/sdk/define/common/types/define-entity.type.ts
+++ b/packages/twenty-sdk/src/sdk/define/common/types/define-entity.type.ts
@@ -18,6 +18,7 @@ import {
type FieldManifest,
type NavigationMenuItemManifest,
type SkillManifest,
+ type StandalonePageLayoutWidgetManifest,
type StandaloneViewFieldManifest,
} from 'twenty-shared/application';
@@ -47,6 +48,7 @@ export type DefinableEntity =
| NavigationMenuItemManifest
| PageLayoutConfig
| PageLayoutTabConfig
+ | StandalonePageLayoutWidgetManifest
| PermissionFlagConfig
| CommandMenuItemConfig;
diff --git a/packages/twenty-sdk/src/sdk/define/index.ts b/packages/twenty-sdk/src/sdk/define/index.ts
index 2ff08161b68..3b22e74098e 100644
--- a/packages/twenty-sdk/src/sdk/define/index.ts
+++ b/packages/twenty-sdk/src/sdk/define/index.ts
@@ -134,6 +134,7 @@ export type { TwentyRecord } from '@/sdk/define/objects/twenty-record.type';
export { definePageLayout } from '@/sdk/define/page-layouts/define-page-layout';
export { definePageLayoutTab } from '@/sdk/define/page-layouts/define-page-layout-tab';
+export { definePageLayoutWidget } from '@/sdk/define/page-layouts/define-page-layout-widget';
export type { PageLayoutConfig } from '@/sdk/define/page-layouts/page-layout-config';
export type { PageLayoutTabConfig } from '@/sdk/define/page-layouts/page-layout-tab-config';
export {
@@ -144,6 +145,7 @@ export type {
PageLayoutManifest,
PageLayoutTabManifest,
PageLayoutWidgetManifest,
+ StandalonePageLayoutWidgetManifest,
} from 'twenty-shared/application';
export { definePermissionFlag } from '@/sdk/define/permission-flags/define-permission-flag';
@@ -170,6 +172,8 @@ export { defineSkill } from '@/sdk/define/skills/define-skill';
export { defineView } from '@/sdk/define/views/define-view';
export { defineViewField } from '@/sdk/define/view-fields/define-view-field';
export {
+ getSystemPageLayoutTabUniversalIdentifier,
+ getSystemRecordPageLayoutUniversalIdentifier,
getSystemViewFieldUniversalIdentifier,
getSystemViewUniversalIdentifier,
SYSTEM_VIEW_KEYS,
diff --git a/packages/twenty-sdk/src/sdk/define/page-layouts/__tests__/define-page-layout-widget.spec.ts b/packages/twenty-sdk/src/sdk/define/page-layouts/__tests__/define-page-layout-widget.spec.ts
new file mode 100644
index 00000000000..dede82240ca
--- /dev/null
+++ b/packages/twenty-sdk/src/sdk/define/page-layouts/__tests__/define-page-layout-widget.spec.ts
@@ -0,0 +1,61 @@
+import { describe, expect, it } from 'vitest';
+
+import {
+ definePageLayoutWidget,
+ PageLayoutTabLayoutMode,
+ type StandalonePageLayoutWidgetManifest,
+} from '@/sdk/define';
+
+const WIDGET_CONFIG: StandalonePageLayoutWidgetManifest = {
+ universalIdentifier: '11111111-1111-4111-8111-111111111111',
+ pageLayoutTabUniversalIdentifier: '22222222-2222-4222-8222-222222222222',
+ title: 'Docs',
+ type: 'IFRAME',
+ position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 1000 },
+ configuration: {
+ configurationType: 'IFRAME',
+ url: 'https://example.com/docs',
+ },
+};
+
+describe('definePageLayoutWidget', () => {
+ it('accepts a widget with a tab and a position', () => {
+ const result = definePageLayoutWidget(WIDGET_CONFIG);
+
+ expect(result.success).toBe(true);
+ expect(result.errors).toEqual([]);
+ });
+
+ it('rejects a widget without a tab or a position', () => {
+ const result = definePageLayoutWidget({
+ ...WIDGET_CONFIG,
+ pageLayoutTabUniversalIdentifier: '',
+ position:
+ undefined as unknown as StandalonePageLayoutWidgetManifest['position'],
+ });
+
+ expect(result.success).toBe(false);
+ expect(result.errors).toEqual([
+ 'PageLayoutWidget must have a pageLayoutTabUniversalIdentifier when defined standalone (use the universalIdentifier of the tab it is added to)',
+ 'PageLayoutWidget must have a position when defined standalone (its tab is not in the manifest, so the layout mode cannot be inferred)',
+ ]);
+ });
+
+ it('rejects invalid header command menu item references like the other page layout definers', () => {
+ const result = definePageLayoutWidget({
+ ...WIDGET_CONFIG,
+ type: 'FRONT_COMPONENT',
+ configuration: {
+ configurationType: 'FRONT_COMPONENT',
+ frontComponentUniversalIdentifier:
+ '33333333-3333-4333-8333-333333333333',
+ headerCommandMenuItemUniversalIdentifiers: ['not-a-uuid'],
+ },
+ });
+
+ expect(result.success).toBe(false);
+ expect(result.errors).toContain(
+ 'PageLayoutWidget header command menu item universalIdentifier "not-a-uuid" must be a UUID',
+ );
+ });
+});
diff --git a/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout-tab.ts b/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout-tab.ts
index 592919846c6..08dc0f50b8c 100644
--- a/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout-tab.ts
+++ b/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout-tab.ts
@@ -1,6 +1,7 @@
import { type DefineEntity } from '@/sdk/define/common/types/define-entity.type';
import { createValidationResult } from '@/sdk/define/common/utils/create-validation-result';
import { type PageLayoutTabConfig } from '@/sdk/define/page-layouts/page-layout-tab-config';
+import { validatePageLayoutWidget } from '@/sdk/define/page-layouts/validate-page-layout-widget';
export const definePageLayoutTab: DefineEntity<PageLayoutTabConfig> = (
config,
@@ -21,18 +22,8 @@ export const definePageLayoutTab: DefineEntity<PageLayoutTabConfig> = (
);
}
- if (config.widgets) {
- for (const widget of config.widgets) {
- if (!widget.universalIdentifier) {
- errors.push('PageLayoutWidget must have a universalIdentifier');
- }
- if (!widget.title) {
- errors.push('PageLayoutWidget must have a title');
- }
- if (!widget.type) {
- errors.push('PageLayoutWidget must have a type');
- }
- }
+ for (const widget of config.widgets ?? []) {
+ errors.push(...validatePageLayoutWidget(widget));
}
return createValidationResult({ config, errors });
diff --git a/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout-widget.ts b/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout-widget.ts
new file mode 100644
index 00000000000..fe3c62e8a76
--- /dev/null
+++ b/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout-widget.ts
@@ -0,0 +1,25 @@
+import { type StandalonePageLayoutWidgetManifest } from 'twenty-shared/application';
+
+import { type DefineEntity } from '@/sdk/define/common/types/define-entity.type';
+import { createValidationResult } from '@/sdk/define/common/utils/create-validation-result';
+import { validatePageLayoutWidget } from '@/sdk/define/page-layouts/validate-page-layout-widget';
+
+export const definePageLayoutWidget: DefineEntity<
+ StandalonePageLayoutWidgetManifest
+> = (config) => {
+ const errors = validatePageLayoutWidget(config);
+
+ if (!config.pageLayoutTabUniversalIdentifier) {
+ errors.push(
+ 'PageLayoutWidget must have a pageLayoutTabUniversalIdentifier when defined standalone (use the universalIdentifier of the tab it is added to)',
+ );
+ }
+
+ if (!config.position) {
+ errors.push(
+ 'PageLayoutWidget must have a position when defined standalone (its tab is not in the manifest, so the layout mode cannot be inferred)',
+ );
+ }
+
+ return createValidationResult({ config, errors });
+};
diff --git a/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout.ts b/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout.ts
index 610c33e7652..f4c23de1d8e 100644
--- a/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout.ts
+++ b/packages/twenty-sdk/src/sdk/define/page-layouts/define-page-layout.ts
@@ -1,8 +1,7 @@
import { type DefineEntity } from '@/sdk/define/common/types/define-entity.type';
import { createValidationResult } from '@/sdk/define/common/utils/create-validation-result';
-import { isValidPostgresUuid } from '@/sdk/define/common/utils/is-valid-postgres-uuid';
import { type PageLayoutConfig } from '@/sdk/define/page-layouts/page-layout-config';
-import { isDefined } from 'twenty-shared/utils';
+import { validatePageLayoutWidget } from '@/sdk/define/page-layouts/validate-page-layout-widget';
export const definePageLayout: DefineEntity<PageLayoutConfig> = (config) => {
const errors: string[] = [];
@@ -19,55 +18,16 @@ export const definePageLayout: DefineEntity<PageLayoutConfig> = (config) => {
errors.push('PageLayout must have a type');
}
- if (config.tabs) {
- for (const tab of config.tabs) {
- if (!tab.universalIdentifier) {
- errors.push('PageLayoutTab must have a universalIdentifier');
- }
- if (!tab.title) {
- errors.push('PageLayoutTab must have a title');
- }
-
- if (tab.widgets) {
- for (const widget of tab.widgets) {
- if (!widget.universalIdentifier) {
- errors.push('PageLayoutWidget must have a universalIdentifier');
- }
- if (!widget.title) {
- errors.push('PageLayoutWidget must have a title');
- }
- if (!widget.type) {
- errors.push('PageLayoutWidget must have a type');
- }
-
- if (
- widget.configuration.configurationType === 'FRONT_COMPONENT' &&
- isDefined(
- widget.configuration.headerCommandMenuItemUniversalIdentifiers,
- )
- ) {
- const headerCommandMenuItemUniversalIdentifiers =
- widget.configuration.headerCommandMenuItemUniversalIdentifiers;
-
- for (const universalIdentifier of headerCommandMenuItemUniversalIdentifiers) {
- if (!isValidPostgresUuid(universalIdentifier)) {
- errors.push(
- `PageLayoutWidget header command menu item universalIdentifier "${universalIdentifier}" must be a UUID`,
- );
- }
- }
+ for (const tab of config.tabs ?? []) {
+ if (!tab.universalIdentifier) {
+ errors.push('PageLayoutTab must have a universalIdentifier');
+ }
+ if (!tab.title) {
+ errors.push('PageLayoutTab must have a title');
+ }
- if (
- new Set(headerCommandMenuItemUniversalIdentifiers).size !==
- headerCommandMenuItemUniversalIdentifiers.length
- ) {
- errors.push(
- 'PageLayoutWidget header command menu item universalIdentifiers must be unique',
- );
- }
- }
- }
- }
+ for (const widget of tab.widgets ?? []) {
+ errors.push(...validatePageLayoutWidget(widget));
}
}
diff --git a/packages/twenty-sdk/src/sdk/define/page-layouts/validate-page-layout-widget.ts b/packages/twenty-sdk/src/sdk/define/page-layouts/validate-page-layout-widget.ts
new file mode 100644
index 00000000000..11d32817cf4
--- /dev/null
+++ b/packages/twenty-sdk/src/sdk/define/page-layouts/validate-page-layout-widget.ts
@@ -0,0 +1,49 @@
+import { type PageLayoutWidgetManifest } from 'twenty-shared/application';
+import { isDefined } from 'twenty-shared/utils';
+
+import { isValidPostgresUuid } from '@/sdk/define/common/utils/is-valid-postgres-uuid';
+
+export const validatePageLayoutWidget = (
+ widget: PageLayoutWidgetManifest,
+): string[] => {
+ const errors: string[] = [];
+
+ if (!widget.universalIdentifier) {
+ errors.push('PageLayoutWidget must have a universalIdentifier');
+ }
+
+ if (!widget.title) {
+ errors.push('PageLayoutWidget must have a title');
+ }
+
+ if (!widget.type) {
+ errors.push('PageLayoutWidget must have a type');
+ }
+
+ if (
+ widget.configuration?.configurationType === 'FRONT_COMPONENT' &&
+ isDefined(widget.configuration.headerCommandMenuItemUniversalIdentifiers)
+ ) {
+ const headerCommandMenuItemUniversalIdentifiers =
+ widget.configuration.headerCommandMenuItemUniversalIdentifiers;
+
+ for (const universalIdentifier of headerCommandMenuItemUniversalIdentifiers) {
+ if (!isValidPostgresUuid(universalIdentifier)) {
+ errors.push(
+ `PageLayoutWidget header command menu item universalIdentifier "${universalIdentifier}" must be a UUID`,
+ );
+ }
+ }
+
+ if (
+ new Set(headerCommandMenuItemUniversalIdentifiers).size !==
+ headerCommandMenuItemUniversalIdentifiers.length
+ ) {
+ errors.push(
+ 'PageLayoutWidget header command menu item universalIdentifiers must be unique',
+ );
+ }
+ }
+
+ return errors;
+};
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/application-manifest-migration.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/application-manifest-migration.service.ts
index 5f8f941f977..50ecba9c4b2 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/application-manifest-migration.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/application-manifest-migration.service.ts
@@ -82,6 +82,7 @@ export class ApplicationManifestMigrationService {
navigationMenuItems: [],
pageLayouts: [],
pageLayoutTabs: [],
+ pageLayoutWidgets: [],
commandMenuItems: [],
timelineActivityTypes: [],
};
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-standalone-page-layout-widget-manifest.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-standalone-page-layout-widget-manifest.util.ts
new file mode 100644
index 00000000000..bf25eef9fdb
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-standalone-page-layout-widget-manifest.util.ts
@@ -0,0 +1,25 @@
+import { type StandalonePageLayoutWidgetManifest } from 'twenty-shared/application';
+
+import { fromFlatPageLayoutWidgetToPageLayoutWidgetManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-page-layout-widget-manifest.util';
+import { type UniversalFlatPageLayoutWidget } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/types/universal-flat-page-layout-widget.type';
+
+export const fromFlatPageLayoutWidgetToStandalonePageLayoutWidgetManifest = ({
+ flatPageLayoutWidget,
+ position,
+}: {
+ flatPageLayoutWidget: UniversalFlatPageLayoutWidget;
+ position: StandalonePageLayoutWidgetManifest['position'];
+}): StandalonePageLayoutWidgetManifest => {
+ const { universalIdentifier, ...pageLayoutWidgetManifest } =
+ fromFlatPageLayoutWidgetToPageLayoutWidgetManifest({
+ flatPageLayoutWidget,
+ });
+
+ return {
+ universalIdentifier,
+ pageLayoutTabUniversalIdentifier:
+ flatPageLayoutWidget.pageLayoutTabUniversalIdentifier,
+ ...pageLayoutWidgetManifest,
+ position,
+ };
+};
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/services/application-manifest-export.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/services/application-manifest-export.service.ts
index f5dfccbe982..72535468227 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/services/application-manifest-export.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/services/application-manifest-export.service.ts
@@ -94,6 +94,7 @@ export class ApplicationManifestExportService {
const {
pageLayouts,
pageLayoutTabs,
+ pageLayoutWidgets,
coverage: pageLayoutsCoverage,
} = reconstructPageLayoutsManifest({
applicationAllFlatEntityMaps,
@@ -129,6 +130,7 @@ export class ApplicationManifestExportService {
viewFields,
navigationMenuItems: [],
pageLayouts,
+ pageLayoutWidgets,
pageLayoutTabs,
commandMenuItems: [],
timelineActivityTypes: [],
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 36b898105ce..dbdbe102cb5 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
@@ -615,6 +615,29 @@ export class ComputeApplicationManifestAllUniversalFlatEntityMapsService {
}
}
+ for (const pageLayoutWidgetManifest of manifest.pageLayoutWidgets ?? []) {
+ if (
+ !isDefined(pageLayoutWidgetManifest.pageLayoutTabUniversalIdentifier)
+ ) {
+ throw new Error(
+ `Top-level pageLayoutWidget "${pageLayoutWidgetManifest.universalIdentifier}" is missing required pageLayoutTabUniversalIdentifier`,
+ );
+ }
+
+ addUniversalFlatEntityToUniversalFlatEntityMapsThroughMutationOrThrow({
+ universalFlatEntity:
+ fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
+ pageLayoutWidgetManifest,
+ pageLayoutTabUniversalIdentifier:
+ pageLayoutWidgetManifest.pageLayoutTabUniversalIdentifier,
+ applicationUniversalIdentifier,
+ now,
+ }),
+ universalFlatEntityMapsToMutate:
+ allUniversalFlatEntityMaps.flatPageLayoutWidgetMaps,
+ });
+ }
+
for (const [key, applicationVariableManifest] of Object.entries(
manifest.application.applicationVariables ?? {},
)) {
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 896986d1059..b8bfb54d244 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
@@ -30,7 +30,7 @@ import { fromFlatIndexMetadataToIndexManifest } from 'src/engine/core-modules/ap
import { fromFlatObjectMetadataToObjectManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-object-metadata-to-object-manifest.util';
import { fromFlatPageLayoutTabToPageLayoutTabManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-tab-to-page-layout-tab-manifest.util';
import { fromFlatPageLayoutToPageLayoutManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-to-page-layout-manifest.util';
-import { fromFlatPageLayoutWidgetToPageLayoutWidgetManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-page-layout-widget-manifest.util';
+import { fromFlatPageLayoutWidgetToStandalonePageLayoutWidgetManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-standalone-page-layout-widget-manifest.util';
import { fromPageLayoutManifestToUniversalFlatPageLayout } from 'src/engine/core-modules/application/application-manifest/converters/from-page-layout-manifest-to-universal-flat-page-layout.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 { fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget } from 'src/engine/core-modules/application/application-manifest/converters/from-page-layout-widget-manifest-to-universal-flat-page-layout-widget.util';
@@ -431,7 +431,7 @@ const EXPORTED_KINDS: ExportedKind[] = [
{
metadataName: 'pageLayoutWidget',
emittedProperties: Object.keys(
- fromFlatPageLayoutWidgetToPageLayoutWidgetManifest({
+ fromFlatPageLayoutWidgetToStandalonePageLayoutWidgetManifest({
flatPageLayoutWidget:
fromPageLayoutWidgetManifestToUniversalFlatPageLayoutWidget({
pageLayoutWidgetManifest: PAGE_LAYOUT_WIDGET_MANIFEST,
@@ -440,6 +440,10 @@ const EXPORTED_KINDS: ExportedKind[] = [
applicationUniversalIdentifier: APP_UID,
now: NOW,
}),
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 0,
+ },
}),
),
renamedProperties: {
@@ -449,8 +453,6 @@ const EXPORTED_KINDS: ExportedKind[] = [
workspaceLocalProperties: ['isActive', 'universalOverrides'],
knownGaps: {
...PAGE_LAYOUT_KIND_GAPS,
- pageLayoutTabUniversalIdentifier:
- 'a widget is written under its tab; there is no standalone widget slot',
conditionalAvailabilityExpression:
'no manifest slot; a widget carrying one is reported as unsupported',
},
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 44729990f1e..d00ccf2259f 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
@@ -2,6 +2,7 @@ import {
type PageLayoutManifest,
type PageLayoutTabManifest,
type PageLayoutWidgetManifest,
+ TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER,
} from 'twenty-shared/application';
import {
AggregateOperations,
@@ -50,6 +51,7 @@ const OVERVIEW_TAB_UID = 'cccccccc-cccc-4ccc-8ccc-cccccccccccc';
const ENGINE_TAB_UID = 'dddddddd-dddd-4ddd-8ddd-dddddddddddd';
const EXTRA_TAB_UID = 'eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee';
const COMPANY_TAB_UID = 'ffffffff-ffff-4fff-8fff-ffffffffffff';
+const COMPANY_HOME_TAB_UID = '12121212-1212-4121-8121-121212121212';
const EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS = new Set([PET_UID]);
const UNKNOWN_REFERENCE: Record<string, string> = {
workflowUniversalIdentifier: MISSING_UID,
@@ -171,13 +173,6 @@ const frontComponent: FlatFrontComponent = {
applicationId: APP_ID,
};
-const allFlatEntityMaps = buildMaps({
- objects: [petObject],
- fields: [nameField],
- views: [allPetsView],
- frontComponents: [frontComponent],
-});
-
const buildFlatPageLayout = ({
pageLayoutManifest,
...flatPageLayoutProperties
@@ -248,6 +243,72 @@ const buildFlatPageLayoutWidget = ({
...flatPageLayoutWidgetProperties,
});
+const companyPage = buildFlatPageLayout({
+ pageLayoutManifest: {
+ universalIdentifier: COMPANY_PAGE_UID,
+ name: 'Default Company Layout',
+ type: 'RECORD_PAGE',
+ },
+ applicationUniversalIdentifier:
+ TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER,
+ isSystemSideEffect: true,
+});
+
+const companyHomeTab = buildFlatPageLayoutTab({
+ pageLayoutTabManifest: {
+ universalIdentifier: COMPANY_HOME_TAB_UID,
+ title: 'Home',
+ position: 10,
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ },
+ pageLayoutUniversalIdentifier: COMPANY_PAGE_UID,
+ applicationUniversalIdentifier:
+ TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER,
+ isSystemSideEffect: true,
+});
+
+const allFlatEntityMaps = buildMaps({
+ objects: [petObject],
+ fields: [nameField],
+ views: [allPetsView],
+ frontComponents: [frontComponent],
+ pageLayouts: [companyPage],
+ pageLayoutTabs: [companyHomeTab],
+});
+
+const includingApplicationLayouts = (
+ applicationAllFlatEntityMaps: AllFlatEntityMaps,
+): AllFlatEntityMaps => ({
+ ...allFlatEntityMaps,
+ flatPageLayoutMaps: addAllFlatEntitiesToFlatEntityMaps({
+ flatEntities: Object.values(
+ applicationAllFlatEntityMaps.flatPageLayoutMaps.byUniversalIdentifier,
+ ).filter(isDefined),
+ flatEntityMaps: allFlatEntityMaps.flatPageLayoutMaps,
+ }),
+ flatPageLayoutTabMaps: addAllFlatEntitiesToFlatEntityMaps({
+ flatEntities: Object.values(
+ applicationAllFlatEntityMaps.flatPageLayoutTabMaps.byUniversalIdentifier,
+ ).filter(isDefined),
+ flatEntityMaps: allFlatEntityMaps.flatPageLayoutTabMaps,
+ }),
+});
+
+const reconstruct = ({
+ applicationAllFlatEntityMaps,
+ exportedObjectUniversalIdentifiers = EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS,
+}: {
+ applicationAllFlatEntityMaps: AllFlatEntityMaps;
+ exportedObjectUniversalIdentifiers?: Set<string>;
+}) =>
+ reconstructPageLayoutsManifest({
+ applicationAllFlatEntityMaps,
+ allFlatEntityMaps: includingApplicationLayouts(
+ applicationAllFlatEntityMaps,
+ ),
+ exportedObjectUniversalIdentifiers,
+ });
+
const PET_PAGE_MANIFEST: PageLayoutManifest = {
universalIdentifier: PET_PAGE_UID,
name: 'Pet page',
@@ -314,8 +375,8 @@ const reasonOf = (
describe('reconstructPageLayoutsManifest', () => {
it('should nest tabs and widgets under an exported page layout and order every collection by universal identifier', () => {
- const { pageLayouts, pageLayoutTabs, coverage } =
- reconstructPageLayoutsManifest({
+ const { pageLayouts, pageLayoutTabs, pageLayoutWidgets, coverage } =
+ reconstruct({
applicationAllFlatEntityMaps: buildMaps({
objects: [petObject],
pageLayouts: [
@@ -343,9 +404,6 @@ describe('reconstructPageLayoutsManifest', () => {
}),
],
}),
- allFlatEntityMaps,
- exportedObjectUniversalIdentifiers:
- EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS,
});
expect(pageLayouts).toEqual([
@@ -364,6 +422,7 @@ describe('reconstructPageLayoutsManifest', () => {
},
]);
expect(pageLayoutTabs).toEqual([]);
+ expect(pageLayoutWidgets).toEqual([]);
expect(coverage).toHaveLength(5);
expect(
coverage.every(
@@ -372,9 +431,9 @@ describe('reconstructPageLayoutsManifest', () => {
).toBe(true);
});
- it('should hide an engine-derived page layout, export a tab added to it standalone with its widgets, and refuse a widget added to an engine-derived tab', () => {
- const { pageLayouts, pageLayoutTabs, coverage } =
- reconstructPageLayoutsManifest({
+ it('should hide an engine-derived page layout, export a tab added to it standalone with its widgets, and export a widget added to an engine-derived tab standalone', () => {
+ const { pageLayouts, pageLayoutTabs, pageLayoutWidgets, coverage } =
+ reconstruct({
applicationAllFlatEntityMaps: buildMaps({
objects: [petObject],
pageLayouts: [
@@ -416,9 +475,6 @@ describe('reconstructPageLayoutsManifest', () => {
}),
],
}),
- allFlatEntityMaps,
- exportedObjectUniversalIdentifiers:
- EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS,
});
expect(pageLayouts).toEqual([]);
@@ -444,16 +500,19 @@ describe('reconstructPageLayoutsManifest', () => {
expect(statusOf(coverage, 'extra-widget')?.status).toBe(
ApplicationExportCoverageStatus.EXPORTED,
);
- expect(statusOf(coverage, 'home-widget')).toEqual({
- metadataName: 'pageLayoutWidget',
- universalIdentifier: 'home-widget',
- status: ApplicationExportCoverageStatus.UNSUPPORTED,
- reason: 'page layout widget on an engine-derived page layout tab',
- });
+ expect(pageLayoutWidgets).toEqual([
+ {
+ ...buildNotesWidgetManifest('home-widget'),
+ pageLayoutTabUniversalIdentifier: ENGINE_TAB_UID,
+ },
+ ]);
+ expect(statusOf(coverage, 'home-widget')?.status).toBe(
+ ApplicationExportCoverageStatus.EXPORTED,
+ );
});
- it('should export a tab on a page layout outside the application standalone and refuse a widget on a tab outside the application', () => {
- const { pageLayoutTabs, coverage } = reconstructPageLayoutsManifest({
+ it('should export a tab on a page layout outside the application and a widget on a tab outside the application standalone, and refuse children whose parent does not exist', () => {
+ const { pageLayoutTabs, pageLayoutWidgets, coverage } = reconstruct({
applicationAllFlatEntityMaps: buildMaps({
objects: [petObject],
pageLayoutTabs: [
@@ -466,6 +525,14 @@ describe('reconstructPageLayoutsManifest', () => {
},
pageLayoutUniversalIdentifier: COMPANY_PAGE_UID,
}),
+ buildFlatPageLayoutTab({
+ pageLayoutTabManifest: {
+ universalIdentifier: 'orphan-tab',
+ title: 'Orphan',
+ position: 70,
+ },
+ pageLayoutUniversalIdentifier: 'missing-page',
+ }),
],
pageLayoutWidgets: [
buildFlatPageLayoutWidget({
@@ -478,10 +545,12 @@ describe('reconstructPageLayoutsManifest', () => {
buildNotesWidgetManifest('foreign-widget'),
pageLayoutTabUniversalIdentifier: 'foreign-tab',
}),
+ buildFlatPageLayoutWidget({
+ pageLayoutWidgetManifest: buildNotesWidgetManifest('home-widget'),
+ pageLayoutTabUniversalIdentifier: COMPANY_HOME_TAB_UID,
+ }),
],
}),
- allFlatEntityMaps,
- exportedObjectUniversalIdentifiers: EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS,
});
expect(
@@ -496,43 +565,48 @@ describe('reconstructPageLayoutsManifest', () => {
expect(statusOf(coverage, 'company-widget')?.status).toBe(
ApplicationExportCoverageStatus.EXPORTED,
);
+ expect(pageLayoutWidgets).toEqual([
+ {
+ ...buildNotesWidgetManifest('home-widget'),
+ pageLayoutTabUniversalIdentifier: COMPANY_HOME_TAB_UID,
+ },
+ ]);
expect(reasonOf(coverage, 'foreign-widget')).toBe(
- 'page layout widget on a page layout tab outside the application',
+ 'page layout widget on a page layout tab that does not exist',
+ );
+ expect(reasonOf(coverage, 'orphan-tab')).toBe(
+ 'page layout tab on a page layout that does not exist',
);
});
it('should refuse an unsupported page layout together with its tab and widget', () => {
- const { pageLayouts, pageLayoutTabs, coverage } =
- reconstructPageLayoutsManifest({
- applicationAllFlatEntityMaps: buildMaps({
- objects: [petObject],
- pageLayouts: [
- buildFlatPageLayout({
- pageLayoutManifest: {
- ...PET_PAGE_MANIFEST,
- universalIdentifier: NAMELESS_PAGE_UID,
- name: '',
- },
- }),
- ],
- pageLayoutTabs: [
- buildFlatPageLayoutTab({
- pageLayoutTabManifest: OVERVIEW_TAB_MANIFEST,
- pageLayoutUniversalIdentifier: NAMELESS_PAGE_UID,
- }),
- ],
- pageLayoutWidgets: [
- buildFlatPageLayoutWidget({
- pageLayoutWidgetManifest:
- buildNotesWidgetManifest('nameless-widget'),
- pageLayoutTabUniversalIdentifier: OVERVIEW_TAB_UID,
- }),
- ],
- }),
- allFlatEntityMaps,
- exportedObjectUniversalIdentifiers:
- EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS,
- });
+ const { pageLayouts, pageLayoutTabs, coverage } = reconstruct({
+ applicationAllFlatEntityMaps: buildMaps({
+ objects: [petObject],
+ pageLayouts: [
+ buildFlatPageLayout({
+ pageLayoutManifest: {
+ ...PET_PAGE_MANIFEST,
+ universalIdentifier: NAMELESS_PAGE_UID,
+ name: '',
+ },
+ }),
+ ],
+ pageLayoutTabs: [
+ buildFlatPageLayoutTab({
+ pageLayoutTabManifest: OVERVIEW_TAB_MANIFEST,
+ pageLayoutUniversalIdentifier: NAMELESS_PAGE_UID,
+ }),
+ ],
+ pageLayoutWidgets: [
+ buildFlatPageLayoutWidget({
+ pageLayoutWidgetManifest:
+ buildNotesWidgetManifest('nameless-widget'),
+ pageLayoutTabUniversalIdentifier: OVERVIEW_TAB_UID,
+ }),
+ ],
+ }),
+ });
expect(pageLayouts).toEqual([]);
expect(pageLayoutTabs).toEqual([]);
@@ -548,7 +622,7 @@ describe('reconstructPageLayoutsManifest', () => {
});
it('should tell the page layout reasons apart', () => {
- const { coverage } = reconstructPageLayoutsManifest({
+ const { coverage } = reconstruct({
applicationAllFlatEntityMaps: buildMaps({
objects: [petObject],
pageLayouts: [
@@ -609,7 +683,6 @@ describe('reconstructPageLayoutsManifest', () => {
}),
],
}),
- allFlatEntityMaps,
exportedObjectUniversalIdentifiers: new Set<string>(),
});
@@ -630,8 +703,8 @@ describe('reconstructPageLayoutsManifest', () => {
);
});
- it('should order exported page layouts and standalone tabs by universal identifier', () => {
- const { pageLayouts, pageLayoutTabs } = reconstructPageLayoutsManifest({
+ it('should order exported page layouts, standalone tabs and standalone widgets by universal identifier', () => {
+ const { pageLayouts, pageLayoutTabs, pageLayoutWidgets } = reconstruct({
applicationAllFlatEntityMaps: buildMaps({
objects: [petObject],
pageLayouts: [
@@ -669,10 +742,28 @@ describe('reconstructPageLayoutsManifest', () => {
},
pageLayoutUniversalIdentifier: COMPANY_PAGE_UID,
}),
+ buildFlatPageLayoutTab({
+ pageLayoutTabManifest: {
+ universalIdentifier: ENGINE_TAB_UID,
+ title: 'Home',
+ position: 10,
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ },
+ pageLayoutUniversalIdentifier: ENGINE_PAGE_UID,
+ isSystemSideEffect: true,
+ }),
+ ],
+ pageLayoutWidgets: [
+ buildFlatPageLayoutWidget({
+ pageLayoutWidgetManifest: buildNotesWidgetManifest('z-widget'),
+ pageLayoutTabUniversalIdentifier: ENGINE_TAB_UID,
+ }),
+ buildFlatPageLayoutWidget({
+ pageLayoutWidgetManifest: buildNotesWidgetManifest('a-widget'),
+ pageLayoutTabUniversalIdentifier: ENGINE_TAB_UID,
+ }),
],
}),
- allFlatEntityMaps,
- exportedObjectUniversalIdentifiers: EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS,
});
expect(
@@ -681,10 +772,13 @@ describe('reconstructPageLayoutsManifest', () => {
expect(
pageLayoutTabs.map(({ universalIdentifier }) => universalIdentifier),
).toEqual(['a-tab', 'z-tab']);
+ expect(
+ pageLayoutWidgets.map(({ universalIdentifier }) => universalIdentifier),
+ ).toEqual(['a-widget', 'z-widget']);
});
it('should refuse the widgets the manifest cannot carry', () => {
- const { coverage } = reconstructPageLayoutsManifest({
+ const { coverage } = reconstruct({
applicationAllFlatEntityMaps: buildMaps({
objects: [
petObject,
@@ -836,8 +930,6 @@ describe('reconstructPageLayoutsManifest', () => {
}),
],
}),
- allFlatEntityMaps,
- exportedObjectUniversalIdentifiers: EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS,
});
expect(reasonOf(coverage, 'view-widget')).toBe(
@@ -932,15 +1024,13 @@ describe('reconstructPageLayoutsManifest', () => {
];
const rows = [...pageLayouts, ...pageLayoutTabs, ...pageLayoutWidgets];
- const { coverage } = reconstructPageLayoutsManifest({
+ const { coverage } = reconstruct({
applicationAllFlatEntityMaps: buildMaps({
objects: [petObject],
pageLayouts,
pageLayoutTabs,
pageLayoutWidgets,
}),
- allFlatEntityMaps,
- exportedObjectUniversalIdentifiers: EXPORTED_OBJECT_UNIVERSAL_IDENTIFIERS,
});
expect(coverage).toHaveLength(rows.length);
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/find-manifest-entity-descriptor-by-universal-identifier.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/find-manifest-entity-descriptor-by-universal-identifier.util.ts
index 7a723148df6..a06bf90357d 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/find-manifest-entity-descriptor-by-universal-identifier.util.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/find-manifest-entity-descriptor-by-universal-identifier.util.ts
@@ -117,6 +117,7 @@ export const MANIFEST_ENTITY_REGISTRY: Record<
pageLayoutWidget: {
entityKind: 'page layout widget',
getCandidates: (manifest) => [
+ ...toCandidates(manifest.pageLayoutWidgets, (widget) => widget.title),
...(manifest.pageLayoutTabs ?? []).flatMap((pageLayoutTab) =>
toCandidates(pageLayoutTab.widgets, (widget) => widget.title),
),
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/get-unsupported-page-layout-widget-reason.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/get-unsupported-page-layout-widget-reason.util.ts
index 23a0bea7a96..f775ddea33d 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/get-unsupported-page-layout-widget-reason.util.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/get-unsupported-page-layout-widget-reason.util.ts
@@ -179,7 +179,7 @@ export const getUnsupportedPageLayoutWidgetReason = ({
exportedObjectUniversalIdentifiers,
}: {
flatPageLayoutWidget: FlatPageLayoutWidget;
- flatPageLayoutTab: FlatPageLayoutTab | undefined;
+ flatPageLayoutTab: FlatPageLayoutTab;
applicationAllFlatEntityMaps: AllFlatEntityMaps;
allFlatEntityMaps: AllFlatEntityMaps;
exportedObjectUniversalIdentifiers: ReadonlySet<string>;
@@ -193,7 +193,6 @@ export const getUnsupportedPageLayoutWidgetReason = ({
}
if (
- isDefined(flatPageLayoutTab) &&
flatPageLayoutWidget.position.layoutMode !== flatPageLayoutTab.layoutMode
) {
return 'page layout widget positioned for another layout mode than its tab';
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/reconstruct-page-layouts-manifest.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/reconstruct-page-layouts-manifest.util.ts
index b2fc5eb02b0..5f92b7273f5 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/reconstruct-page-layouts-manifest.util.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/reconstruct-page-layouts-manifest.util.ts
@@ -2,6 +2,7 @@ import {
type PageLayoutManifest,
type PageLayoutTabManifest,
type PageLayoutWidgetManifest,
+ type StandalonePageLayoutWidgetManifest,
} from 'twenty-shared/application';
import { isDefined } from 'twenty-shared/utils';
@@ -9,6 +10,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 { fromFlatPageLayoutToPageLayoutManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-to-page-layout-manifest.util';
import { fromFlatPageLayoutWidgetToPageLayoutWidgetManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-page-layout-widget-manifest.util';
+import { fromFlatPageLayoutWidgetToStandalonePageLayoutWidgetManifest } from 'src/engine/core-modules/application/application-manifest/converters/from-flat-page-layout-widget-to-standalone-page-layout-widget-manifest.util';
import { type ApplicationExportCoverageEntry } from 'src/engine/core-modules/application/application-manifest/types/application-export.type';
import { type ParentStatus } from 'src/engine/core-modules/application/application-manifest/types/export-classification.type';
import { buildExportedCoverageEntry } from 'src/engine/core-modules/application/application-manifest/utils/build-exported-coverage-entry.util';
@@ -42,6 +44,7 @@ export const reconstructPageLayoutsManifest = ({
}): {
pageLayouts: PageLayoutManifest[];
pageLayoutTabs: PageLayoutTabManifest[];
+ pageLayoutWidgets: StandalonePageLayoutWidgetManifest[];
coverage: ApplicationExportCoverageEntry[];
} => {
const coverage: ApplicationExportCoverageEntry[] = [];
@@ -113,6 +116,13 @@ export const reconstructPageLayoutsManifest = ({
metadataName: 'pageLayoutTab',
flatEntity: flatPageLayoutTab,
isEngineDerived: flatPageLayoutTab.isSystemSideEffect,
+ unsupportedReason: isDefined(
+ allFlatEntityMaps.flatPageLayoutMaps.byUniversalIdentifier[
+ flatPageLayoutTab.pageLayoutUniversalIdentifier
+ ],
+ )
+ ? undefined
+ : 'page layout tab on a page layout that does not exist',
canStandAlone: true,
});
@@ -143,28 +153,32 @@ export const reconstructPageLayoutsManifest = ({
string,
PageLayoutWidgetManifest[]
>();
+ const pageLayoutWidgets: StandalonePageLayoutWidgetManifest[] = [];
for (const flatPageLayoutWidget of sortFlatEntitiesByUniversalIdentifier(
applicationAllFlatEntityMaps.flatPageLayoutWidgetMaps,
)) {
- if (
- decidePageLayoutWidget({
- metadataName: 'pageLayoutWidget',
- flatEntity: flatPageLayoutWidget,
- isEngineDerived: flatPageLayoutWidget.isSystemSideEffect,
- unsupportedReason: getUnsupportedPageLayoutWidgetReason({
- flatPageLayoutWidget,
- flatPageLayoutTab:
- applicationAllFlatEntityMaps.flatPageLayoutTabMaps
- .byUniversalIdentifier[
- flatPageLayoutWidget.pageLayoutTabUniversalIdentifier
- ],
- applicationAllFlatEntityMaps,
- allFlatEntityMaps,
- exportedObjectUniversalIdentifiers,
- }),
- }) === 'nested'
- ) {
+ const flatPageLayoutTab =
+ allFlatEntityMaps.flatPageLayoutTabMaps.byUniversalIdentifier[
+ flatPageLayoutWidget.pageLayoutTabUniversalIdentifier
+ ];
+ const decision = decidePageLayoutWidget({
+ metadataName: 'pageLayoutWidget',
+ flatEntity: flatPageLayoutWidget,
+ isEngineDerived: flatPageLayoutWidget.isSystemSideEffect,
+ unsupportedReason: isDefined(flatPageLayoutTab)
+ ? getUnsupportedPageLayoutWidgetReason({
+ flatPageLayoutWidget,
+ flatPageLayoutTab,
+ applicationAllFlatEntityMaps,
+ allFlatEntityMaps,
+ exportedObjectUniversalIdentifiers,
+ })
+ : 'page layout widget on a page layout tab that does not exist',
+ canStandAlone: true,
+ });
+
+ if (decision === 'nested') {
const widgets =
widgetsByPageLayoutTabUniversalIdentifier.get(
flatPageLayoutWidget.pageLayoutTabUniversalIdentifier,
@@ -179,6 +193,16 @@ export const reconstructPageLayoutsManifest = ({
flatPageLayoutWidget.pageLayoutTabUniversalIdentifier,
widgets,
);
+ } else if (
+ decision === 'standalone' &&
+ isDefined(flatPageLayoutWidget.position)
+ ) {
+ pageLayoutWidgets.push(
+ fromFlatPageLayoutWidgetToStandalonePageLayoutWidgetManifest({
+ flatPageLayoutWidget,
+ position: flatPageLayoutWidget.position,
+ }),
+ );
}
}
@@ -231,5 +255,5 @@ export const reconstructPageLayoutsManifest = ({
}),
);
- return { pageLayouts, pageLayoutTabs, coverage };
+ return { pageLayouts, pageLayoutTabs, pageLayoutWidgets, coverage };
};
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/successful-export-application-data-model.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/successful-export-application-data-model.integration-spec.ts.snap
index ea5138f5131..6dbd9d3b10a 100644
--- a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/successful-export-application-data-model.integration-spec.ts.snap
+++ b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/successful-export-application-data-model.integration-spec.ts.snap
@@ -448,6 +448,12 @@ exports[`Application export - data model exports the whole application as a stab
"status": "EXPORTED",
"universalIdentifier": "<TICKET_RECORD_PAGE_EXTRA_NOTES_WIDGET>",
},
+ {
+ "metadataName": "pageLayoutWidget",
+ "reason": null,
+ "status": "EXPORTED",
+ "universalIdentifier": "<TICKET_RECORD_PAGE_HOME_DOCS_WIDGET>",
+ },
{
"metadataName": "pageLayoutWidget",
"reason": null,
@@ -906,6 +912,22 @@ exports[`Application export - data model exports the whole application as a stab
"universalIdentifier": "<STANDARD_COMPANY_RECORD_PAGE_TAGLINE_TAB>",
},
],
+ "pageLayoutWidgets": [
+ {
+ "configuration": {
+ "configurationType": "IFRAME",
+ "url": "https://example.com/tickets/docs",
+ },
+ "pageLayoutTabUniversalIdentifier": "<TICKET_RECORD_PAGE_TAB_Home>",
+ "position": {
+ "index": 1,
+ "layoutMode": "VERTICAL_LIST",
+ },
+ "title": "Docs",
+ "type": "IFRAME",
+ "universalIdentifier": "<TICKET_RECORD_PAGE_HOME_DOCS_WIDGET>",
+ },
+ ],
"pageLayouts": [
{
"defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier": "<TICKET_PAGE_OVERVIEW_TAB>",
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/app-distribution.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/app-distribution.integration-spec.ts
index 17295e5855c..3f48dcbe17f 100644
--- a/packages/twenty-server/test/integration/metadata/suites/application/app-distribution.integration-spec.ts
+++ b/packages/twenty-server/test/integration/metadata/suites/application/app-distribution.integration-spec.ts
@@ -71,6 +71,7 @@ const createValidManifest = (universalIdentifier: string) =>
navigationMenuItems: [],
pageLayouts: [],
pageLayoutTabs: [],
+ pageLayoutWidgets: [],
});
const insertRegistrationWithSource = async (
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/failing-install-application-validation-errors.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/failing-install-application-validation-errors.integration-spec.ts
index c6884ab3708..ec6020c4285 100644
--- a/packages/twenty-server/test/integration/metadata/suites/application/failing-install-application-validation-errors.integration-spec.ts
+++ b/packages/twenty-server/test/integration/metadata/suites/application/failing-install-application-validation-errors.integration-spec.ts
@@ -96,6 +96,7 @@ const buildManifestWithCrossEntityIdentifierConflict = (
navigationMenuItems: [],
pageLayouts: [],
pageLayoutTabs: [],
+ pageLayoutWidgets: [],
});
describe('Install application should return structured validation errors', () => {
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/marketplace-catalog-sync.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/marketplace-catalog-sync.integration-spec.ts
index 63eab28310e..f55ed9578f0 100644
--- a/packages/twenty-server/test/integration/metadata/suites/application/marketplace-catalog-sync.integration-spec.ts
+++ b/packages/twenty-server/test/integration/metadata/suites/application/marketplace-catalog-sync.integration-spec.ts
@@ -233,6 +233,7 @@ describe('Marketplace Catalog Sync (integration)', () => {
navigationMenuItems: [],
pageLayouts: [],
pageLayoutTabs: [],
+ pageLayoutWidgets: [],
commandMenuItems: [],
});
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/successful-export-application-data-model.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/successful-export-application-data-model.integration-spec.ts
index deeba2141c3..a5eb4ea52a8 100644
--- a/packages/twenty-server/test/integration/metadata/suites/application/successful-export-application-data-model.integration-spec.ts
+++ b/packages/twenty-server/test/integration/metadata/suites/application/successful-export-application-data-model.integration-spec.ts
@@ -26,6 +26,7 @@ import {
type ObjectManifest,
type PageLayoutManifest,
type PageLayoutTabManifest,
+ type StandalonePageLayoutWidgetManifest,
type StandaloneViewFieldManifest,
SYSTEM_VIEW_KEYS,
type TranslationsManifest,
@@ -83,6 +84,8 @@ const TICKET_RECORD_PAGE_EXTRA_NOTES_WIDGET_ID =
'7e3d1c2b-0026-4a7b-8c9d-0e1f2a3b4c5d';
const COMPANY_RECORD_PAGE_TAGLINE_TAB_ID =
'7e3d1c2b-0027-4a7b-8c9d-0e1f2a3b4c5d';
+const TICKET_RECORD_PAGE_HOME_DOCS_WIDGET_ID =
+ '7e3d1c2b-0028-4a7b-8c9d-0e1f2a3b4c5d';
const ENGINE_DERIVED_FIELD_NAMES = [
'id',
@@ -154,6 +157,10 @@ const buildIdentifierNames = (): Map<string, string> => {
COMPANY_RECORD_PAGE_TAGLINE_TAB_ID,
'STANDARD_COMPANY_RECORD_PAGE_TAGLINE_TAB',
],
+ [
+ TICKET_RECORD_PAGE_HOME_DOCS_WIDGET_ID,
+ 'TICKET_RECORD_PAGE_HOME_DOCS_WIDGET',
+ ],
[
getIndexFieldUniversalIdentifier({
applicationUniversalIdentifier: TEST_APP_ID,
@@ -661,6 +668,22 @@ const companyRecordPageTaglineTab: PageLayoutTabManifest = {
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
};
+const ticketRecordPageHomeDocsWidget: StandalonePageLayoutWidgetManifest = {
+ universalIdentifier: TICKET_RECORD_PAGE_HOME_DOCS_WIDGET_ID,
+ pageLayoutTabUniversalIdentifier: getSystemPageLayoutTabUniversalIdentifier({
+ objectMetadataApplicationUniversalIdentifier: TEST_APP_ID,
+ pageLayoutUniversalIdentifier: TICKET_RECORD_PAGE_LAYOUT_ID,
+ title: 'Home',
+ }),
+ title: 'Docs',
+ type: 'IFRAME',
+ position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index: 1 },
+ configuration: {
+ configurationType: 'IFRAME',
+ url: 'https://example.com/tickets/docs',
+ },
+};
+
const manifest = buildBaseManifest({
appId: TEST_APP_ID,
roleId: TEST_ROLE_ID,
@@ -684,6 +707,7 @@ const manifest = buildBaseManifest({
viewFields: [projectIndexViewField],
pageLayouts: [ticketPageLayout, ticketBoardLayout],
pageLayoutTabs: [ticketRecordPageExtraTab, companyRecordPageTaglineTab],
+ pageLayoutWidgets: [ticketRecordPageHomeDocsWidget],
},
});
@@ -835,6 +859,9 @@ describe('Application export - data model', () => {
expect(statusOf(TICKET_RECORD_PAGE_EXTRA_TAB_ID)).toBe(
ApplicationExportCoverageStatus.EXPORTED,
);
+ expect(statusOf(TICKET_RECORD_PAGE_HOME_DOCS_WIDGET_ID)).toBe(
+ ApplicationExportCoverageStatus.EXPORTED,
+ );
}, 60000);
it('round-trips the raw export through an additive dry-run sync without any action', async () => {
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-update-page-layout-widget.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-update-page-layout-widget.integration-spec.ts
new file mode 100644
index 00000000000..20aef7e063e
--- /dev/null
+++ b/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-update-page-layout-widget.integration-spec.ts
@@ -0,0 +1,232 @@
+import { buildBaseManifest } from 'test/integration/metadata/suites/application/utils/build-base-manifest.util';
+import { cleanupApplicationAndAppRegistration } from 'test/integration/metadata/suites/application/utils/cleanup-application-and-app-registration.util';
+import { setupApplicationForSync } from 'test/integration/metadata/suites/application/utils/setup-application-for-sync.util';
+import { syncApplication } from 'test/integration/metadata/suites/application/utils/sync-application.util';
+import { WIDGET_POSITION_GQL_FIELDS } from 'test/integration/metadata/suites/page-layout-widget/constants/widget-position-gql-fields.constant';
+import { findPageLayoutWidgets } from 'test/integration/metadata/suites/page-layout-widget/utils/find-page-layout-widgets.util';
+import {
+ type Manifest,
+ type StandalonePageLayoutWidgetManifest,
+} from 'twenty-shared/application';
+import { STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS } from 'twenty-shared/metadata';
+import { PageLayoutTabLayoutMode } from 'twenty-shared/types';
+import { v4 as uuidv4 } from 'uuid';
+
+const TEST_APP_ID = uuidv4();
+const TEST_ROLE_ID = uuidv4();
+const TEST_WIDGET_ID = uuidv4();
+
+const STANDARD_PERSON_HOME_TAB_UNIVERSAL_ID =
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.personRecordPage.tabs.home
+ .universalIdentifier;
+
+const PAGE_LAYOUT_WIDGET_GQL_FIELDS = `
+ id
+ universalIdentifier
+ applicationId
+ pageLayoutTabId
+ title
+ type
+ position {
+ ${WIDGET_POSITION_GQL_FIELDS}
+ }
+ configuration {
+ ... on TimelineConfiguration {
+ configurationType
+ }
+ }
+`;
+
+let testApplicationId: string;
+let standardPersonHomeTabId: string;
+
+const buildManifest = (
+ overrides?: Partial<Pick<Manifest, 'pageLayoutWidgets'>>,
+) =>
+ buildBaseManifest({
+ appId: TEST_APP_ID,
+ roleId: TEST_ROLE_ID,
+ overrides,
+ });
+
+const buildTimelineWidget = ({
+ title,
+ index,
+}: {
+ title: string;
+ index: number;
+}): StandalonePageLayoutWidgetManifest => ({
+ universalIdentifier: TEST_WIDGET_ID,
+ pageLayoutTabUniversalIdentifier: STANDARD_PERSON_HOME_TAB_UNIVERSAL_ID,
+ title,
+ type: 'TIMELINE',
+ position: { layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST, index },
+ configuration: { configurationType: 'TIMELINE' },
+});
+
+const findStandardPersonHomeTabWidgets = async () => {
+ const { data } = await findPageLayoutWidgets({
+ gqlFields: PAGE_LAYOUT_WIDGET_GQL_FIELDS,
+ expectToFail: false,
+ input: { pageLayoutTabId: standardPersonHomeTabId },
+ });
+
+ return data.getPageLayoutWidgets.filter(
+ (widget) => widget.applicationId === testApplicationId,
+ );
+};
+
+describe('Manifest update - page layout widgets (standalone)', () => {
+ beforeEach(async () => {
+ await setupApplicationForSync({
+ applicationUniversalIdentifier: TEST_APP_ID,
+ name: 'Test Application',
+ description:
+ 'App for testing standalone page layout widget manifest updates',
+ sourcePath: 'test-manifest-update-page-layout-widget',
+ });
+
+ const applicationRow = await globalThis.testDataSource.query(
+ `SELECT id FROM core."application" WHERE "universalIdentifier" = $1`,
+ [TEST_APP_ID],
+ );
+
+ testApplicationId = applicationRow[0].id;
+
+ const pageLayoutTabRow = await globalThis.testDataSource.query(
+ `SELECT id FROM core."pageLayoutTab" WHERE "universalIdentifier" = $1`,
+ [STANDARD_PERSON_HOME_TAB_UNIVERSAL_ID],
+ );
+
+ standardPersonHomeTabId = pageLayoutTabRow[0].id;
+ }, 60000);
+
+ afterEach(async () => {
+ await cleanupApplicationAndAppRegistration({
+ applicationUniversalIdentifier: TEST_APP_ID,
+ });
+ });
+
+ it('should attach a standalone widget to a standard page layout tab', async () => {
+ await syncApplication({
+ manifest: buildManifest({
+ pageLayoutWidgets: [
+ buildTimelineWidget({ title: 'Activity', index: 1000 }),
+ ],
+ }),
+ expectToFail: false,
+ });
+
+ const widgets = await findStandardPersonHomeTabWidgets();
+
+ expect(widgets).toHaveLength(1);
+ expect(widgets[0]).toMatchObject({
+ universalIdentifier: TEST_WIDGET_ID,
+ applicationId: testApplicationId,
+ pageLayoutTabId: standardPersonHomeTabId,
+ title: 'Activity',
+ type: 'TIMELINE',
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 1000,
+ },
+ configuration: { configurationType: 'TIMELINE' },
+ });
+ }, 60000);
+
+ it('should rename and reposition a standalone widget on second sync', async () => {
+ await syncApplication({
+ manifest: buildManifest({
+ pageLayoutWidgets: [
+ buildTimelineWidget({ title: 'Activity', index: 1000 }),
+ ],
+ }),
+ expectToFail: false,
+ });
+
+ const widgetsAfterFirstSync = await findStandardPersonHomeTabWidgets();
+
+ expect(widgetsAfterFirstSync).toHaveLength(1);
+
+ await syncApplication({
+ manifest: buildManifest({
+ pageLayoutWidgets: [
+ buildTimelineWidget({ title: 'Recent activity', index: 1500 }),
+ ],
+ }),
+ expectToFail: false,
+ });
+
+ const widgetsAfterSecondSync = await findStandardPersonHomeTabWidgets();
+
+ expect(widgetsAfterSecondSync).toHaveLength(1);
+ expect(widgetsAfterSecondSync[0]).toMatchObject({
+ id: widgetsAfterFirstSync[0].id,
+ title: 'Recent activity',
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ index: 1500,
+ },
+ });
+ }, 60000);
+
+ it('should delete a standalone widget when removed from manifest on second sync', async () => {
+ await syncApplication({
+ manifest: buildManifest({
+ pageLayoutWidgets: [
+ buildTimelineWidget({ title: 'Activity', index: 1000 }),
+ ],
+ }),
+ expectToFail: false,
+ });
+
+ expect(await findStandardPersonHomeTabWidgets()).toHaveLength(1);
+
+ await syncApplication({
+ manifest: buildManifest({ pageLayoutWidgets: [] }),
+ expectToFail: false,
+ });
+
+ expect(await findStandardPersonHomeTabWidgets()).toHaveLength(0);
+ }, 60000);
+
+ it('should fail to sync when a standalone widget references a non-existent tab', async () => {
+ const { errors } = await syncApplication({
+ manifest: buildManifest({
+ pageLayoutWidgets: [
+ {
+ ...buildTimelineWidget({ title: 'Activity', index: 1000 }),
+ pageLayoutTabUniversalIdentifier: uuidv4(),
+ },
+ ],
+ }),
+ expectToFail: true,
+ });
+
+ expect(errors).toBeDefined();
+ expect(errors?.length).toBeGreaterThan(0);
+ }, 60000);
+
+ it('should fail to sync when a standalone widget is positioned for another layout mode than its tab', async () => {
+ const { errors } = await syncApplication({
+ manifest: buildManifest({
+ pageLayoutWidgets: [
+ {
+ ...buildTimelineWidget({ title: 'Activity', index: 1000 }),
+ position: {
+ layoutMode: PageLayoutTabLayoutMode.GRID,
+ row: 0,
+ column: 0,
+ rowSpan: 4,
+ columnSpan: 4,
+ },
+ },
+ ],
+ }),
+ expectToFail: true,
+ });
+
+ expect(errors).toBeDefined();
+ expect(errors?.length).toBeGreaterThan(0);
+ }, 60000);
+});
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/utils/build-base-manifest.util.ts b/packages/twenty-server/test/integration/metadata/suites/application/utils/build-base-manifest.util.ts
index db083e030cc..b0801ba67ac 100644
--- a/packages/twenty-server/test/integration/metadata/suites/application/utils/build-base-manifest.util.ts
+++ b/packages/twenty-server/test/integration/metadata/suites/application/utils/build-base-manifest.util.ts
@@ -38,6 +38,7 @@ export const buildBaseManifest = ({
navigationMenuItems: [],
pageLayouts: [],
pageLayoutTabs: [],
+ pageLayoutWidgets: [],
commandMenuItems: [],
timelineActivityTypes: [],
...overrides,
diff --git a/packages/twenty-shared/src/application/enums/syncable-entities.enum.ts b/packages/twenty-shared/src/application/enums/syncable-entities.enum.ts
index 36f013cc6a0..ac696662b91 100644
--- a/packages/twenty-shared/src/application/enums/syncable-entities.enum.ts
+++ b/packages/twenty-shared/src/application/enums/syncable-entities.enum.ts
@@ -12,6 +12,7 @@ export enum SyncableEntity {
NavigationMenuItem = 'navigationMenuItem',
PageLayout = 'pageLayout',
PageLayoutTab = 'pageLayoutTab',
+ PageLayoutWidget = 'pageLayoutWidget',
CommandMenuItem = 'commandMenuItem',
TimelineActivityType = 'timelineActivityType',
}
diff --git a/packages/twenty-shared/src/application/index.ts b/packages/twenty-shared/src/application/index.ts
index 112b930ae87..35a04a41c97 100644
--- a/packages/twenty-shared/src/application/index.ts
+++ b/packages/twenty-shared/src/application/index.ts
@@ -154,6 +154,7 @@ export type { ObjectFieldManifest } from './objectFieldManifest.type';
export type { ObjectManifest } from './objectManifestType';
export type {
PageLayoutWidgetManifest,
+ StandalonePageLayoutWidgetManifest,
PageLayoutTabManifest,
PageLayoutManifest,
} from './pageLayoutManifestType';
diff --git a/packages/twenty-shared/src/application/manifestType.ts b/packages/twenty-shared/src/application/manifestType.ts
index b73b5b638e9..0f5c1bcd5bc 100644
--- a/packages/twenty-shared/src/application/manifestType.ts
+++ b/packages/twenty-shared/src/application/manifestType.ts
@@ -16,6 +16,7 @@ import { type ObjectManifest } from './objectManifestType';
import {
type PageLayoutManifest,
type PageLayoutTabManifest,
+ type StandalonePageLayoutWidgetManifest,
} from './pageLayoutManifestType';
import { type PermissionFlagManifest } from './permissionFlagManifestType';
import { type RoleManifest } from './roleManifestType';
@@ -48,6 +49,7 @@ export type Manifest = {
navigationMenuItems: NavigationMenuItemManifest[];
pageLayouts: PageLayoutManifest[];
pageLayoutTabs: PageLayoutTabManifest[];
+ pageLayoutWidgets: StandalonePageLayoutWidgetManifest[];
commandMenuItems: CommandMenuItemManifest[];
timelineActivityTypes: TimelineActivityTypeManifest[];
translations?: TranslationsManifest;
diff --git a/packages/twenty-shared/src/application/pageLayoutManifestType.ts b/packages/twenty-shared/src/application/pageLayoutManifestType.ts
index 1925e603de1..bbd928647ed 100644
--- a/packages/twenty-shared/src/application/pageLayoutManifestType.ts
+++ b/packages/twenty-shared/src/application/pageLayoutManifestType.ts
@@ -17,6 +17,11 @@ export type PageLayoutWidgetManifest = SyncableEntityOptions & {
configuration: PageLayoutWidgetUniversalConfiguration;
};
+export type StandalonePageLayoutWidgetManifest = PageLayoutWidgetManifest & {
+ pageLayoutTabUniversalIdentifier: string;
+ position: PageLayoutWidgetPosition;
+};
+
export type PageLayoutTabManifest = SyncableEntityOptions & {
title: string;
position: number;