diff --git a/public/app/features/dashboard/components/DebugWizard/DebugWizard.tsx b/public/app/features/dashboard/components/DebugWizard/DebugWizard.tsx index 920610bc2fc..82c0ec33838 100644 --- a/public/app/features/dashboard/components/DebugWizard/DebugWizard.tsx +++ b/public/app/features/dashboard/components/DebugWizard/DebugWizard.tsx @@ -14,7 +14,7 @@ import { FeatureState, formattedValueToString, } from '@grafana/data'; -import { getTemplateSrv, locationService } from '@grafana/runtime'; +import { config, getTemplateSrv } from '@grafana/runtime'; import { Drawer, Tab, @@ -34,7 +34,7 @@ import appEvents from 'app/core/app_events'; import { contextSrv } from 'app/core/core'; import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv'; import { PanelModel } from 'app/features/dashboard/state'; -import { pendingNewDashboard } from 'app/features/dashboard/state/initDashboard'; +import { setDashboardToFetchFromLocalStorage } from 'app/features/dashboard/state/initDashboard'; import { InspectTab } from 'app/features/inspector/types'; import { Randomize } from './randomizer'; @@ -72,9 +72,10 @@ export const DebugWizard = ({ panel, plugin, onClose }: Props) => { const [rand, setRand] = useState({}); const [_, copyToClipboard] = useCopyToClipboard(); const info = useAsync(async () => { - const dash = await getDebugDashboard(panel, rand, getTimeSrv().timeRange()); - setDashboardText(JSON.stringify(dash, null, 2)); - }, [rand, panel, plugin, setDashboardText]); + const dashboard = await getDebugDashboard(panel, rand, getTimeSrv().timeRange()); + setDashboardToFetchFromLocalStorage({ meta: {}, dashboard }); + setDashboardText(JSON.stringify(dashboard, null, 2)); + }, [rand, panel, plugin, setDashboardText, currentTab]); const snapshotSize = useMemo(() => { return formattedValueToString(getValueFormat('bytes')(snapshotText?.length ?? 0)); @@ -95,9 +96,8 @@ export const DebugWizard = ({ panel, plugin, onClose }: Props) => { }; const doImportDashboard = () => { - pendingNewDashboard.dashboard = JSON.parse(snapshotText); - locationService.push('/dashboard/new'); // will load the above body - appEvents.emit(AppEvents.alertSuccess, ['Panel snapshot dashboard']); + setDashboardToFetchFromLocalStorage({ meta: {}, dashboard: JSON.parse(snapshotText) }); + global.open(config.appUrl + 'dashboard/new', '_blank'); }; const doDownloadDashboard = () => { @@ -130,7 +130,7 @@ export const DebugWizard = ({ panel, plugin, onClose }: Props) => { return ( { ) : ( -
+ <> {false && ( { - -
-
-  Requires Testdata DB to be installed -
+
- {/* TODO: can we iframe in the preview? */} - {false &&