Restore dashboards: Update cache invalidation (#110702)

* Restore dashboards: Update cache invalidation

* Delete unused component

* Update i18n

* Restore analytics toggle
This commit is contained in:
Alex Khomenko
2025-09-08 13:32:07 +03:00
committed by GitHub
parent d9f0d642cc
commit 7020bdd7e1
5 changed files with 5 additions and 64 deletions
@@ -32,6 +32,7 @@ import {
import { PAGE_SIZE } from '../../../../features/browse-dashboards/api/services';
import { refetchChildren, refreshParents } from '../../../../features/browse-dashboards/state/actions';
import { GENERAL_FOLDER_UID } from '../../../../features/search/constants';
import { deletedDashboardsCache } from '../../../../features/search/service/deletedDashboardsCache';
import { useDispatch } from '../../../../types/store';
import { useLazyGetDisplayMappingQuery } from '../../iam/v0alpha1';
@@ -298,6 +299,7 @@ export function useCreateFolder() {
const result = await createFolder(payload);
refresh({ childrenOf: folder.parentUid });
deletedDashboardsCache.clear();
return {
...result,
@@ -324,14 +324,14 @@ export const browseDashboardsAPI = createApi({
forceDeleteRules: false,
},
});
// Clear the deleted dashboards cache since deleting a folder also deletes its dashboards
deletedDashboardsCache.clear();
}
return { data: undefined };
},
onQueryStarted: ({ folderUIDs }, { queryFulfilled, dispatch }) => {
queryFulfilled.then(() => {
dispatch(refreshParents(folderUIDs));
// Clear the deleted dashboards cache since deleting a folder also deletes its dashboards
deletedDashboardsCache.clear();
});
},
}),
@@ -28,7 +28,7 @@ export const DeleteModal = ({ onConfirm, onDismiss, selectedItems, ...props }: P
folder: Object.keys(selectedItems.folder).length,
},
source: 'browse_dashboards',
restore_enabled: false,
restore_enabled: Boolean(config.featureToggles.restoreDashboards),
});
setIsDeleting(true);
try {
@@ -1,53 +0,0 @@
import { Trans, t } from '@grafana/i18n';
import { reportInteraction } from '@grafana/runtime';
import { ConfirmModal, Text } from '@grafana/ui';
interface PermanentlyDeleteModalProps {
isOpen: boolean;
onConfirm: () => Promise<void>;
onDismiss: () => void;
selectedDashboards: string[];
isLoading: boolean;
}
export const PermanentlyDeleteModal = ({
onConfirm,
onDismiss,
selectedDashboards,
isLoading,
...props
}: PermanentlyDeleteModalProps) => {
const numberOfDashboards = selectedDashboards.length;
const onDelete = async () => {
reportInteraction('grafana_delete_permanently_confirm_clicked', {
item_counts: {
dashboard: numberOfDashboards,
},
});
await onConfirm();
onDismiss();
};
return (
<ConfirmModal
body={
<Text element="p">
<Trans i18nKey="recently-deleted.permanently-delete-modal.text" count={numberOfDashboards}>
This action will delete {{ numberOfDashboards }} dashboards.
</Trans>
</Text>
}
title={t('recently-deleted.permanently-delete-modal.title', 'Permanently Delete Dashboards')}
confirmationText={t('recently-deleted.permanently-delete-modal.confirm-text', 'Delete')}
confirmText={
isLoading
? t('recently-deleted.permanently-delete-modal.delete-loading', 'Deleting...')
: t('recently-deleted.permanently-delete-modal.delete-button', 'Delete')
}
confirmButtonVariant="destructive"
onConfirm={onDelete}
onDismiss={onDismiss}
{...props}
/>
);
};
-8
View File
@@ -11956,14 +11956,6 @@
"no-deleted-dashboards-text": "When you delete a dashboard, it will appear here for 30 days before being permanently deleted. Your organization administrator can restore recently-deleted dashboards.",
"no-search-result": "No results found for your query"
},
"permanently-delete-modal": {
"confirm-text": "Delete",
"delete-button": "Delete",
"delete-loading": "Deleting...",
"text_one": "This action will delete {{numberOfDashboards}} dashboards.",
"text_other": "This action will delete {{numberOfDashboards}} dashboards.",
"title": "Permanently Delete Dashboards"
},
"restore-modal": {
"folder-picker-text_one": "Please choose a folder where your dashboards will be restored.",
"folder-picker-text_other": "Please choose a folder where your dashboards will be restored.",