mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
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
This commit is contained in:
parent
4dbedb8405
commit
ac3fb6452d
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user