mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
StatPanels: Fixed migration from old singlestat and default min & max being copied even when gauge was disbled (#21820)
This commit is contained in:
parent
c344a3a66e
commit
13948c0b76
@ -86,7 +86,7 @@ export function sharedSingleStatPanelChangedHandler(
|
|||||||
defaults.mappings = mappings;
|
defaults.mappings = mappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel.gauge) {
|
if (panel.gauge && panel.gauge.show) {
|
||||||
defaults.min = panel.gauge.minValue;
|
defaults.min = panel.gauge.minValue;
|
||||||
defaults.max = panel.gauge.maxValue;
|
defaults.max = panel.gauge.maxValue;
|
||||||
}
|
}
|
||||||
|
@ -103,4 +103,23 @@ describe('Gauge Panel Migrations', () => {
|
|||||||
expect(newOptions.showThresholdMarkers).toBe(true);
|
expect(newOptions.showThresholdMarkers).toBe(true);
|
||||||
expect(newOptions.showThresholdLabels).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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user