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';
import appEvents from 'app/core/app_events';
import config from 'app/core/config';
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
import { DataSourceResponse } from 'app/types/events';
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 { ContextSrv, contextSrv } from './context_srv';
import { Emitter } from '../utils/emitter';
......@@ -260,11 +259,11 @@ export class BackendSrv implements BackendService {
}
saveDashboard(
dash: DashboardModel,
dashboard: DashboardDataDTO,
{ message = '', folderId, overwrite = false }: { message?: string; folderId?: number; overwrite?: boolean } = {}
) {
return this.post('/api/dashboards/db/', {
dashboard: dash,
dashboard,
folderId,
overwrite,
message,
......@@ -319,13 +318,12 @@ export class BackendSrv implements BackendService {
private async moveDashboard(uid: string, toFolder: FolderInfo) {
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) {
return { alreadyInFolder: true };
}
const clone = model.getSaveModelClone();
const clone = fullDash.dashboard;
const options = {
folderId: toFolder.id,
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