Dashboard: Fix version restore (#72866)

* Dashboard: Fix version restore

* Update comment
This commit is contained in:
Alex Khomenko
2023-08-18 15:17:45 +03:00
committed by GitHub
parent b0ed67a306
commit dd21584961
2 changed files with 4 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ export const RevertDashboardModal = ({ hideModal, version }: RevertDashboardModa
const { state, onRestoreDashboard } = useDashboardRestore(version); const { state, onRestoreDashboard } = useDashboardRestore(version);
useEffect(() => { useEffect(() => {
if (state.loading === false && state.value) { if (!state.loading && state.value) {
hideModal(); hideModal();
} }
}, [state, hideModal]); }, [state, hideModal]);

View File

@@ -6,11 +6,14 @@ import { locationService } from '@grafana/runtime';
import { useAppNotification } from 'app/core/copy/appNotification'; import { useAppNotification } from 'app/core/copy/appNotification';
import { useSelector } from 'app/types'; import { useSelector } from 'app/types';
import { dashboardWatcher } from '../../../live/dashboard/dashboardWatcher';
import { DashboardModel } from '../../state'; import { DashboardModel } from '../../state';
import { historySrv } from './HistorySrv'; import { historySrv } from './HistorySrv';
const restoreDashboard = async (version: number, dashboard: DashboardModel) => { const restoreDashboard = async (version: number, dashboard: DashboardModel) => {
// Skip the watcher logic for this save since it's handled by the hook
dashboardWatcher.ignoreNextSave();
return await historySrv.restoreDashboard(dashboard, version); return await historySrv.restoreDashboard(dashboard, version);
}; };