[DASHBOARDS] Allow dashboards to be restored (#17042)

This PR introduces a few changes:
- Add three actions: see deleted dashboards, destroy dashboard and
restore dashboard
- Remove the soft delete and restore on all the page layout entities
- Cascade the destruction of a dashboard to a page layout

Video QA:


https://github.com/user-attachments/assets/ab993b11-dd9c-4e88-880c-92691a521cc2
This commit is contained in:
Raphaël Bosi
2026-01-12 13:59:17 +01:00
committed by GitHub
parent 3ada8e5168
commit 655f1eef5f
60 changed files with 1178 additions and 2067 deletions
@@ -1,43 +0,0 @@
import { t } from '@lingui/core/macro';
import {
extractAndSanitizeObjectStringFields,
isDefined,
} from 'twenty-shared/utils';
import { type FlatPageLayoutMaps } from 'src/engine/metadata-modules/flat-page-layout/types/flat-page-layout-maps.type';
import { type FlatPageLayout } from 'src/engine/metadata-modules/flat-page-layout/types/flat-page-layout.type';
import {
PageLayoutException,
PageLayoutExceptionCode,
} from 'src/engine/metadata-modules/page-layout/exceptions/page-layout.exception';
export type DeletePageLayoutInput = {
id: string;
};
export const fromDeletePageLayoutInputToFlatPageLayoutOrThrow = ({
deletePageLayoutInput: rawDeletePageLayoutInput,
flatPageLayoutMaps,
}: {
deletePageLayoutInput: DeletePageLayoutInput;
flatPageLayoutMaps: FlatPageLayoutMaps;
}): FlatPageLayout => {
const { id: pageLayoutId } = extractAndSanitizeObjectStringFields(
rawDeletePageLayoutInput,
['id'],
);
const existingFlatPageLayoutToDelete = flatPageLayoutMaps.byId[pageLayoutId];
if (!isDefined(existingFlatPageLayoutToDelete)) {
throw new PageLayoutException(
t`Page layout to delete not found`,
PageLayoutExceptionCode.PAGE_LAYOUT_NOT_FOUND,
);
}
return {
...existingFlatPageLayoutToDelete,
deletedAt: new Date().toISOString(),
};
};
@@ -1,50 +0,0 @@
import { t } from '@lingui/core/macro';
import {
extractAndSanitizeObjectStringFields,
isDefined,
} from 'twenty-shared/utils';
import { type FlatPageLayoutMaps } from 'src/engine/metadata-modules/flat-page-layout/types/flat-page-layout-maps.type';
import { type FlatPageLayout } from 'src/engine/metadata-modules/flat-page-layout/types/flat-page-layout.type';
import {
PageLayoutException,
PageLayoutExceptionCode,
} from 'src/engine/metadata-modules/page-layout/exceptions/page-layout.exception';
export type RestorePageLayoutInput = {
id: string;
};
export const fromRestorePageLayoutInputToFlatPageLayoutOrThrow = ({
restorePageLayoutInput,
flatPageLayoutMaps,
}: {
restorePageLayoutInput: RestorePageLayoutInput;
flatPageLayoutMaps: FlatPageLayoutMaps;
}): FlatPageLayout => {
const { id: pageLayoutId } = extractAndSanitizeObjectStringFields(
restorePageLayoutInput,
['id'],
);
const existingFlatPageLayoutToRestore = flatPageLayoutMaps.byId[pageLayoutId];
if (!isDefined(existingFlatPageLayoutToRestore)) {
throw new PageLayoutException(
t`Page layout to restore not found`,
PageLayoutExceptionCode.PAGE_LAYOUT_NOT_FOUND,
);
}
if (!isDefined(existingFlatPageLayoutToRestore.deletedAt)) {
throw new PageLayoutException(
t`Page layout is not deleted and cannot be restored`,
PageLayoutExceptionCode.INVALID_PAGE_LAYOUT_DATA,
);
}
return {
...existingFlatPageLayoutToRestore,
deletedAt: null,
};
};