Commit 3a469f6c by Torkel Ödegaard Committed by GitHub

MoveDashboard: Fix for moving dashboard caused all variables to be lost (#25005)

* MoveDashboard: Fix moving caused all variables to be lost

* fix typescript issue
parent 60e7b63c
...@@ -6,10 +6,9 @@ import { AppEvents } from '@grafana/data'; ...@@ -6,10 +6,9 @@ import { AppEvents } from '@grafana/data';
import appEvents from 'app/core/app_events'; import appEvents from 'app/core/app_events';
import config from 'app/core/config'; import config from 'app/core/config';
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
import { DataSourceResponse } from 'app/types/events'; import { DataSourceResponse } from 'app/types/events';
import { DashboardSearchHit } from 'app/features/search/types'; import { DashboardSearchHit } from 'app/features/search/types';
import { CoreEvents, DashboardDTO, FolderInfo } from 'app/types'; import { CoreEvents, DashboardDTO, FolderInfo, DashboardDataDTO } from 'app/types';
import { coreModule } from 'app/core/core_module'; import { coreModule } from 'app/core/core_module';
import { ContextSrv, contextSrv } from './context_srv'; import { ContextSrv, contextSrv } from './context_srv';
import { Emitter } from '../utils/emitter'; import { Emitter } from '../utils/emitter';
...@@ -260,11 +259,11 @@ export class BackendSrv implements BackendService { ...@@ -260,11 +259,11 @@ export class BackendSrv implements BackendService {
} }
saveDashboard( saveDashboard(
dash: DashboardModel, dashboard: DashboardDataDTO,
{ message = '', folderId, overwrite = false }: { message?: string; folderId?: number; overwrite?: boolean } = {} { message = '', folderId, overwrite = false }: { message?: string; folderId?: number; overwrite?: boolean } = {}
) { ) {
return this.post('/api/dashboards/db/', { return this.post('/api/dashboards/db/', {
dashboard: dash, dashboard,
folderId, folderId,
overwrite, overwrite,
message, message,
...@@ -319,13 +318,12 @@ export class BackendSrv implements BackendService { ...@@ -319,13 +318,12 @@ export class BackendSrv implements BackendService {
private async moveDashboard(uid: string, toFolder: FolderInfo) { private async moveDashboard(uid: string, toFolder: FolderInfo) {
const fullDash: DashboardDTO = await this.getDashboardByUid(uid); const fullDash: DashboardDTO = await this.getDashboardByUid(uid);
const model = new DashboardModel(fullDash.dashboard, fullDash.meta);
if ((!fullDash.meta.folderId && toFolder.id === 0) || fullDash.meta.folderId === toFolder.id) { if ((!fullDash.meta.folderId && toFolder.id === 0) || fullDash.meta.folderId === toFolder.id) {
return { alreadyInFolder: true }; return { alreadyInFolder: true };
} }
const clone = model.getSaveModelClone(); const clone = fullDash.dashboard;
const options = { const options = {
folderId: toFolder.id, folderId: toFolder.id,
overwrite: false, overwrite: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment