[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:
@@ -79,89 +79,6 @@ export class DashboardSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
async softDeleteLinkedDashboardsByPageLayoutId({
|
||||
pageLayoutId,
|
||||
workspaceId,
|
||||
deletedAt,
|
||||
}: {
|
||||
pageLayoutId: string;
|
||||
workspaceId: string;
|
||||
deletedAt: Date;
|
||||
}): Promise<void> {
|
||||
const isDashboard = await this.isPageLayoutOfTypeDashboard({
|
||||
pageLayoutId,
|
||||
workspaceId,
|
||||
});
|
||||
|
||||
if (!isDashboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
const authContext = buildSystemAuthContext(workspaceId);
|
||||
|
||||
try {
|
||||
await this.globalWorkspaceOrmManager.executeInWorkspaceContext(
|
||||
authContext,
|
||||
async () => {
|
||||
const dashboardRepository =
|
||||
await this.globalWorkspaceOrmManager.getRepository(
|
||||
workspaceId,
|
||||
'dashboard',
|
||||
{ shouldBypassPermissionChecks: true },
|
||||
);
|
||||
|
||||
await dashboardRepository.update({ pageLayoutId }, { deletedAt });
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
`Failed to soft delete dashboards for page layout ${pageLayoutId}: ${error}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async restoreLinkedDashboardsByPageLayoutId({
|
||||
pageLayoutId,
|
||||
workspaceId,
|
||||
}: {
|
||||
pageLayoutId: string;
|
||||
workspaceId: string;
|
||||
}): Promise<void> {
|
||||
const isDashboard = await this.isPageLayoutOfTypeDashboard({
|
||||
pageLayoutId,
|
||||
workspaceId,
|
||||
});
|
||||
|
||||
if (!isDashboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
const authContext = buildSystemAuthContext(workspaceId);
|
||||
|
||||
try {
|
||||
await this.globalWorkspaceOrmManager.executeInWorkspaceContext(
|
||||
authContext,
|
||||
async () => {
|
||||
const dashboardRepository =
|
||||
await this.globalWorkspaceOrmManager.getRepository(
|
||||
workspaceId,
|
||||
'dashboard',
|
||||
{ shouldBypassPermissionChecks: true },
|
||||
);
|
||||
|
||||
await dashboardRepository.update(
|
||||
{ pageLayoutId },
|
||||
{ deletedAt: null },
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
`Failed to restore dashboards for page layout ${pageLayoutId}: ${error}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async updateLinkedDashboardsUpdatedAtByTabId({
|
||||
tabId,
|
||||
workspaceId,
|
||||
|
||||
Reference in New Issue
Block a user