17042 followups (#17122)
Followups after @Weiko review on https://github.com/twentyhq/twenty/pull/17042
This commit is contained in:
+51
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user