Commit 05e37e92 by Torkel Ödegaard Committed by GitHub

PanelModel: Make sure the angular options are passed to react panel type changed handler (#30441)

parent b9fd4dba
...@@ -364,13 +364,13 @@ export class PanelModel implements DataConfigSource { ...@@ -364,13 +364,13 @@ export class PanelModel implements DataConfigSource {
changePlugin(newPlugin: PanelPlugin) { changePlugin(newPlugin: PanelPlugin) {
const pluginId = newPlugin.meta.id; const pluginId = newPlugin.meta.id;
const oldOptions: any = this.getOptionsToRemember(); const oldOptions: any = this.getOptionsToRemember();
const oldFieldConfig = this.fieldConfig; const prevFieldConfig = this.fieldConfig;
const oldPluginId = this.type; const oldPluginId = this.type;
const wasAngular = this.isAngularPlugin(); const wasAngular = this.isAngularPlugin();
this.cachedPluginOptions[oldPluginId] = { this.cachedPluginOptions[oldPluginId] = {
properties: oldOptions, properties: oldOptions,
fieldConfig: oldFieldConfig, fieldConfig: prevFieldConfig,
}; };
this.clearPropertiesBeforePluginChange(); this.clearPropertiesBeforePluginChange();
...@@ -378,15 +378,8 @@ export class PanelModel implements DataConfigSource { ...@@ -378,15 +378,8 @@ export class PanelModel implements DataConfigSource {
// Let panel plugins inspect options from previous panel and keep any that it can use // Let panel plugins inspect options from previous panel and keep any that it can use
if (newPlugin.onPanelTypeChanged) { if (newPlugin.onPanelTypeChanged) {
let oldOptions: any = {}; const prevOptions = wasAngular ? { angular: oldOptions } : oldOptions.options;
Object.assign(this.options, newPlugin.onPanelTypeChanged(this, oldPluginId, prevOptions, prevFieldConfig));
if (wasAngular) {
oldOptions = { angular: oldOptions };
} else if (oldOptions && oldOptions.options) {
oldOptions = oldOptions.options;
}
Object.assign(this.options, newPlugin.onPanelTypeChanged(this, oldPluginId, oldOptions, oldFieldConfig));
} }
// switch // switch
......
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