Commit ac3fb645 by Torkel Ödegaard Committed by GitHub

Dashboard: Fix export for sharing when panels use default data source (#19315)

* PanelModel: moved datasource: null away from defaults that are removed

* Added unit test
parent 4dbedb84
......@@ -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);
......
......@@ -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];
......
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