Support more standard objects in Record Page Layout (#15288)
Used the `PageLayoutRenderer` for people, opportunities, tasks and notes. ## Demo https://github.com/user-attachments/assets/35e61702-f338-47b3-91b7-fd3951a0c967
This commit is contained in:
committed by
GitHub
parent
93ab1c4118
commit
9b2a73d50a
+38
-4
@@ -1,6 +1,16 @@
|
||||
import { FIND_ONE_PAGE_LAYOUT } from '@/dashboards/graphql/queries/findOnePageLayout';
|
||||
import { DEFAULT_PAGE_LAYOUT } from '@/page-layout/constants/DefaultPageLayout';
|
||||
import { DEFAULT_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultPageLayoutId';
|
||||
import { DEFAULT_COMPANY_RECORD_PAGE_LAYOUT } from '@/page-layout/constants/DefaultCompanyRecordPageLayout';
|
||||
import { DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultCompanyRecordPageLayoutId';
|
||||
import { DEFAULT_NOTE_RECORD_PAGE_LAYOUT } from '@/page-layout/constants/DefaultNoteRecordPageLayout';
|
||||
import { DEFAULT_NOTE_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultNoteRecordPageLayoutId';
|
||||
import { DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT } from '@/page-layout/constants/DefaultOpportunityRecordPageLayout';
|
||||
import { DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultOpportunityRecordPageLayoutId';
|
||||
import { DEFAULT_PERSON_RECORD_PAGE_LAYOUT } from '@/page-layout/constants/DefaultPersonRecordPageLayout';
|
||||
import { DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultPersonRecordPageLayoutId';
|
||||
import { DEFAULT_RECORD_PAGE_LAYOUT } from '@/page-layout/constants/DefaultRecordPageLayout';
|
||||
import { DEFAULT_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultRecordPageLayoutId';
|
||||
import { DEFAULT_TASK_RECORD_PAGE_LAYOUT } from '@/page-layout/constants/DefaultTaskRecordPageLayout';
|
||||
import { DEFAULT_TASK_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultTaskRecordPageLayoutId';
|
||||
import { pageLayoutCurrentLayoutsComponentState } from '@/page-layout/states/pageLayoutCurrentLayoutsComponentState';
|
||||
import { pageLayoutDraftComponentState } from '@/page-layout/states/pageLayoutDraftComponentState';
|
||||
import { pageLayoutPersistedComponentState } from '@/page-layout/states/pageLayoutPersistedComponentState';
|
||||
@@ -15,6 +25,24 @@ import { useRecoilCallback } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
|
||||
const getDefaultLayoutById = (layoutId: string): PageLayout => {
|
||||
switch (layoutId) {
|
||||
case DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID:
|
||||
return DEFAULT_COMPANY_RECORD_PAGE_LAYOUT;
|
||||
case DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID:
|
||||
return DEFAULT_PERSON_RECORD_PAGE_LAYOUT;
|
||||
case DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID:
|
||||
return DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT;
|
||||
case DEFAULT_NOTE_RECORD_PAGE_LAYOUT_ID:
|
||||
return DEFAULT_NOTE_RECORD_PAGE_LAYOUT;
|
||||
case DEFAULT_TASK_RECORD_PAGE_LAYOUT_ID:
|
||||
return DEFAULT_TASK_RECORD_PAGE_LAYOUT;
|
||||
case DEFAULT_RECORD_PAGE_LAYOUT_ID:
|
||||
default:
|
||||
return DEFAULT_RECORD_PAGE_LAYOUT;
|
||||
}
|
||||
};
|
||||
|
||||
type PageLayoutInitializationQueryEffectProps = {
|
||||
pageLayoutId: string;
|
||||
onInitialized?: (pageLayout: PageLayout) => void;
|
||||
@@ -26,7 +54,13 @@ export const PageLayoutInitializationQueryEffect = ({
|
||||
}: PageLayoutInitializationQueryEffectProps) => {
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
|
||||
const isDefaultLayout = pageLayoutId === DEFAULT_PAGE_LAYOUT_ID;
|
||||
const isDefaultLayout =
|
||||
pageLayoutId === DEFAULT_RECORD_PAGE_LAYOUT_ID ||
|
||||
pageLayoutId === DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID ||
|
||||
pageLayoutId === DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID ||
|
||||
pageLayoutId === DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID ||
|
||||
pageLayoutId === DEFAULT_NOTE_RECORD_PAGE_LAYOUT_ID ||
|
||||
pageLayoutId === DEFAULT_TASK_RECORD_PAGE_LAYOUT_ID;
|
||||
|
||||
const { data } = useQuery(FIND_ONE_PAGE_LAYOUT, {
|
||||
variables: {
|
||||
@@ -36,7 +70,7 @@ export const PageLayoutInitializationQueryEffect = ({
|
||||
});
|
||||
|
||||
const pageLayout: PageLayout | undefined = isDefaultLayout
|
||||
? DEFAULT_PAGE_LAYOUT
|
||||
? getDefaultLayoutById(pageLayoutId)
|
||||
: data?.getPageLayout
|
||||
? transformPageLayout(data.getPageLayout)
|
||||
: undefined;
|
||||
|
||||
Reference in New Issue
Block a user