Repair Edit Layout command menu item and add a button in settings to start edition too (#19208)

https://github.com/user-attachments/assets/f23f0777-abf3-4ff4-8fab-ec2004df60bc
This commit is contained in:
Baptiste Devessier
2026-04-01 17:24:05 +02:00
committed by GitHub
parent 9054d3aef6
commit 291792f864
11 changed files with 277 additions and 92 deletions
@@ -1,30 +1,14 @@
import { HeadlessEngineCommandWrapperEffect } from '@/command-menu-item/engine-command/components/HeadlessEngineCommandWrapperEffect';
import { useHeadlessCommandContextApi } from '@/command-menu-item/engine-command/hooks/useHeadlessCommandContextApi';
import { useRecordPageLayoutIdFromRecordStoreOrThrow } from '@/page-layout/hooks/useRecordPageLayoutIdFromRecordStoreOrThrow';
import { useSetIsPageLayoutInEditMode } from '@/page-layout/hooks/useSetIsPageLayoutInEditMode';
import { isDefined } from 'twenty-shared/utils';
import { useEnterLayoutCustomizationMode } from '@/layout-customization/hooks/useEnterLayoutCustomizationMode';
import { useResetLocationHash } from 'twenty-ui/utilities';
export const EditRecordPageLayoutSingleRecordCommand = () => {
const { objectMetadataItem } = useHeadlessCommandContextApi();
if (!isDefined(objectMetadataItem)) {
throw new Error(
'Object metadata item is required to edit record page layout',
);
}
const { pageLayoutId } = useRecordPageLayoutIdFromRecordStoreOrThrow({
targetObjectNameSingular: objectMetadataItem.nameSingular,
});
const { setIsPageLayoutInEditMode } =
useSetIsPageLayoutInEditMode(pageLayoutId);
const { enterLayoutCustomizationMode } = useEnterLayoutCustomizationMode();
const { resetLocationHash } = useResetLocationHash();
const handleExecute = () => {
setIsPageLayoutInEditMode(true);
enterLayoutCustomizationMode();
resetLocationHash();
};