17042 followups (#17122)

Followups after @Weiko review on
https://github.com/twentyhq/twenty/pull/17042
This commit is contained in:
Raphaël Bosi
2026-01-13 17:25:30 +01:00
committed by GitHub
parent 869a0a7cf4
commit f793faae2b
4 changed files with 66 additions and 18 deletions
@@ -350,6 +350,57 @@ export class PageLayoutService {
return true;
}
async destroyMany({
ids,
workspaceId,
}: {
ids: string[];
workspaceId: string;
}): Promise<boolean> {
if (ids.length === 0) {
return true;
}
const { flatPageLayoutMaps: existingFlatPageLayoutMaps } =
await this.workspaceManyOrAllFlatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatMapsKeys: ['flatPageLayoutMaps'],
},
);
const flatPageLayoutsToDestroy = ids.map((id) =>
fromDestroyPageLayoutInputToFlatPageLayoutOrThrow({
destroyPageLayoutInput: { id },
flatPageLayoutMaps: existingFlatPageLayoutMaps,
}),
);
const validateAndBuildResult =
await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunWorkspaceMigration(
{
allFlatEntityOperationByMetadataName: {
pageLayout: {
flatEntityToCreate: [],
flatEntityToDelete: flatPageLayoutsToDestroy,
flatEntityToUpdate: [],
},
},
workspaceId,
isSystemBuild: false,
},
);
if (isDefined(validateAndBuildResult)) {
throw new WorkspaceMigrationBuilderException(
validateAndBuildResult,
'Multiple validation errors occurred while destroying page layouts',
);
}
return true;
}
private async destroyAssociatedDashboards({
pageLayoutId,
workspaceId,