diff --git a/public/app/features/browse-dashboards/components/RecentlyDeletedActions.tsx b/public/app/features/browse-dashboards/components/RecentlyDeletedActions.tsx index 8df52a18f84..6e065e98220 100644 --- a/public/app/features/browse-dashboards/components/RecentlyDeletedActions.tsx +++ b/public/app/features/browse-dashboards/components/RecentlyDeletedActions.tsx @@ -29,11 +29,11 @@ export function RecentlyDeletedActions() { .map(([uid]) => uid); }, [selectedItemsState.dashboard]); - const dashboardOrigin: Record = {}; + const selectedDashboardOrigin: string[] = []; if (searchState.result) { for (const selectedDashboard of selectedDashboards) { const index = searchState.result.view.fields.uid.values.findIndex((e) => e === selectedDashboard); - dashboardOrigin[selectedDashboard] = searchState.result.view.fields.location.values[index]; + selectedDashboardOrigin.push(searchState.result.view.fields.location.values[index]); } } @@ -90,7 +90,7 @@ export function RecentlyDeletedActions() { component: RestoreModal, props: { selectedDashboards, - dashboardOrigin, + dashboardOrigin: selectedDashboardOrigin, onConfirm: onRestore, isLoading: isRestoreLoading, }, diff --git a/public/app/features/browse-dashboards/components/RestoreModal.tsx b/public/app/features/browse-dashboards/components/RestoreModal.tsx index e582370a773..d0e05e0dde7 100644 --- a/public/app/features/browse-dashboards/components/RestoreModal.tsx +++ b/public/app/features/browse-dashboards/components/RestoreModal.tsx @@ -11,7 +11,7 @@ export interface RestoreModalProps { onConfirm: (restoreTarget: string) => Promise; onDismiss: () => void; selectedDashboards: string[]; - dashboardOrigin: { [key: string]: string }; + dashboardOrigin: string[]; isLoading: boolean; } @@ -27,8 +27,13 @@ export const RestoreModal = ({ const numberOfDashboards = selectedDashboards.length; useEffect(() => { - if (Object.entries(dashboardOrigin).length === 1 && dashboardOrigin[selectedDashboards[0]] !== 'general') { - setRestoreTarget(dashboardOrigin[selectedDashboards[0]]); + // restoreTarget is used by the folder picker to preselect a folder and therefore enable the confirm button + // if there is only one dashboard selected or all selected dashboards come from the same folder + if ( + dashboardOrigin.length > 0 && + dashboardOrigin.every((originalLocation) => originalLocation === dashboardOrigin[0]) + ) { + setRestoreTarget(dashboardOrigin[0]); } }, [dashboardOrigin, selectedDashboards]);