[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:
-43
@@ -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(),
|
||||
};
|
||||
};
|
||||
-50
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user