diff --git a/public/app/features/dashboard/state/PanelModel.test.ts b/public/app/features/dashboard/state/PanelModel.test.ts index 165195583fd9..fd47ecc30136 100644 --- a/public/app/features/dashboard/state/PanelModel.test.ts +++ b/public/app/features/dashboard/state/PanelModel.test.ts @@ -93,6 +93,11 @@ describe('PanelModel', () => { expect(saveModel.gridPos).toBe(undefined); }); + it('getSaveModel should not remove datasource default', () => { + const saveModel = model.getSaveModel(); + expect(saveModel.datasource).toBe(null); + }); + it('getSaveModel should remove nonPersistedProperties', () => { const saveModel = model.getSaveModel(); expect(saveModel.events).toBe(undefined); diff --git a/public/app/features/dashboard/state/PanelModel.ts b/public/app/features/dashboard/state/PanelModel.ts index 093447d53d51..c390ae0edee9 100644 --- a/public/app/features/dashboard/state/PanelModel.ts +++ b/public/app/features/dashboard/state/PanelModel.ts @@ -69,7 +69,6 @@ const mustKeepProps: { [str: string]: boolean } = { const defaults: any = { gridPos: { x: 0, y: 0, h: 3, w: 6 }, - datasource: null, targets: [{ refId: 'A' }], cachedPluginOptions: {}, transparent: false, @@ -126,6 +125,10 @@ export class PanelModel { constructor(model: any) { this.events = new Emitter(); + // should not be part of defaults as defaults are removed in save model and + // this should not be removed in save model as exporter needs to templatize it + this.datasource = null; + // copy properties from persisted model for (const property in model) { (this as any)[property] = model[property];