Link command menu items to specific page layout (#19706)

- Add a `pageLayoutId` foreign key to `CommandMenuItem`, allowing
command menu items to be scoped to a specific page layout instead of
being globally available
- Filter command menu items by the current page layout on the frontend.
Items with a `pageLayoutId` only appear when viewing that layout, while
items without one remain globally visible
- Create an effect to track the current page layout ID
- Include a seed example: a "Show Notification" command pinned to the
Star history standalone page layout

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Raphaël Bosi
2026-04-16 14:07:36 +02:00
committed by GitHub
parent 7af82fb6a4
commit 2b5b8a8b13
39 changed files with 342 additions and 51 deletions
@@ -82,13 +82,15 @@ export const prefillFrontComponentCommandMenuItems = async ({
icon: definition.icon,
shortLabel: definition.label,
position: definition.position,
isPinned: false,
isPinned: definition.isPinned ?? false,
availabilityType: CommandMenuItemAvailabilityType.GLOBAL,
conditionalAvailabilityExpression: null,
availabilityObjectMetadataId: null,
availabilityObjectMetadataUniversalIdentifier: null,
payload: null,
hotKeys: null,
pageLayoutId: definition.pageLayoutId ?? null,
pageLayoutUniversalIdentifier: definition.pageLayoutId ?? null,
createdAt: now,
updatedAt: now,
};
@@ -1,5 +1,8 @@
import { v5 as uuidv5 } from 'uuid';
import { PAGE_LAYOUT_SEEDS } from 'src/engine/workspace-manager/dev-seeder/core/constants/page-layout-seeds.constant';
import { generateSeedId } from 'src/engine/workspace-manager/dev-seeder/core/utils/generate-seed-id.util';
const SEED_FRONT_COMPONENT_ID_NAMESPACE =
'e7a3b1c4-f5d6-4e8a-9b2c-3d4e5f6a7b8c';
@@ -20,6 +23,8 @@ export type SeedFrontComponentCommandMenuItemDefinition = {
label: string;
icon: string;
position: number;
isPinned?: boolean;
pageLayoutId?: string | null;
};
export const getSeedFrontComponentIds = (workspaceId: string) => ({
@@ -98,5 +103,20 @@ export const getSeedFrontComponentCommandMenuItemDefinitions = (
icon: 'IconBell',
position: 201,
},
{
universalIdentifier: uuidv5(
`${workspaceId}:seed-front-component-command:standalone-page-show-notification`,
SEED_FRONT_COMPONENT_ID_NAMESPACE,
),
frontComponentId: showNotificationId,
label: 'Show Notification',
icon: 'IconStar',
position: 202,
isPinned: true,
pageLayoutId: generateSeedId(
workspaceId,
PAGE_LAYOUT_SEEDS.DOCUMENTATION_STANDALONE_PAGE,
),
},
];
};
@@ -68,6 +68,8 @@ export const prefillWorkflowCommandMenuItems = async ({
availabilityObjectMetadataUniversalIdentifier: null,
payload: null,
hotKeys: null,
pageLayoutId: null,
pageLayoutUniversalIdentifier: null,
createdAt: now,
updatedAt: now,
};