Commit 0c086795 by ryan

check types better

parent 75022ebd
...@@ -257,7 +257,10 @@ export class PanelModel { ...@@ -257,7 +257,10 @@ export class PanelModel {
// Callback that can validate and migrate any existing settings // Callback that can validate and migrate any existing settings
if (hook) { if (hook) {
Object.assign(this.options, hook(this.options || {}, oldPluginId, oldOptions.options)); this.options = this.options || {};
const old = oldOptions ? oldOptions.options : null;
Object.assign(this.options, hook(this.options, oldPluginId, old));
} }
} }
......
...@@ -8,8 +8,10 @@ export const reactPanel = new ReactPanelPlugin<BarGaugeOptions>(BarGaugePanel); ...@@ -8,8 +8,10 @@ export const reactPanel = new ReactPanelPlugin<BarGaugeOptions>(BarGaugePanel);
reactPanel.setEditor(BarGaugePanelEditor); reactPanel.setEditor(BarGaugePanelEditor);
reactPanel.setDefaults(defaults); reactPanel.setDefaults(defaults);
reactPanel.setPanelTypeChangedHook((options: BarGaugeOptions, prevPluginId: string, prevOptions: any) => { reactPanel.setPanelTypeChangedHook((options: BarGaugeOptions, prevPluginId?: string, prevOptions?: any) => {
if (prevOptions.valueOptions) { console.log('BAR Gauge', options, prevPluginId, prevOptions);
if (prevOptions && prevOptions.valueOptions) {
options.valueOptions = prevOptions.valueOptions; options.valueOptions = prevOptions.valueOptions;
options.thresholds = prevOptions.thresholds; options.thresholds = prevOptions.thresholds;
options.maxValue = prevOptions.maxValue; options.maxValue = prevOptions.maxValue;
......
...@@ -8,8 +8,10 @@ export const reactPanel = new ReactPanelPlugin<GaugeOptions>(GaugePanel); ...@@ -8,8 +8,10 @@ export const reactPanel = new ReactPanelPlugin<GaugeOptions>(GaugePanel);
reactPanel.setEditor(GaugePanelEditor); reactPanel.setEditor(GaugePanelEditor);
reactPanel.setDefaults(defaults); reactPanel.setDefaults(defaults);
reactPanel.setPanelTypeChangedHook((options: GaugeOptions, prevPluginId: string, prevOptions: any) => { reactPanel.setPanelTypeChangedHook((options: GaugeOptions, prevPluginId?: string, prevOptions?: any) => {
if (prevOptions.valueOptions) { console.log('BAR Gauge', options, prevPluginId, prevOptions);
if (prevOptions && prevOptions.valueOptions) {
options.valueOptions = prevOptions.valueOptions; options.valueOptions = prevOptions.valueOptions;
options.thresholds = prevOptions.thresholds; options.thresholds = prevOptions.thresholds;
options.maxValue = prevOptions.maxValue; options.maxValue = prevOptions.maxValue;
......
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