NewGauge: Fixes issue with too eager migration (#113200)

This commit is contained in:
Torkel Ödegaard
2025-10-31 10:58:57 +01:00
committed by GitHub
parent 7648eac654
commit 137803a32a
2 changed files with 34 additions and 0 deletions
@@ -60,6 +60,35 @@ describe('Gauge Panel Migrations', () => {
expect(result.sparkline).toBe(true);
});
it('does not overwrite new gauge for current version', () => {
const panel = {
id: 2,
options: {
reduceOptions: {
calcs: ['lastNotNull'],
},
shape: 'circle',
gradient: 'auto',
sparkline: true,
},
fieldConfig: {
defaults: {
color: {
mode: FieldColorModeId.Fixed,
fixedColor: 'blue',
},
},
overrides: [],
},
pluginVersion: '12.4.0',
type: 'gauge',
} as Omit<PanelModel, 'fieldConfig'>;
const result = gaugePanelMigrationHandler(panel as PanelModel);
expect(result.sparkline).toBe(true);
expect(result.gradient).toBe('auto');
});
it('from 6.1.1', () => {
const panel = {
datasource: '-- Grafana --',
@@ -39,6 +39,11 @@ export function gaugePanelMigrationHandler(panel: PanelModel<Options>): Partial<
}
export function shouldMigrateGauge(panel: PanelModel): boolean {
// Test for new gauge option
if (panel.options?.shape) {
return false;
}
const previousVersion = parseFloat(panel.pluginVersion ?? '8');
return previousVersion < 13;
}