Dashboard: Remove DTO cache and scene cache on dashboard delete (#107460)
This commit is contained in:
@@ -19,6 +19,7 @@ import { PermissionLevelString } from 'app/types/acl';
|
||||
import { SaveDashboardResponseDTO, ImportDashboardResponseDTO } from 'app/types/dashboard';
|
||||
import { FolderListItemDTO, FolderDTO, DescendantCount, DescendantCountDTO } from 'app/types/folders';
|
||||
|
||||
import { getDashboardScenePageStateManager } from '../../dashboard-scene/pages/DashboardScenePageStateManager';
|
||||
import { refetchChildren, refreshParents } from '../state/actions';
|
||||
import { DashboardTreeSelection } from '../types';
|
||||
|
||||
@@ -287,6 +288,7 @@ export const browseDashboardsAPI = createApi({
|
||||
queryFn: async ({ selectedItems }, _api, _extraOptions, baseQuery) => {
|
||||
const selectedDashboards = Object.keys(selectedItems.dashboard).filter((uid) => selectedItems.dashboard[uid]);
|
||||
const selectedFolders = Object.keys(selectedItems.folder).filter((uid) => selectedItems.folder[uid]);
|
||||
const pageStateManager = getDashboardScenePageStateManager();
|
||||
// Delete all the folders sequentially
|
||||
// TODO error handling here
|
||||
for (const folderUID of selectedFolders) {
|
||||
@@ -331,6 +333,9 @@ export const browseDashboardsAPI = createApi({
|
||||
|
||||
await getDashboardAPI().deleteDashboard(dashboardUID, true);
|
||||
|
||||
pageStateManager.clearDashboardCache();
|
||||
pageStateManager.removeSceneCache(dashboardUID);
|
||||
|
||||
// handling success alerts for these feature toggles
|
||||
// for legacy response, the success alert will be triggered by showSuccessAlert function in public/app/core/services/backend_srv.ts
|
||||
if (config.featureToggles.kubernetesDashboards) {
|
||||
|
||||
@@ -362,6 +362,10 @@ abstract class DashboardScenePageStateManagerBase<T>
|
||||
this.cache[cacheKey] = scene;
|
||||
}
|
||||
|
||||
public removeSceneCache(cacheKey: string) {
|
||||
delete this.cache[cacheKey];
|
||||
}
|
||||
|
||||
public clearSceneCache() {
|
||||
this.cache = {};
|
||||
}
|
||||
@@ -823,6 +827,11 @@ export class UnifiedDashboardScenePageStateManager extends DashboardScenePageSta
|
||||
this.activeManager.setSceneCache(cacheKey, scene);
|
||||
}
|
||||
|
||||
public removeSceneCache(cacheKey: string): void {
|
||||
this.v1Manager.removeSceneCache(cacheKey);
|
||||
this.v2Manager.removeSceneCache(cacheKey);
|
||||
}
|
||||
|
||||
public getCache() {
|
||||
return this.activeManager.getCache();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user