NewGauge: Fixes issue with too eager migration (#113200)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user