Commit 13948c0b by Torkel Ödegaard Committed by GitHub

StatPanels: Fixed migration from old singlestat and default min & max being…

StatPanels: Fixed migration from old singlestat and default min & max being copied even when gauge was disbled (#21820)
parent c344a3a6
......@@ -86,7 +86,7 @@ export function sharedSingleStatPanelChangedHandler(
defaults.mappings = mappings;
}
if (panel.gauge) {
if (panel.gauge && panel.gauge.show) {
defaults.min = panel.gauge.minValue;
defaults.max = panel.gauge.maxValue;
}
......
......@@ -103,4 +103,23 @@ describe('Gauge Panel Migrations', () => {
expect(newOptions.showThresholdMarkers).toBe(true);
expect(newOptions.showThresholdLabels).toBe(true);
});
it('change from angular singlestatt with no enabled gauge', () => {
const old: any = {
angular: {
format: 'ms',
decimals: 7,
gauge: {
maxValue: 150,
minValue: -10,
show: false,
},
},
};
const newOptions = gaugePanelChangedHandler({} as any, 'singlestat', old);
expect(newOptions.fieldOptions.defaults.unit).toBe('ms');
expect(newOptions.fieldOptions.defaults.min).toBe(undefined);
expect(newOptions.fieldOptions.defaults.max).toBe(undefined);
});
});
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