diff --git a/public/app/api/clients/folder/v1beta1/hooks.ts b/public/app/api/clients/folder/v1beta1/hooks.ts index fca72781955..e79e3bab4c5 100644 --- a/public/app/api/clients/folder/v1beta1/hooks.ts +++ b/public/app/api/clients/folder/v1beta1/hooks.ts @@ -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, diff --git a/public/app/features/browse-dashboards/api/browseDashboardsAPI.ts b/public/app/features/browse-dashboards/api/browseDashboardsAPI.ts index c55a6b48ea3..d9788cda50b 100644 --- a/public/app/features/browse-dashboards/api/browseDashboardsAPI.ts +++ b/public/app/features/browse-dashboards/api/browseDashboardsAPI.ts @@ -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(); }); }, }), diff --git a/public/app/features/browse-dashboards/components/BrowseActions/DeleteModal.tsx b/public/app/features/browse-dashboards/components/BrowseActions/DeleteModal.tsx index 6db8c35928f..187f0eb1543 100644 --- a/public/app/features/browse-dashboards/components/BrowseActions/DeleteModal.tsx +++ b/public/app/features/browse-dashboards/components/BrowseActions/DeleteModal.tsx @@ -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 { diff --git a/public/app/features/browse-dashboards/components/PermanentlyDeleteModal.tsx b/public/app/features/browse-dashboards/components/PermanentlyDeleteModal.tsx deleted file mode 100644 index 17bc1df184a..00000000000 --- a/public/app/features/browse-dashboards/components/PermanentlyDeleteModal.tsx +++ /dev/null @@ -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; - 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 ( - - - This action will delete {{ numberOfDashboards }} dashboards. - - - } - 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} - /> - ); -}; diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 46459e68f27..8573bb03880 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -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.",