Reset Tab Page Layout (#19453)

## Context
- Add "Reset to default" for page layout tabs and widgets — backend
mutation resets overrides, reactivates deactivated children, and deletes
custom children
- Fix override write bug where mutating an overridable property (e.g.
widget title) on a standard-app entity incorrectly overwrote the base
column instead of writing to the overrides JSONB —
PageLayoutUpdateService now uses resolveFlatEntityOverridableProperties
for accurate diffing and routes properties through
sanitizeOverridableEntityInput
- Deprecate isOverridden - We need more time to think about this
feature. Currently this adds too much complexity for a very small
benefit



https://github.com/user-attachments/assets/a84546c8-1e15-4d9e-a489-0825cf8b8ed2
This commit is contained in:
Weiko
2026-04-08 18:43:57 +02:00
committed by GitHub
parent 2267c56f15
commit 238018dc7b
94 changed files with 1000 additions and 619 deletions
@@ -68,7 +68,6 @@ const mixedGraphsPageLayoutMocks = {
title: 'Mixed Graphs',
position: 0,
pageLayoutId: 'mixed-graphs-layout',
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -93,7 +92,6 @@ const mixedGraphsPageLayoutMocks = {
aggregateOperation: AggregateOperations.COUNT,
aggregateFieldMetadataId: idField.id,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -119,7 +117,6 @@ const mixedGraphsPageLayoutMocks = {
aggregateFieldMetadataId: idField.id,
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -146,7 +143,6 @@ const mixedGraphsPageLayoutMocks = {
groupByFieldMetadataId: createdAtField.id,
orderBy: GraphOrderBy.VALUE_DESC,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -176,7 +172,6 @@ const mixedGraphsPageLayoutMocks = {
axisNameDisplay: AxisNameDisplay.BOTH,
displayDataLabel: false,
} satisfies BarChartConfiguration,
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -30,7 +30,6 @@ const createInitialTabs = (): PageLayoutTab[] => [
icon: 'IconPlus',
pageLayoutId: 'test-layout',
widgets: [],
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -43,7 +42,6 @@ const createInitialTabs = (): PageLayoutTab[] => [
position: 1,
pageLayoutId: 'test-layout',
widgets: [],
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -56,7 +54,6 @@ const createInitialTabs = (): PageLayoutTab[] => [
position: 2,
pageLayoutId: 'test-layout',
widgets: [],
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -86,7 +83,6 @@ const PageLayoutTabListPlayground = ({
position: nextIndex,
pageLayoutId: 'test-layout',
widgets: [],
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -26,7 +26,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -50,7 +49,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -66,7 +64,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 200,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -90,7 +87,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -106,7 +102,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 300,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -130,7 +125,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -146,7 +140,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 400,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -170,7 +163,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -186,7 +178,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 500,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -210,7 +201,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -226,7 +216,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 600,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -250,7 +239,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -266,7 +254,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 700,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_COMPANY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -290,7 +277,6 @@ export const DEFAULT_COMPANY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -26,7 +26,6 @@ export const DEFAULT_MESSAGE_THREAD_RECORD_PAGE_LAYOUT: PageLayout = {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: DEFAULT_MESSAGE_THREAD_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -50,7 +49,6 @@ export const DEFAULT_MESSAGE_THREAD_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -26,7 +26,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: DEFAULT_NOTE_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -53,7 +52,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -77,7 +75,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -100,7 +97,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
position: 150,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_NOTE_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -124,7 +120,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -147,7 +142,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
position: 200,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_NOTE_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -171,7 +165,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -187,7 +180,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
position: 300,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_NOTE_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -211,7 +203,6 @@ export const DEFAULT_NOTE_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -26,7 +26,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -50,7 +49,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -66,7 +64,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 200,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -90,7 +87,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -106,7 +102,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 300,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -130,7 +125,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -146,7 +140,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 400,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -170,7 +163,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -186,7 +178,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 500,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -210,7 +201,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -226,7 +216,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 600,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -250,7 +239,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -266,7 +254,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
position: 700,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -290,7 +277,6 @@ export const DEFAULT_OPPORTUNITY_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -26,7 +26,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -50,7 +49,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -66,7 +64,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
position: 200,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -90,7 +87,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -106,7 +102,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
position: 300,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -130,7 +125,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -146,7 +140,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
position: 400,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -170,7 +163,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -186,7 +178,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
position: 500,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -210,7 +201,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -226,7 +216,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
position: 600,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -250,7 +239,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -266,7 +254,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
position: 700,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_PERSON_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -290,7 +277,6 @@ export const DEFAULT_PERSON_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -26,7 +26,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: DEFAULT_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -50,7 +49,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -66,7 +64,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
position: 200,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -90,7 +87,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -106,7 +102,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
position: 300,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -130,7 +125,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -146,7 +140,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
position: 400,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -170,7 +163,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -186,7 +178,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
position: 500,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -210,7 +201,6 @@ export const DEFAULT_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -26,7 +26,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: DEFAULT_TASK_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -50,7 +49,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -74,7 +72,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -97,7 +94,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
position: 150,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_TASK_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -121,7 +117,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -144,7 +139,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
position: 200,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_TASK_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -168,7 +162,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -184,7 +177,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
position: 300,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_TASK_RECORD_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -208,7 +200,6 @@ export const DEFAULT_TASK_RECORD_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -31,7 +31,6 @@ export const DEFAULT_WORKFLOW_PAGE_LAYOUT: PageLayout = {
layoutMode: PageLayoutTabLayoutMode.CANVAS,
icon: 'IconSettings',
pageLayoutId: DEFAULT_WORKFLOW_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -55,7 +54,6 @@ export const DEFAULT_WORKFLOW_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -32,7 +32,6 @@ export const DEFAULT_WORKFLOW_RUN_PAGE_LAYOUT: PageLayout = {
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
icon: 'IconHome',
pageLayoutId: DEFAULT_WORKFLOW_RUN_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -56,7 +55,6 @@ export const DEFAULT_WORKFLOW_RUN_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -73,7 +71,6 @@ export const DEFAULT_WORKFLOW_RUN_PAGE_LAYOUT: PageLayout = {
layoutMode: PageLayoutTabLayoutMode.CANVAS,
icon: 'IconSettings',
pageLayoutId: DEFAULT_WORKFLOW_RUN_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -97,7 +94,6 @@ export const DEFAULT_WORKFLOW_RUN_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -32,7 +32,6 @@ export const DEFAULT_WORKFLOW_VERSION_PAGE_LAYOUT: PageLayout = {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: DEFAULT_WORKFLOW_VERSION_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -56,7 +55,6 @@ export const DEFAULT_WORKFLOW_VERSION_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -73,7 +71,6 @@ export const DEFAULT_WORKFLOW_VERSION_PAGE_LAYOUT: PageLayout = {
position: 200,
layoutMode: PageLayoutTabLayoutMode.CANVAS,
pageLayoutId: DEFAULT_WORKFLOW_VERSION_PAGE_LAYOUT_ID,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -97,7 +94,6 @@ export const DEFAULT_WORKFLOW_VERSION_PAGE_LAYOUT: PageLayout = {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -6,7 +6,6 @@ export const PAGE_LAYOUT_WIDGET_FRAGMENT = gql`
title
type
objectMetadataId
isOverridden
createdAt
updatedAt
deletedAt
@@ -0,0 +1,12 @@
import { gql } from '@apollo/client';
import { PAGE_LAYOUT_TAB_FRAGMENT } from '@/dashboards/graphql/fragments/pageLayoutTabFragment';
export const RESET_PAGE_LAYOUT_TAB_TO_DEFAULT = gql`
${PAGE_LAYOUT_TAB_FRAGMENT}
mutation ResetPageLayoutTabToDefault($id: String!) {
resetPageLayoutTabToDefault(id: $id) {
...PageLayoutTabFragment
}
}
`;
@@ -25,7 +25,6 @@ const makeWidget = (
pageLayoutTabId: tabId,
title: id,
type: WidgetType.FIELDS,
isOverridden: false,
gridPosition: { column: 0, columnSpan: 1, row: 0, rowSpan: 1 },
configuration: { __typename: 'FieldsConfiguration' as const },
position: {
@@ -51,7 +50,6 @@ const makeTab = (
layoutMode,
pageLayoutId: '',
widgets,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -25,7 +25,6 @@ const makeWidget = (
pageLayoutTabId: tabId,
title: id,
type: WidgetType.FIELDS,
isOverridden: false,
gridPosition: { column: 0, columnSpan: 1, row: 0, rowSpan: 1 },
configuration: { __typename: 'FieldsConfiguration' as const },
position: {
@@ -51,7 +50,6 @@ const makeTab = (
layoutMode,
pageLayoutId: '',
widgets,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -82,7 +82,6 @@ describe('useCreatePageLayoutGraphWidget', () => {
position: 0,
pageLayoutId: '',
widgets: [],
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -166,7 +165,6 @@ describe('useCreatePageLayoutGraphWidget', () => {
position: 0,
pageLayoutId: '',
widgets: [],
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -311,7 +311,6 @@ describe('useCreatePageLayoutTab', () => {
position: 0,
pageLayoutId: 'test-layout',
widgets: [],
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -26,7 +26,6 @@ const makeWidget = (
pageLayoutTabId: tabId,
title: id,
type: WidgetType.FIELDS,
isOverridden: false,
gridPosition: { column: 0, columnSpan: 1, row: 0, rowSpan: 1 },
configuration: { __typename: 'FieldsConfiguration' as const },
position: {
@@ -50,7 +49,6 @@ const makeTab = (
position,
pageLayoutId: '',
widgets,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -25,7 +25,6 @@ const makeWidget = (
pageLayoutTabId: tabId,
title: id,
type: WidgetType.FIELDS,
isOverridden: false,
gridPosition: { column: 0, columnSpan: 1, row: 0, rowSpan: 1 },
configuration: { __typename: 'FieldsConfiguration' as const },
position: {
@@ -50,7 +49,6 @@ const makeTab = (
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: '',
widgets,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -25,7 +25,6 @@ const makeWidget = (
pageLayoutTabId: tabId,
title: id,
type: WidgetType.FIELDS,
isOverridden: false,
gridPosition: { column: 0, columnSpan: 1, row: 0, rowSpan: 1 },
configuration: { __typename: 'FieldsConfiguration' as const },
position: {
@@ -50,7 +49,6 @@ const makeTab = (
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: '',
widgets,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -25,7 +25,6 @@ const makeWidget = (
pageLayoutTabId: tabId,
title: id,
type: WidgetType.FIELDS,
isOverridden: false,
gridPosition: { column: 0, columnSpan: 1, row: 0, rowSpan: 1 },
configuration: { __typename: 'FieldsConfiguration' as const },
position: {
@@ -50,7 +49,6 @@ const makeTab = (
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: '',
widgets,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -92,7 +92,6 @@ describe('usePageLayoutDraftState', () => {
title: 'Tab 1',
position: 0,
pageLayoutId: '',
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -113,7 +112,6 @@ describe('usePageLayoutDraftState', () => {
displayDataLabel: false,
},
objectMetadataId: null,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -39,7 +39,6 @@ describe('usePageLayoutWithRelationWidgets', () => {
position: 100,
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
pageLayoutId: 'test-layout',
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -63,7 +62,6 @@ describe('usePageLayoutWithRelationWidgets', () => {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -86,7 +84,6 @@ describe('usePageLayoutWithRelationWidgets', () => {
__typename: 'NotesConfiguration',
configurationType: WidgetConfigurationType.NOTES,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -115,7 +112,6 @@ describe('usePageLayoutWithRelationWidgets', () => {
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
displayDataLabel: false,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -240,7 +236,6 @@ describe('usePageLayoutWithRelationWidgets', () => {
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
displayDataLabel: false,
},
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -59,7 +59,6 @@ export const useCreatePageLayoutTab = ({
pageLayoutId: pageLayoutId,
layoutMode: getDefaultTabLayoutMode(pageLayoutDraft.type),
widgets: [],
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -0,0 +1,95 @@
import { useApolloClient } from '@apollo/client/react';
import { useStore } from 'jotai';
import { useCallback } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { FindOnePageLayoutDocument } from '~/generated-metadata/graphql';
import { useExitLayoutCustomizationMode } from '@/layout-customization/hooks/useExitLayoutCustomizationMode';
import { useInvalidateMetadataStore } from '@/metadata-store/hooks/useInvalidateMetadataStore';
import { useSetIsPageLayoutInEditMode } from '@/page-layout/hooks/useSetIsPageLayoutInEditMode';
import { PageLayoutComponentInstanceContext } from '@/page-layout/states/contexts/PageLayoutComponentInstanceContext';
import { pageLayoutCurrentLayoutsComponentState } from '@/page-layout/states/pageLayoutCurrentLayoutsComponentState';
import { pageLayoutDraftComponentState } from '@/page-layout/states/pageLayoutDraftComponentState';
import { pageLayoutPersistedComponentState } from '@/page-layout/states/pageLayoutPersistedComponentState';
import { type PageLayout } from '@/page-layout/types/PageLayout';
import { convertPageLayoutToTabLayouts } from '@/page-layout/utils/convertPageLayoutToTabLayouts';
import { evictViewMetadataForViewIds } from '@/page-layout/utils/evictViewMetadataForViewIds';
import { toDraftPageLayout } from '@/page-layout/utils/toDraftPageLayout';
import { transformPageLayout } from '@/page-layout/utils/transformPageLayout';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateCallbackState } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateCallbackState';
export const useRefreshPageLayoutAfterReset = (
pageLayoutIdFromProps: string,
) => {
const pageLayoutId = useAvailableComponentInstanceIdOrThrow(
PageLayoutComponentInstanceContext,
pageLayoutIdFromProps,
);
const client = useApolloClient();
const store = useStore();
const { setIsPageLayoutInEditMode } =
useSetIsPageLayoutInEditMode(pageLayoutId);
const { exitLayoutCustomizationMode } = useExitLayoutCustomizationMode();
const { invalidateMetadataStore } = useInvalidateMetadataStore();
const pageLayoutPersistedState = useAtomComponentStateCallbackState(
pageLayoutPersistedComponentState,
pageLayoutId,
);
const pageLayoutDraftState = useAtomComponentStateCallbackState(
pageLayoutDraftComponentState,
pageLayoutId,
);
const pageLayoutCurrentLayoutsState = useAtomComponentStateCallbackState(
pageLayoutCurrentLayoutsComponentState,
pageLayoutId,
);
const refreshPageLayoutAfterReset = useCallback(
async (collectAffectedViewIds: (layout: PageLayout) => Set<string>) => {
const { data } = await client.query({
query: FindOnePageLayoutDocument,
variables: { id: pageLayoutId },
fetchPolicy: 'network-only',
});
let affectedViewIds = new Set<string>();
if (isDefined(data?.getPageLayout)) {
const freshLayout = transformPageLayout(data.getPageLayout);
affectedViewIds = collectAffectedViewIds(freshLayout);
store.set(pageLayoutPersistedState, freshLayout);
store.set(pageLayoutDraftState, toDraftPageLayout(freshLayout));
store.set(
pageLayoutCurrentLayoutsState,
convertPageLayoutToTabLayouts(freshLayout),
);
}
setIsPageLayoutInEditMode(false);
exitLayoutCustomizationMode();
evictViewMetadataForViewIds(store, affectedViewIds);
invalidateMetadataStore();
},
[
client,
pageLayoutId,
store,
pageLayoutPersistedState,
pageLayoutDraftState,
pageLayoutCurrentLayoutsState,
setIsPageLayoutInEditMode,
exitLayoutCustomizationMode,
invalidateMetadataStore,
],
);
return { refreshPageLayoutAfterReset };
};
@@ -0,0 +1,52 @@
import { CombinedGraphQLErrors } from '@apollo/client/errors';
import { useMutation } from '@apollo/client/react';
import { t } from '@lingui/core/macro';
import { useCallback } from 'react';
import { CrudOperationType } from 'twenty-shared/types';
import { useMetadataErrorHandler } from '@/metadata-error-handler/hooks/useMetadataErrorHandler';
import { RESET_PAGE_LAYOUT_TAB_TO_DEFAULT } from '@/page-layout/graphql/mutations/resetPageLayoutTabToDefault';
import { useRefreshPageLayoutAfterReset } from '@/page-layout/hooks/useRefreshPageLayoutAfterReset';
import { collectViewIdsFromWidgets } from '@/page-layout/utils/collectViewIdsFromWidgets';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
export const useResetPageLayoutTabToDefault = (
pageLayoutIdFromProps: string,
) => {
const [resetMutation] = useMutation(RESET_PAGE_LAYOUT_TAB_TO_DEFAULT);
const { handleMetadataError } = useMetadataErrorHandler();
const { enqueueErrorSnackBar } = useSnackBar();
const { refreshPageLayoutAfterReset } = useRefreshPageLayoutAfterReset(
pageLayoutIdFromProps,
);
const resetPageLayoutTabToDefault = useCallback(
async (tabId: string) => {
try {
await resetMutation({ variables: { id: tabId } });
await refreshPageLayoutAfterReset((layout) =>
collectViewIdsFromWidgets(
layout.tabs.find((tab) => tab.id === tabId)?.widgets ?? [],
),
);
} catch (error) {
if (CombinedGraphQLErrors.is(error)) {
handleMetadataError(error, {
primaryMetadataName: 'pageLayoutTab',
operationType: CrudOperationType.UPDATE,
});
} else {
enqueueErrorSnackBar({ message: t`An error occurred.` });
}
}
},
[
resetMutation,
refreshPageLayoutAfterReset,
handleMetadataError,
enqueueErrorSnackBar,
],
);
return { resetPageLayoutTabToDefault };
};
@@ -1,115 +1,36 @@
import { useInvalidateMetadataStore } from '@/metadata-store/hooks/useInvalidateMetadataStore';
import { useMetadataErrorHandler } from '@/metadata-error-handler/hooks/useMetadataErrorHandler';
import { PageLayoutComponentInstanceContext } from '@/page-layout/states/contexts/PageLayoutComponentInstanceContext';
import { fieldsWidgetEditorModeDraftComponentState } from '@/page-layout/states/fieldsWidgetEditorModeDraftComponentState';
import { fieldsWidgetEditorModePersistedComponentState } from '@/page-layout/states/fieldsWidgetEditorModePersistedComponentState';
import { fieldsWidgetGroupsDraftComponentState } from '@/page-layout/states/fieldsWidgetGroupsDraftComponentState';
import { fieldsWidgetGroupsPersistedComponentState } from '@/page-layout/states/fieldsWidgetGroupsPersistedComponentState';
import { fieldsWidgetUngroupedFieldsDraftComponentState } from '@/page-layout/states/fieldsWidgetUngroupedFieldsDraftComponentState';
import { fieldsWidgetUngroupedFieldsPersistedComponentState } from '@/page-layout/states/fieldsWidgetUngroupedFieldsPersistedComponentState';
import { hasInitializedFieldsWidgetGroupsDraftComponentState } from '@/page-layout/states/hasInitializedFieldsWidgetGroupsDraftComponentState';
import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateCallbackState } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateCallbackState';
import { useMutation } from '@apollo/client/react';
import { CombinedGraphQLErrors } from '@apollo/client/errors';
import { useMutation } from '@apollo/client/react';
import { t } from '@lingui/core/macro';
import { useStore } from 'jotai';
import { useCallback } from 'react';
import { CrudOperationType } from 'twenty-shared/types';
import { ResetPageLayoutWidgetToDefaultDocument } from '~/generated-metadata/graphql';
import { useMetadataErrorHandler } from '@/metadata-error-handler/hooks/useMetadataErrorHandler';
import { useRefreshPageLayoutAfterReset } from '@/page-layout/hooks/useRefreshPageLayoutAfterReset';
import { collectViewIdsFromWidgets } from '@/page-layout/utils/collectViewIdsFromWidgets';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
export const useResetPageLayoutWidgetToDefault = (
pageLayoutIdFromProps?: string,
pageLayoutIdFromProps: string,
) => {
const pageLayoutId = useAvailableComponentInstanceIdOrThrow(
PageLayoutComponentInstanceContext,
pageLayoutIdFromProps,
);
const [resetMutation] = useMutation(ResetPageLayoutWidgetToDefaultDocument);
const { handleMetadataError } = useMetadataErrorHandler();
const { enqueueErrorSnackBar } = useSnackBar();
const { closeSidePanelMenu } = useSidePanelMenu();
const { invalidateMetadataStore } = useInvalidateMetadataStore();
const store = useStore();
const hasInitializedState = useAtomComponentStateCallbackState(
hasInitializedFieldsWidgetGroupsDraftComponentState,
pageLayoutId,
);
const groupsDraftState = useAtomComponentStateCallbackState(
fieldsWidgetGroupsDraftComponentState,
pageLayoutId,
);
const groupsPersistedState = useAtomComponentStateCallbackState(
fieldsWidgetGroupsPersistedComponentState,
pageLayoutId,
);
const ungroupedDraftState = useAtomComponentStateCallbackState(
fieldsWidgetUngroupedFieldsDraftComponentState,
pageLayoutId,
);
const ungroupedPersistedState = useAtomComponentStateCallbackState(
fieldsWidgetUngroupedFieldsPersistedComponentState,
pageLayoutId,
);
const editorModeDraftState = useAtomComponentStateCallbackState(
fieldsWidgetEditorModeDraftComponentState,
pageLayoutId,
);
const editorModePersistedState = useAtomComponentStateCallbackState(
fieldsWidgetEditorModePersistedComponentState,
pageLayoutId,
);
const clearWidgetDraftState = useCallback(
(widgetId: string) => {
const removeWidgetEntry = <T>(prev: Record<string, T>) => {
const { [widgetId]: _, ...rest } = prev;
return rest;
};
store.set(hasInitializedState, removeWidgetEntry);
store.set(groupsDraftState, removeWidgetEntry);
store.set(groupsPersistedState, removeWidgetEntry);
store.set(ungroupedDraftState, removeWidgetEntry);
store.set(ungroupedPersistedState, removeWidgetEntry);
store.set(editorModeDraftState, removeWidgetEntry);
store.set(editorModePersistedState, removeWidgetEntry);
},
[
store,
hasInitializedState,
groupsDraftState,
groupsPersistedState,
ungroupedDraftState,
ungroupedPersistedState,
editorModeDraftState,
editorModePersistedState,
],
const { refreshPageLayoutAfterReset } = useRefreshPageLayoutAfterReset(
pageLayoutIdFromProps,
);
const resetPageLayoutWidgetToDefault = useCallback(
async (widgetId: string) => {
try {
await resetMutation({
variables: { id: widgetId },
});
closeSidePanelMenu();
clearWidgetDraftState(widgetId);
invalidateMetadataStore();
await resetMutation({ variables: { id: widgetId } });
await refreshPageLayoutAfterReset((layout) =>
collectViewIdsFromWidgets(
layout.tabs
.flatMap((tab) => tab.widgets)
.filter((widget) => widget.id === widgetId),
),
);
} catch (error) {
if (CombinedGraphQLErrors.is(error)) {
handleMetadataError(error, {
@@ -123,9 +44,7 @@ export const useResetPageLayoutWidgetToDefault = (
},
[
resetMutation,
closeSidePanelMenu,
clearWidgetDraftState,
invalidateMetadataStore,
refreshPageLayoutAfterReset,
handleMetadataError,
enqueueErrorSnackBar,
],
@@ -22,7 +22,6 @@ describe('addWidgetToTab', () => {
},
gridPosition: { row: 0, column: 0, rowSpan: 2, columnSpan: 2 },
objectMetadataId: null,
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -36,7 +35,6 @@ describe('addWidgetToTab', () => {
position: 0,
pageLayoutId: 'layout-1',
widgets: [],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -48,7 +46,6 @@ describe('addWidgetToTab', () => {
position: 1,
pageLayoutId: 'layout-1',
widgets: [],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -28,7 +28,6 @@ describe('convertLayoutsToWidgets', () => {
aggregateFieldMetadataId: 'id',
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -53,7 +52,6 @@ describe('convertLayoutsToWidgets', () => {
orderBy: GraphOrderBy.VALUE_DESC,
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -38,7 +38,6 @@ describe('convertPageLayoutToTabLayouts', () => {
},
gridPosition: { row: 0, column: 0, rowSpan: 2, columnSpan: 2 },
objectMetadataId: 'object-metadata-1',
isOverridden: false,
createdAt: '2025-01-01T00:00:00.000Z',
updatedAt: '2025-01-01T00:00:00.000Z',
deletedAt: null,
@@ -59,13 +58,11 @@ describe('convertPageLayoutToTabLayouts', () => {
},
gridPosition: { row: 2, column: 0, rowSpan: 2, columnSpan: 2 },
objectMetadataId: 'object-metadata-1',
isOverridden: false,
createdAt: '2025-01-01T00:00:00.000Z',
updatedAt: '2025-01-01T00:00:00.000Z',
deletedAt: null,
},
],
isOverridden: false,
createdAt: '2025-01-01T00:00:00.000Z',
updatedAt: '2025-01-01T00:00:00.000Z',
deletedAt: null,
@@ -118,13 +115,11 @@ describe('convertPageLayoutToTabLayouts', () => {
},
gridPosition: { row: 0, column: 0, rowSpan: 4, columnSpan: 4 },
objectMetadataId: null,
isOverridden: false,
createdAt: '2025-01-01T00:00:00.000Z',
updatedAt: '2025-01-01T00:00:00.000Z',
deletedAt: null,
},
],
isOverridden: false,
createdAt: '2025-01-01T00:00:00.000Z',
updatedAt: '2025-01-01T00:00:00.000Z',
deletedAt: null,
@@ -50,8 +50,7 @@ describe('createDefaultRecordTableWidget', () => {
});
});
it('should set objectMetadataId to null and isOverridden to false', () => {
it('should set objectMetadataId to null', () => {
expect(widget.objectMetadataId).toBeNull();
expect(widget.isOverridden).toBe(false);
});
});
@@ -28,7 +28,6 @@ const createMockWidget = (
objectMetadataId: null,
gridPosition: { row: 0, column: 0, rowSpan: 1, columnSpan: 1 },
pageLayoutTabId: 'tab-1',
isOverridden: false,
createdAt: '2024-01-01',
updatedAt: '2024-01-01',
...overrides,
@@ -28,7 +28,6 @@ describe('filterVisibleWidgets', () => {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-01T00:00:00.000Z',
deletedAt: null,
@@ -9,7 +9,6 @@ describe('getPageLayoutTabListInitialActiveTabId', () => {
title: `Tab ${id}`,
position: 0,
widgets: [],
isOverridden: false,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-01T00:00:00.000Z',
});
@@ -14,7 +14,6 @@ describe('getTabsByDisplayMode', () => {
title: `Tab ${id}`,
position: 0,
widgets: [],
isOverridden: false,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-01T00:00:00.000Z',
});
@@ -28,7 +28,6 @@ describe('getTabsWithVisibleWidgets', () => {
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-01T00:00:00.000Z',
deletedAt: null,
@@ -46,7 +45,6 @@ describe('getTabsWithVisibleWidgets', () => {
title: `Tab ${id}`,
position: 0,
widgets,
isOverridden: false,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-01T00:00:00.000Z',
deletedAt: null,
@@ -40,7 +40,6 @@ const createMockWidget = (
configurationType: WidgetConfigurationType.FIELDS,
viewId: null,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-01T00:00:00.000Z',
deletedAt: null,
@@ -58,7 +57,6 @@ const createMockTab = (
title: `Tab ${id}`,
position: 0,
widgets,
isOverridden: false,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-01T00:00:00.000Z',
deletedAt: null,
@@ -27,7 +27,6 @@ describe('prepareGridLayoutItemsWithPlaceholders', () => {
aggregateFieldMetadataId: 'field-id',
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -30,7 +30,6 @@ describe('removeWidgetFromTab', () => {
},
gridPosition: { row: 0, column: 0, rowSpan: 2, columnSpan: 2 },
objectMetadataId: null,
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -51,13 +50,11 @@ describe('removeWidgetFromTab', () => {
},
gridPosition: { row: 2, column: 0, rowSpan: 2, columnSpan: 2 },
objectMetadataId: null,
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
},
],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -81,13 +78,11 @@ describe('removeWidgetFromTab', () => {
},
gridPosition: { row: 0, column: 0, rowSpan: 2, columnSpan: 2 },
objectMetadataId: null,
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
},
],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -13,7 +13,6 @@ const makeWidget = (id: string, index: number): PageLayoutWidget =>
pageLayoutTabId: 'tab-1',
title: id,
type: WidgetType.FIELDS,
isOverridden: false,
gridPosition: { row: 0, column: 0, rowSpan: 1, columnSpan: 1 },
configuration: {
__typename: 'FieldsConfiguration',
@@ -0,0 +1,20 @@
import { isDefined } from 'twenty-shared/utils';
import { type PageLayoutWidget } from '@/page-layout/types/PageLayoutWidget';
import { getWidgetConfigurationViewId } from '@/page-layout/utils/getWidgetConfigurationViewId';
export const collectViewIdsFromWidgets = (
widgets: PageLayoutWidget[],
): Set<string> => {
const viewIds = new Set<string>();
for (const widget of widgets) {
const viewId = getWidgetConfigurationViewId(widget.configuration);
if (isDefined(viewId)) {
viewIds.add(viewId);
}
}
return viewIds;
};
@@ -46,7 +46,6 @@ export const createDefaultFieldWidget = ({
index: positionIndex,
},
objectMetadataId: objectMetadataId ?? null,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -42,7 +42,6 @@ export const createDefaultFieldsWidget = ({
index: positionIndex,
},
objectMetadataId: objectMetadataId ?? null,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -34,7 +34,6 @@ export const createDefaultFrontComponentWidget = (
columnSpan: gridPosition.columnSpan,
},
objectMetadataId: null,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -84,7 +84,6 @@ export const createDefaultGraphWidget = ({
columnSpan: gridPosition.columnSpan,
},
objectMetadataId: resolvedObjectMetadataId,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -34,7 +34,6 @@ export const createDefaultIframeWidget = (
columnSpan: gridPosition.columnSpan,
},
objectMetadataId: objectMetadataId ?? null,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -31,7 +31,6 @@ export const createDefaultRecordTableWidget = (
columnSpan: gridPosition.columnSpan,
},
objectMetadataId: null,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -34,7 +34,6 @@ export const createDefaultStandaloneRichTextWidget = (
columnSpan: gridPosition.columnSpan,
},
objectMetadataId: objectMetadataId ?? null,
isOverridden: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
@@ -0,0 +1,31 @@
import type { useStore } from 'jotai';
import { isDefined } from 'twenty-shared/utils';
import {
type MetadataEntityKey,
metadataStoreState,
} from '@/metadata-store/states/metadataStoreState';
const VIEW_RELATED_METADATA_KEYS: MetadataEntityKey[] = [
'viewFields',
'viewFieldGroups',
];
export const evictViewMetadataForViewIds = (
store: ReturnType<typeof useStore>,
viewIds: Set<string>,
) => {
if (viewIds.size === 0) {
return;
}
for (const key of VIEW_RELATED_METADATA_KEYS) {
store.set(metadataStoreState.atomFamily(key), (prev) => ({
...prev,
current: (prev.current as { viewId?: string }[]).filter(
(item) => !isDefined(item.viewId) || !viewIds.has(item.viewId),
),
currentCollectionHash: undefined,
}));
}
};
@@ -41,7 +41,6 @@ const getRelationFieldWidgetToInsert = (
fieldMetadataId: field.id,
fieldDisplayMode: FieldDisplayMode.CARD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-01T00:00:00.000Z',
deletedAt: null,
@@ -0,0 +1,12 @@
import { type DraftPageLayout } from '@/page-layout/types/DraftPageLayout';
import { type PageLayout } from '@/page-layout/types/PageLayout';
export const toDraftPageLayout = (pageLayout: PageLayout): DraftPageLayout => ({
id: pageLayout.id,
name: pageLayout.name,
type: pageLayout.type,
objectMetadataId: pageLayout.objectMetadataId,
tabs: pageLayout.tabs,
defaultTabToFocusOnMobileAndSidePanelId:
pageLayout.defaultTabToFocusOnMobileAndSidePanelId,
});
@@ -149,7 +149,6 @@ const createPageLayoutWithWidget = (
position: 0,
pageLayoutId: PAGE_LAYOUT_TEST_INSTANCE_ID,
widgets: [widget],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -272,7 +271,6 @@ export const WithNumberChart: Story = {
aggregateFieldMetadataId: idField.id,
displayDataLabel: true,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -359,7 +357,6 @@ export const WithGaugeChart: Story = {
aggregateFieldMetadataId: idField.id,
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -450,7 +447,6 @@ export const WithBarChart: Story = {
axisNameDisplay: AxisNameDisplay.BOTH,
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -544,7 +540,6 @@ export const SmallWidget: Story = {
aggregateFieldMetadataId: idField.id,
displayDataLabel: true,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -642,7 +637,6 @@ export const MediumWidget: Story = {
axisNameDisplay: AxisNameDisplay.BOTH,
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -740,7 +734,6 @@ export const LargeWidget: Story = {
axisNameDisplay: AxisNameDisplay.BOTH,
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -834,7 +827,6 @@ export const WideWidget: Story = {
aggregateFieldMetadataId: idField.id,
displayDataLabel: true,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -932,7 +924,6 @@ export const TallWidget: Story = {
axisNameDisplay: AxisNameDisplay.BOTH,
displayDataLabel: false,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1026,7 +1017,6 @@ export const WithManyToOneRelationFieldWidget: Story = {
fieldMetadataId: accountOwnerField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1145,7 +1135,6 @@ export const WithOneToManyRelationFieldWidget: Story = {
fieldMetadataId: companyPeopleField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1256,7 +1245,6 @@ export const OneToManyRelationFieldWidgetWithSeeAllButton: Story = {
fieldMetadataId: companyPeopleField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1394,7 +1382,6 @@ export const OnMobile: Story = {
aggregateFieldMetadataId: idField.id,
displayDataLabel: true,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1492,7 +1479,6 @@ export const InSidePanel: Story = {
aggregateFieldMetadataId: idField.id,
displayDataLabel: true,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1651,7 +1637,6 @@ export const Catalog: CatalogStory<Story, typeof WidgetRenderer> = {
aggregateFieldMetadataId: idField.id,
displayDataLabel: true,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1744,7 +1729,6 @@ export const Catalog: CatalogStory<Story, typeof WidgetRenderer> = {
position: 0,
pageLayoutId: PAGE_LAYOUT_TEST_INSTANCE_ID,
widgets: [widget],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1757,7 +1741,6 @@ export const Catalog: CatalogStory<Story, typeof WidgetRenderer> = {
position: 1,
pageLayoutId: PAGE_LAYOUT_TEST_INSTANCE_ID,
widgets: [],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1772,7 +1755,6 @@ export const Catalog: CatalogStory<Story, typeof WidgetRenderer> = {
position: 0,
pageLayoutId: PAGE_LAYOUT_TEST_INSTANCE_ID,
widgets: [widget],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -297,7 +297,6 @@ const createPageLayoutWithWidget = (
position: 0,
pageLayoutId: PAGE_LAYOUT_TEST_INSTANCE_ID,
widgets: [widget],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -351,7 +350,6 @@ export const TextFieldWidget: Story = {
fieldMetadataId: nameField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -445,7 +443,6 @@ export const AddressFieldWidget: Story = {
fieldMetadataId: addressField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -542,7 +539,6 @@ export const NumberFieldWidget: Story = {
fieldMetadataId: employeesField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -636,7 +632,6 @@ export const LinkFieldWidget: Story = {
fieldMetadataId: linkedinField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -730,7 +725,6 @@ export const ManyToOneRelationFieldWidget: Story = {
fieldMetadataId: accountOwnerField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -834,7 +828,6 @@ export const OneToManyRelationFieldWidget: Story = {
fieldMetadataId: companyPeopleField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -930,7 +923,6 @@ export const BooleanFieldWidget: Story = {
fieldMetadataId: idealCustomerProfileField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1023,7 +1015,6 @@ export const CurrencyFieldWidget: Story = {
fieldMetadataId: annualRecurringRevenueField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1116,7 +1107,6 @@ export const EmailsFieldWidget: Story = {
fieldMetadataId: personEmailsField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1210,7 +1200,6 @@ export const PhonesFieldWidget: Story = {
fieldMetadataId: personPhonesField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1304,7 +1293,6 @@ export const SelectFieldWidget: Story = {
fieldMetadataId: opportunityStageField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1399,7 +1387,6 @@ export const MultiSelectFieldWidget: Story = {
fieldMetadataId: companyWorkPolicyField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1497,7 +1484,6 @@ export const TimelineActivityRelationFieldWidget: Story = {
fieldMetadataId: timelineActivityWorkspaceMemberField.id,
fieldDisplayMode: FieldDisplayMode.FIELD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1596,7 +1582,6 @@ export const ManyToOneRelationCardWidget: Story = {
fieldMetadataId: accountOwnerField.id,
fieldDisplayMode: FieldDisplayMode.CARD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1708,7 +1693,6 @@ export const OneToManyRelationCardWidget: Story = {
fieldMetadataId: companyPeopleField.id,
fieldDisplayMode: FieldDisplayMode.CARD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1803,7 +1787,6 @@ export const TimelineActivityRelationCardWidget: Story = {
fieldMetadataId: timelineActivityWorkspaceMemberField.id,
fieldDisplayMode: FieldDisplayMode.CARD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -1964,7 +1947,6 @@ export const OneToManyRelationCardWidgetWithProgressiveLoading: Story = {
fieldMetadataId: companyPeopleField.id,
fieldDisplayMode: FieldDisplayMode.CARD,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -147,7 +147,6 @@ const createPageLayoutWithWidget = (
position: 0,
pageLayoutId: PAGE_LAYOUT_TEST_INSTANCE_ID,
widgets: [widget],
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -177,7 +176,6 @@ const createFieldsWidget = (viewId: string | null): PageLayoutWidget => ({
configurationType: WidgetConfigurationType.FIELDS,
viewId,
},
isOverridden: false,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
deletedAt: null,
@@ -217,7 +215,6 @@ const createViewField = (
isVisible: true,
size: 200,
aggregateOperation: null,
isOverridden: false,
viewId: FIELDS_VIEW_ID,
...(viewFieldGroupId !== undefined && { viewFieldGroupId }),
});
@@ -233,7 +230,6 @@ const createViewFieldGroup = (
name,
position,
isVisible,
isOverridden: false,
viewId: FIELDS_VIEW_ID,
viewFields,
});
@@ -13,7 +13,6 @@ const buildViewField = (
isVisible: true,
size: 100,
aggregateOperation: null,
isOverridden: false,
...overrides,
});
@@ -24,7 +23,6 @@ const buildExistingViewField = (overrides: Partial<ViewField>): ViewField => ({
isVisible: true,
size: 100,
aggregateOperation: null,
isOverridden: false,
...overrides,
});