Dashboard Migrator: persist thresholds param if already set (#20458)
(cherry picked from commit 836cf8e639)
This commit is contained in:
committed by
Marcus Efraimsson
parent
64e294c586
commit
5bc748cb56
@@ -139,6 +139,27 @@ describe('DashboardModel', () => {
|
||||
expect(graph.thresholds[1].value).toBe(400);
|
||||
expect(graph.thresholds[1].fillColor).toBe('red');
|
||||
});
|
||||
|
||||
it('graph thresholds should be migrated onto specified thresholds', () => {
|
||||
model = new DashboardModel({
|
||||
panels: [
|
||||
{
|
||||
type: 'graph',
|
||||
y_formats: ['kbyte', 'ms'],
|
||||
grid: {
|
||||
threshold1: 200,
|
||||
threshold2: 400,
|
||||
},
|
||||
thresholds: [{ value: 100 }],
|
||||
},
|
||||
],
|
||||
});
|
||||
graph = model.panels[0];
|
||||
expect(graph.thresholds.length).toBe(3);
|
||||
expect(graph.thresholds[0].value).toBe(100);
|
||||
expect(graph.thresholds[1].value).toBe(200);
|
||||
expect(graph.thresholds[2].value).toBe(400);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when migrating to the grid layout', () => {
|
||||
|
||||
@@ -316,7 +316,9 @@ export class DashboardMigrator {
|
||||
return;
|
||||
}
|
||||
|
||||
panel.thresholds = [];
|
||||
if (!panel.thresholds) {
|
||||
panel.thresholds = [];
|
||||
}
|
||||
const t1: any = {},
|
||||
t2: any = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user