From 40b771c04db29c705e0edc027d90c56a021fb5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 3 May 2019 10:29:22 +0200 Subject: [PATCH] Panels: Fixed issue with panel type change and data updates (#16871) --- public/app/features/dashboard/state/PanelModel.test.ts | 8 ++++++++ public/app/features/dashboard/state/PanelModel.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/state/PanelModel.test.ts b/public/app/features/dashboard/state/PanelModel.test.ts index ca88584ad08..ceda847adf6 100644 --- a/public/app/features/dashboard/state/PanelModel.test.ts +++ b/public/app/features/dashboard/state/PanelModel.test.ts @@ -87,7 +87,10 @@ describe('PanelModel', () => { }); describe('when changing panel type', () => { + let panelQueryRunner: any; + beforeEach(() => { + panelQueryRunner = model.getQueryRunner(); model.changePlugin(getPanelPlugin({ id: 'graph' })); model.alert = { id: 2 }; }); @@ -105,6 +108,11 @@ describe('PanelModel', () => { model.changePlugin(getPanelPlugin({ id: 'table' })); expect(model.alert).toBe(undefined); }); + + it('getQueryRunner() should return same instance after plugin change', () => { + const sameQueryRunner = model.getQueryRunner(); + expect(panelQueryRunner).toBe(sameQueryRunner); + }); }); describe('when changing from angular panel', () => { diff --git a/public/app/features/dashboard/state/PanelModel.ts b/public/app/features/dashboard/state/PanelModel.ts index a09540adc9a..c785cd3630a 100644 --- a/public/app/features/dashboard/state/PanelModel.ts +++ b/public/app/features/dashboard/state/PanelModel.ts @@ -33,7 +33,6 @@ const notPersistedProperties: { [str: string]: boolean } = { // To make sure the change happens without strange bugs happening when panels use same // named property with different type / value expectations // This is not required for react panels - const mustKeepProps: { [str: string]: boolean } = { id: true, gridPos: true, @@ -63,6 +62,7 @@ const mustKeepProps: { [str: string]: boolean } = { cachedPluginOptions: true, transparent: true, pluginVersion: true, + queryRunner: true, }; const defaults: any = {