Add standard record page layout for calendar events (#21857)

Moves calendar event details from the bespoke side-panel page to the
standard record page layout system.

- Adds standard calendar event record page metadata, fields view,
widgets, tests, snapshots, and upgrade command for existing workspaces.
- Opens calendar events through the generic ViewRecord side-panel path.
- Adds participants and call recordings as standard field widgets.
- Removes the old custom calendar event side-panel page and related
side-panel enum/config entry.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21857?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->




https://github.com/user-attachments/assets/c1f88cac-1615-478c-a3dd-87d0c61ab9a8

<img width="3024" height="1658" alt="CleanShot 2026-06-19 at 19 01
27@2x"
src="https://github.com/user-attachments/assets/c3df5705-ff08-446e-ac3c-6ccb11cf21ec"
/>

<img width="3024" height="1658" alt="CleanShot 2026-06-19 at 19 01
19@2x"
src="https://github.com/user-attachments/assets/633525db-310c-4462-8458-a72068cc1432"
/>
This commit is contained in:
nitin
2026-06-19 20:06:33 +05:30
committed by GitHub
parent 0b80e3e018
commit 973b35989e
26 changed files with 2241 additions and 1666 deletions
@@ -2,10 +2,21 @@ import { Module } from '@nestjs/common';
import { WorkspaceIteratorModule } from 'src/database/commands/command-runners/workspace-iterator.module';
import { MigrateManualTriggerVariablesToPayloadCommand } from 'src/database/commands/upgrade-version-command/2-15/2-15-workspace-command-1800000001000-migrate-manual-trigger-variables-to-payload.command';
import { SyncCalendarEventRecordPageCommand } from 'src/database/commands/upgrade-version-command/2-15/2-15-workspace-command-1800000002000-sync-calendar-event-record-page.command';
import { ApplicationModule } from 'src/engine/core-modules/application/application.module';
import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';
import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration.module';
@Module({
imports: [WorkspaceIteratorModule, WorkspaceCacheModule],
providers: [MigrateManualTriggerVariablesToPayloadCommand],
imports: [
ApplicationModule,
WorkspaceIteratorModule,
WorkspaceCacheModule,
WorkspaceMigrationModule,
],
providers: [
MigrateManualTriggerVariablesToPayloadCommand,
SyncCalendarEventRecordPageCommand,
],
})
export class V2_15_UpgradeVersionCommandModule {}
@@ -0,0 +1,256 @@
import { Command } from 'nest-commander';
import {
STANDARD_OBJECTS,
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS,
} from 'twenty-shared/metadata';
import { isDefined } from 'twenty-shared/utils';
import { ActiveOrSuspendedWorkspaceCommandRunner } from 'src/database/commands/command-runners/active-or-suspended-workspace.command-runner';
import { WorkspaceIteratorService } from 'src/database/commands/command-runners/workspace-iterator.service';
import { type RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspace.command-runner';
import { getStandardFlatEntitiesToCreateOrThrow } from 'src/database/commands/upgrade-version-command/2-10/utils/get-standard-flat-entities-to-create-or-throw.util';
import { ApplicationService } from 'src/engine/core-modules/application/application.service';
import { RegisteredWorkspaceCommand } from 'src/engine/core-modules/upgrade/decorators/registered-workspace-command.decorator';
import { type FlatPageLayoutTab } from 'src/engine/metadata-modules/flat-page-layout-tab/types/flat-page-layout-tab.type';
import { type FlatPageLayoutWidget } from 'src/engine/metadata-modules/flat-page-layout-widget/types/flat-page-layout-widget.type';
import { type FlatPageLayout } from 'src/engine/metadata-modules/flat-page-layout/types/flat-page-layout.type';
import { type FlatViewFieldGroup } from 'src/engine/metadata-modules/flat-view-field-group/types/flat-view-field-group.type';
import { type FlatViewField } from 'src/engine/metadata-modules/flat-view-field/types/flat-view-field.type';
import { type FlatView } from 'src/engine/metadata-modules/flat-view/types/flat-view.type';
import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
import { computeTwentyStandardApplicationAllFlatEntityMaps } from 'src/engine/workspace-manager/twenty-standard-application/utils/twenty-standard-application-all-flat-entity-maps.constant';
import { WorkspaceMigrationValidateBuildAndRunService } from 'src/engine/workspace-manager/workspace-migration/services/workspace-migration-validate-build-and-run-service';
const getUniversalIdentifiers = (
entitiesByName: Record<string, { universalIdentifier: string }>,
): string[] =>
Object.values(entitiesByName).map((entity) => entity.universalIdentifier);
const CALENDAR_EVENT_RECORD_PAGE_VIEW_UNIVERSAL_IDENTIFIERS = [
STANDARD_OBJECTS.calendarEvent.views.calendarEventRecordPageFields
.universalIdentifier,
];
const CALENDAR_EVENT_RECORD_PAGE_VIEW_FIELD_GROUP_UNIVERSAL_IDENTIFIERS =
getUniversalIdentifiers(
STANDARD_OBJECTS.calendarEvent.views.calendarEventRecordPageFields
.viewFieldGroups,
);
const CALENDAR_EVENT_RECORD_PAGE_VIEW_FIELD_UNIVERSAL_IDENTIFIERS =
getUniversalIdentifiers(
STANDARD_OBJECTS.calendarEvent.views.calendarEventRecordPageFields
.viewFields,
);
const CALENDAR_EVENT_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS = [
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage
.universalIdentifier,
];
const CALENDAR_EVENT_PAGE_LAYOUT_TAB_UNIVERSAL_IDENTIFIERS = [
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs.home
.universalIdentifier,
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs
.timeline.universalIdentifier,
];
const CALENDAR_EVENT_PAGE_LAYOUT_WIDGET_UNIVERSAL_IDENTIFIERS = [
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs.home
.widgets.fields.universalIdentifier,
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs.home
.widgets.participants.universalIdentifier,
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs.home
.widgets.callRecordings.universalIdentifier,
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs
.timeline.widgets.timeline.universalIdentifier,
];
@RegisteredWorkspaceCommand('2.15.0', 1800000002000)
@Command({
name: 'upgrade:2-15:sync-calendar-event-record-page',
description:
'Create the CalendarEvent record page layout and fields view in existing workspaces',
})
export class SyncCalendarEventRecordPageCommand extends ActiveOrSuspendedWorkspaceCommandRunner {
constructor(
protected readonly workspaceIteratorService: WorkspaceIteratorService,
private readonly applicationService: ApplicationService,
private readonly workspaceCacheService: WorkspaceCacheService,
private readonly workspaceMigrationValidateBuildAndRunService: WorkspaceMigrationValidateBuildAndRunService,
) {
super(workspaceIteratorService);
}
override async runOnWorkspace({
workspaceId,
options,
}: RunOnWorkspaceArgs): Promise<void> {
const isDryRun = options.dryRun ?? false;
const { twentyStandardFlatApplication } =
await this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow(
{ workspaceId },
);
const {
flatObjectMetadataMaps,
flatViewMaps,
flatViewFieldMaps,
flatViewFieldGroupMaps,
flatPageLayoutMaps,
flatPageLayoutTabMaps,
flatPageLayoutWidgetMaps,
} = await this.workspaceCacheService.getOrRecompute(workspaceId, [
'flatObjectMetadataMaps',
'flatViewMaps',
'flatViewFieldMaps',
'flatViewFieldGroupMaps',
'flatPageLayoutMaps',
'flatPageLayoutTabMaps',
'flatPageLayoutWidgetMaps',
]);
const existingCalendarEventObjectMetadata =
flatObjectMetadataMaps.byUniversalIdentifier[
STANDARD_OBJECTS.calendarEvent.universalIdentifier
];
if (!isDefined(existingCalendarEventObjectMetadata)) {
this.logger.log(
`calendarEvent object metadata does not exist for workspace ${workspaceId}, skipping`,
);
return;
}
const { allFlatEntityMaps: standardAllFlatEntityMaps } =
computeTwentyStandardApplicationAllFlatEntityMaps({
now: new Date().toISOString(),
workspaceId,
twentyStandardApplicationId: twentyStandardFlatApplication.id,
});
const viewsToCreate = getStandardFlatEntitiesToCreateOrThrow<FlatView>({
standardFlatEntityMaps: standardAllFlatEntityMaps.flatViewMaps,
existingFlatEntityMaps: flatViewMaps,
universalIdentifiers: CALENDAR_EVENT_RECORD_PAGE_VIEW_UNIVERSAL_IDENTIFIERS,
});
const viewFieldGroupsToCreate =
getStandardFlatEntitiesToCreateOrThrow<FlatViewFieldGroup>({
standardFlatEntityMaps: standardAllFlatEntityMaps.flatViewFieldGroupMaps,
existingFlatEntityMaps: flatViewFieldGroupMaps,
universalIdentifiers:
CALENDAR_EVENT_RECORD_PAGE_VIEW_FIELD_GROUP_UNIVERSAL_IDENTIFIERS,
});
const viewFieldsToCreate =
getStandardFlatEntitiesToCreateOrThrow<FlatViewField>({
standardFlatEntityMaps: standardAllFlatEntityMaps.flatViewFieldMaps,
existingFlatEntityMaps: flatViewFieldMaps,
universalIdentifiers:
CALENDAR_EVENT_RECORD_PAGE_VIEW_FIELD_UNIVERSAL_IDENTIFIERS,
});
const pageLayoutsToCreate =
getStandardFlatEntitiesToCreateOrThrow<FlatPageLayout>({
standardFlatEntityMaps: standardAllFlatEntityMaps.flatPageLayoutMaps,
existingFlatEntityMaps: flatPageLayoutMaps,
universalIdentifiers: CALENDAR_EVENT_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS,
});
const pageLayoutTabsToCreate =
getStandardFlatEntitiesToCreateOrThrow<FlatPageLayoutTab>({
standardFlatEntityMaps: standardAllFlatEntityMaps.flatPageLayoutTabMaps,
existingFlatEntityMaps: flatPageLayoutTabMaps,
universalIdentifiers:
CALENDAR_EVENT_PAGE_LAYOUT_TAB_UNIVERSAL_IDENTIFIERS,
});
const pageLayoutWidgetsToCreate =
getStandardFlatEntitiesToCreateOrThrow<FlatPageLayoutWidget>({
standardFlatEntityMaps:
standardAllFlatEntityMaps.flatPageLayoutWidgetMaps,
existingFlatEntityMaps: flatPageLayoutWidgetMaps,
universalIdentifiers:
CALENDAR_EVENT_PAGE_LAYOUT_WIDGET_UNIVERSAL_IDENTIFIERS,
});
const totalOperationCount =
viewsToCreate.length +
viewFieldGroupsToCreate.length +
viewFieldsToCreate.length +
pageLayoutsToCreate.length +
pageLayoutTabsToCreate.length +
pageLayoutWidgetsToCreate.length;
if (totalOperationCount === 0) {
this.logger.log(
`CalendarEvent record page metadata already exists for workspace ${workspaceId}, skipping`,
);
return;
}
this.logger.log(
`${isDryRun ? '[DRY RUN] ' : ''}Creating ${totalOperationCount} CalendarEvent record page metadata item(s) for workspace ${workspaceId}`,
);
if (isDryRun) {
return;
}
const validateAndBuildResult =
await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunWorkspaceMigration(
{
isSystemBuild: true,
applicationUniversalIdentifier:
twentyStandardFlatApplication.universalIdentifier,
workspaceId,
allFlatEntityOperationByMetadataName: {
view: {
flatEntityToCreate: viewsToCreate,
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
viewFieldGroup: {
flatEntityToCreate: viewFieldGroupsToCreate,
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
viewField: {
flatEntityToCreate: viewFieldsToCreate,
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
pageLayout: {
flatEntityToCreate: pageLayoutsToCreate,
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
pageLayoutTab: {
flatEntityToCreate: pageLayoutTabsToCreate,
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
pageLayoutWidget: {
flatEntityToCreate: pageLayoutWidgetsToCreate,
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
},
},
);
if (validateAndBuildResult.status === 'fail') {
throw new Error(
`Failed to create CalendarEvent record page metadata for workspace ${workspaceId}: ${JSON.stringify(
validateAndBuildResult,
null,
2,
)}`,
);
}
this.logger.log(
`Created ${totalOperationCount} CalendarEvent record page metadata item(s) for workspace ${workspaceId}`,
);
}
}