[BREAKING_CHANGE_DASHBOARDS][DASHBOARD_CACHE_FLUSH_REQUIRED] Refactor page layout widget configuration type (#16671)

# Introduction
In this pull-request we're refactoring the page layout widget
configuration entity to be containing its discriminated key simplifying
underlying code and maintainability
- Made the configuration and title non nullable
- Introduced a generic predicate for the `widgetConfigurationType`
- Upgraded command to remove `graphType` and insert new
`configurationType` to existing entries
- Migrated frontend to new type system

---------

Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com>
This commit is contained in:
Paul Rastoin
2025-12-29 15:46:59 +01:00
committed by GitHub
parent 2b9728230a
commit 4135a6473a
221 changed files with 3241 additions and 1947 deletions
@@ -0,0 +1,12 @@
import { type FlatPageLayoutWidget } from 'src/engine/metadata-modules/flat-page-layout-widget/types/flat-page-layout-widget.type';
export type SeederFlatPageLayoutWidget = Pick<
FlatPageLayoutWidget,
| 'id'
| 'pageLayoutTabId'
| 'title'
| 'type'
| 'gridPosition'
| 'configuration'
| 'objectMetadataId'
>;
@@ -5,26 +5,14 @@ import { isDefined } from 'twenty-shared/utils';
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { AxisNameDisplay } from 'src/engine/metadata-modules/page-layout-widget/enums/axis-name-display.enum';
import { GraphOrderBy } from 'src/engine/metadata-modules/page-layout-widget/enums/graph-order-by.enum';
import { WidgetConfigurationType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-configuration-type.type';
import { WidgetType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-type.enum';
import { PAGE_LAYOUT_TAB_SEEDS } from 'src/engine/workspace-manager/dev-seeder/core/constants/page-layout-tab-seeds.constant';
import { PAGE_LAYOUT_WIDGET_SEEDS } from 'src/engine/workspace-manager/dev-seeder/core/constants/page-layout-widget-seeds.constant';
import { type SeederFlatPageLayoutWidget } from 'src/engine/workspace-manager/dev-seeder/core/types/seeder-flat-page-layout-widget.type';
import { generateSeedId } from 'src/engine/workspace-manager/dev-seeder/core/utils/generate-seed-id.util';
type PageLayoutWidgetDataSeed = {
id: string;
pageLayoutTabId: string;
title: string;
type: WidgetType;
gridPosition: {
row: number;
column: number;
rowSpan: number;
columnSpan: number;
};
configuration: Record<string, unknown> | null;
objectMetadataId: string | null;
};
const getFieldId = (
object: ObjectMetadataEntity | undefined,
fieldName: string,
@@ -35,7 +23,7 @@ const getFieldId = (
export const getPageLayoutWidgetDataSeedsV2 = (
workspaceId: string,
objectMetadataItems: ObjectMetadataEntity[],
): PageLayoutWidgetDataSeed[] => {
): SeederFlatPageLayoutWidget[] => {
const opportunityObject = objectMetadataItems.find(
(obj) => obj.standardId === STANDARD_OBJECT_IDS.opportunity,
);
@@ -65,7 +53,7 @@ export const getPageLayoutWidgetDataSeedsV2 = (
// LINE chart: Revenue Forecast (Sales Overview)
isDefined(opportunityAmountFieldId) &&
isDefined(opportunityCloseDateFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.SALES_REVENUE_FORECAST,
@@ -78,23 +66,23 @@ export const getPageLayoutWidgetDataSeedsV2 = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 7, rowSpan: 8, columnSpan: 5 },
configuration: {
graphType: 'LINE',
configurationType: WidgetConfigurationType.LINE_CHART,
aggregateFieldMetadataId: opportunityAmountFieldId,
aggregateOperation: AggregateOperations.SUM,
primaryAxisGroupByFieldMetadataId: opportunityCloseDateFieldId,
primaryAxisOrderBy: 'FIELD_ASC',
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
axisNameDisplay: AxisNameDisplay.NONE,
displayDataLabel: false,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: opportunityObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// LINE chart: New Customers Over Time (Customer Overview)
isDefined(companyIdFieldId) && isDefined(companyCreatedAtFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.CUSTOMER_NEW_OVER_TIME,
@@ -107,23 +95,23 @@ export const getPageLayoutWidgetDataSeedsV2 = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 3, rowSpan: 6, columnSpan: 5 },
configuration: {
graphType: 'LINE',
configurationType: WidgetConfigurationType.LINE_CHART,
aggregateFieldMetadataId: companyIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
primaryAxisGroupByFieldMetadataId: companyCreatedAtFieldId,
primaryAxisOrderBy: 'FIELD_ASC',
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
axisNameDisplay: AxisNameDisplay.NONE,
displayDataLabel: false,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: companyObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// PIE chart: Revenue Distribution (Customer Analytics)
isDefined(companyArrFieldId) && isDefined(companyNameFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.CUSTOMER_REVENUE_DISTRIBUTION,
@@ -136,22 +124,22 @@ export const getPageLayoutWidgetDataSeedsV2 = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 4, rowSpan: 2, columnSpan: 3 },
configuration: {
graphType: 'PIE',
configurationType: WidgetConfigurationType.PIE_CHART,
aggregateFieldMetadataId: companyArrFieldId,
aggregateOperation: AggregateOperations.SUM,
groupByFieldMetadataId: companyNameFieldId,
orderBy: 'VALUE_DESC',
orderBy: GraphOrderBy.VALUE_DESC,
displayDataLabel: true,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: companyObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// GAUGE chart: Average ARR (Customer Analytics)
isDefined(companyArrFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.CUSTOMER_AVERAGE_ARR,
@@ -164,7 +152,7 @@ export const getPageLayoutWidgetDataSeedsV2 = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 7, rowSpan: 6, columnSpan: 5 },
configuration: {
graphType: 'GAUGE',
configurationType: WidgetConfigurationType.GAUGE_CHART,
aggregateFieldMetadataId: companyArrFieldId,
aggregateOperation: AggregateOperations.AVG,
displayDataLabel: true,
@@ -172,12 +160,12 @@ export const getPageLayoutWidgetDataSeedsV2 = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: companyObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// PIE chart: Companies by LinkedIn (Customer Overview)
isDefined(companyIdFieldId) && isDefined(companyLinkedinLinkFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.CUSTOMER_LINKEDIN_DISTRIBUTION,
@@ -190,22 +178,22 @@ export const getPageLayoutWidgetDataSeedsV2 = (
type: WidgetType.GRAPH,
gridPosition: { row: 6, column: 0, rowSpan: 4, columnSpan: 6 },
configuration: {
graphType: 'PIE',
configurationType: WidgetConfigurationType.PIE_CHART,
aggregateFieldMetadataId: companyIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
groupByFieldMetadataId: companyLinkedinLinkFieldId,
orderBy: 'VALUE_DESC',
orderBy: GraphOrderBy.VALUE_DESC,
displayDataLabel: true,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: companyObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// PIE chart: Contact Roles (Team Metrics)
isDefined(personIdFieldId) && isDefined(personJobTitleFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.TEAM_CONTACT_ROLES,
@@ -218,17 +206,17 @@ export const getPageLayoutWidgetDataSeedsV2 = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 0, rowSpan: 4, columnSpan: 6 },
configuration: {
graphType: 'PIE',
configurationType: WidgetConfigurationType.PIE_CHART,
aggregateFieldMetadataId: personIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
groupByFieldMetadataId: personJobTitleFieldId,
orderBy: 'VALUE_DESC',
orderBy: GraphOrderBy.VALUE_DESC,
displayDataLabel: true,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: personObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
].filter(isDefined);
};
@@ -5,28 +5,17 @@ import { isDefined } from 'twenty-shared/utils';
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { AxisNameDisplay } from 'src/engine/metadata-modules/page-layout-widget/enums/axis-name-display.enum';
import { GraphType } from 'src/engine/metadata-modules/page-layout-widget/enums/graph-type.enum';
import { BarChartLayout } from 'src/engine/metadata-modules/page-layout-widget/enums/bar-chart-layout.enum';
import { ObjectRecordGroupByDateGranularity } from 'src/engine/metadata-modules/page-layout-widget/enums/date-granularity.enum';
import { GraphOrderBy } from 'src/engine/metadata-modules/page-layout-widget/enums/graph-order-by.enum';
import { WidgetConfigurationType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-configuration-type.type';
import { WidgetType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-type.enum';
import { PAGE_LAYOUT_TAB_SEEDS } from 'src/engine/workspace-manager/dev-seeder/core/constants/page-layout-tab-seeds.constant';
import { PAGE_LAYOUT_WIDGET_SEEDS } from 'src/engine/workspace-manager/dev-seeder/core/constants/page-layout-widget-seeds.constant';
import { type SeederFlatPageLayoutWidget } from 'src/engine/workspace-manager/dev-seeder/core/types/seeder-flat-page-layout-widget.type';
import { generateSeedId } from 'src/engine/workspace-manager/dev-seeder/core/utils/generate-seed-id.util';
import { getPageLayoutWidgetDataSeedsV2 } from 'src/engine/workspace-manager/dev-seeder/core/utils/get-page-layout-widget-data-seeds-v2.util';
type PageLayoutWidgetDataSeed = {
id: string;
pageLayoutTabId: string;
title: string;
type: WidgetType;
gridPosition: {
row: number;
column: number;
rowSpan: number;
columnSpan: number;
};
configuration: Record<string, unknown> | null;
objectMetadataId: string | null;
};
const getFieldId = (
object: ObjectMetadataEntity | undefined,
fieldName: string,
@@ -38,7 +27,7 @@ export const getPageLayoutWidgetDataSeeds = (
workspaceId: string,
objectMetadataItems: ObjectMetadataEntity[],
isDashboardV2Enabled: boolean,
): PageLayoutWidgetDataSeed[] => {
): SeederFlatPageLayoutWidget[] => {
const opportunityObject = objectMetadataItems.find(
(obj) => obj.standardId === STANDARD_OBJECT_IDS.opportunity,
);
@@ -78,10 +67,10 @@ export const getPageLayoutWidgetDataSeeds = (
const rocketIdFieldId = getFieldId(rocketObject, 'id');
const rocketCreatedAtFieldId = getFieldId(rocketObject, 'createdAt');
const v1Widgets = [
const v1Widgets: SeederFlatPageLayoutWidget[] = [
// Sales Overview Tab Widgets
isDefined(opportunityAmountFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.SALES_PIPELINE_VALUE,
@@ -94,7 +83,7 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 0, rowSpan: 2, columnSpan: 3 },
configuration: {
graphType: 'AGGREGATE',
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
aggregateFieldMetadataId: opportunityAmountFieldId,
aggregateOperation: AggregateOperations.SUM,
displayDataLabel: true,
@@ -102,10 +91,10 @@ export const getPageLayoutWidgetDataSeeds = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: opportunityObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
isDefined(rocketIdFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.SALES_AVERAGE_DEAL_SIZE,
@@ -118,7 +107,7 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 3, rowSpan: 4, columnSpan: 4 },
configuration: {
graphType: 'AGGREGATE',
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
aggregateFieldMetadataId: rocketIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
displayDataLabel: true,
@@ -126,12 +115,12 @@ export const getPageLayoutWidgetDataSeeds = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: rocketObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
isDefined(opportunityAmountFieldId) &&
isDefined(opportunityCloseDateFieldId) &&
isDefined(opportunityStageFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.SALES_DEALS_BY_STAGE,
@@ -144,25 +133,26 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 4, column: 0, rowSpan: 8, columnSpan: 6 },
configuration: {
graphType: GraphType.VERTICAL_BAR,
configurationType: WidgetConfigurationType.BAR_CHART,
aggregateFieldMetadataId: opportunityAmountFieldId,
aggregateOperation: AggregateOperations.SUM,
primaryAxisGroupByFieldMetadataId: opportunityCloseDateFieldId,
secondaryAxisGroupByFieldMetadataId: opportunityStageFieldId,
primaryAxisOrderBy: 'FIELD_ASC',
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
axisNameDisplay: AxisNameDisplay.NONE,
displayDataLabel: false,
color: 'auto',
layout: BarChartLayout.VERTICAL,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: opportunityObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// Sales Details Tab Widgets
isDefined(rocketIdFieldId) && isDefined(rocketCreatedAtFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.SALES_DEAL_DISTRIBUTION,
@@ -175,22 +165,23 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 0, rowSpan: 5, columnSpan: 5 },
configuration: {
graphType: GraphType.VERTICAL_BAR,
configurationType: WidgetConfigurationType.BAR_CHART,
aggregateFieldMetadataId: rocketIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
primaryAxisGroupByFieldMetadataId: rocketCreatedAtFieldId,
primaryAxisOrderBy: 'FIELD_ASC',
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
axisNameDisplay: AxisNameDisplay.NONE,
displayDataLabel: false,
color: 'auto',
layout: BarChartLayout.VERTICAL,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: rocketObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
isDefined(opportunityIdFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.SALES_OPPORTUNITY_COUNT,
@@ -203,7 +194,7 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 5, rowSpan: 5, columnSpan: 7 },
configuration: {
graphType: 'AGGREGATE',
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
aggregateFieldMetadataId: opportunityIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
displayDataLabel: true,
@@ -211,12 +202,12 @@ export const getPageLayoutWidgetDataSeeds = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: opportunityObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// Customer Overview Tab Widgets
isDefined(companyIdFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.CUSTOMER_TOTAL_COUNT,
@@ -229,7 +220,7 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 0, rowSpan: 2, columnSpan: 3 },
configuration: {
graphType: 'AGGREGATE',
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
aggregateFieldMetadataId: companyIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
displayDataLabel: true,
@@ -237,12 +228,12 @@ export const getPageLayoutWidgetDataSeeds = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: companyObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
isDefined(companyIdFieldId) &&
isDefined(companyEmployeesFieldId) &&
isDefined(companyAddressFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.CUSTOMER_COMPANIES_BY_SIZE,
@@ -255,27 +246,29 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 8, rowSpan: 10, columnSpan: 8 },
configuration: {
graphType: GraphType.VERTICAL_BAR,
configurationType: WidgetConfigurationType.BAR_CHART,
aggregateFieldMetadataId: companyIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
primaryAxisGroupByFieldMetadataId: companyEmployeesFieldId,
secondaryAxisGroupByFieldMetadataId: companyAddressFieldId,
secondaryAxisGroupBySubFieldName: 'addressCity',
secondaryAxisGroupByDateGranularity: 'DAY',
primaryAxisOrderBy: 'FIELD_ASC',
secondaryAxisGroupByDateGranularity:
ObjectRecordGroupByDateGranularity.DAY,
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
axisNameDisplay: AxisNameDisplay.NONE,
displayDataLabel: false,
color: 'auto',
layout: BarChartLayout.VERTICAL,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: companyObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// Customer Analytics Tab Widgets
isDefined(companyArrFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.CUSTOMER_ANNUAL_RECURRING_REVENUE,
@@ -288,7 +281,7 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 0, rowSpan: 4, columnSpan: 4 },
configuration: {
graphType: 'AGGREGATE',
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
aggregateFieldMetadataId: companyArrFieldId,
aggregateOperation: AggregateOperations.SUM,
displayDataLabel: true,
@@ -296,10 +289,10 @@ export const getPageLayoutWidgetDataSeeds = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: companyObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
isDefined(companyLinkedinLinkFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.CUSTOMER_LINKEDIN_COUNT,
@@ -312,7 +305,7 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 2, column: 0, rowSpan: 4, columnSpan: 3 },
configuration: {
graphType: 'AGGREGATE',
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
aggregateFieldMetadataId: companyLinkedinLinkFieldId,
aggregateOperation: AggregateOperations.COUNT,
displayDataLabel: true,
@@ -320,12 +313,12 @@ export const getPageLayoutWidgetDataSeeds = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: companyObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// Team Overview Tab Widgets
isDefined(personIdFieldId)
? {
? ({
id: generateSeedId(workspaceId, PAGE_LAYOUT_WIDGET_SEEDS.TEAM_SIZE),
pageLayoutTabId: generateSeedId(
workspaceId,
@@ -335,7 +328,7 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 0, rowSpan: 5, columnSpan: 6 },
configuration: {
graphType: 'AGGREGATE',
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
aggregateFieldMetadataId: personIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
displayDataLabel: true,
@@ -343,10 +336,10 @@ export const getPageLayoutWidgetDataSeeds = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: personObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
isDefined(personIdFieldId) && isDefined(personCityFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.TEAM_GEOGRAPHIC_DISTRIBUTION,
@@ -359,24 +352,25 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 6, rowSpan: 5, columnSpan: 6 },
configuration: {
graphType: GraphType.VERTICAL_BAR,
configurationType: WidgetConfigurationType.BAR_CHART,
aggregateFieldMetadataId: personIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
primaryAxisGroupByFieldMetadataId: personCityFieldId,
primaryAxisOrderBy: 'VALUE_DESC',
primaryAxisOrderBy: GraphOrderBy.VALUE_DESC,
axisNameDisplay: AxisNameDisplay.NONE,
displayDataLabel: false,
color: 'auto',
layout: BarChartLayout.VERTICAL,
timezone: 'UTC',
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: personObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
// Team Metrics Tab Widgets
isDefined(taskIdFieldId)
? {
? ({
id: generateSeedId(
workspaceId,
PAGE_LAYOUT_WIDGET_SEEDS.TEAM_OPEN_TASKS,
@@ -389,7 +383,7 @@ export const getPageLayoutWidgetDataSeeds = (
type: WidgetType.GRAPH,
gridPosition: { row: 0, column: 6, rowSpan: 6, columnSpan: 6 },
configuration: {
graphType: 'AGGREGATE',
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
aggregateFieldMetadataId: taskIdFieldId,
aggregateOperation: AggregateOperations.COUNT,
displayDataLabel: true,
@@ -397,7 +391,7 @@ export const getPageLayoutWidgetDataSeeds = (
firstDayOfTheWeek: CalendarStartDay.MONDAY,
},
objectMetadataId: taskObject?.id ?? null,
}
} satisfies SeederFlatPageLayoutWidget)
: null,
].filter(isDefined);