Commit 836cf8e6 by Gabriel Kent Committed by Ryan McKinley

Dashboard Migrator: persist thresholds param if already set (#20458)

parent d02f4ea6
...@@ -139,6 +139,27 @@ describe('DashboardModel', () => { ...@@ -139,6 +139,27 @@ describe('DashboardModel', () => {
expect(graph.thresholds[1].value).toBe(400); expect(graph.thresholds[1].value).toBe(400);
expect(graph.thresholds[1].fillColor).toBe('red'); 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', () => { describe('when migrating to the grid layout', () => {
......
...@@ -316,7 +316,9 @@ export class DashboardMigrator { ...@@ -316,7 +316,9 @@ export class DashboardMigrator {
return; return;
} }
if (!panel.thresholds) {
panel.thresholds = []; panel.thresholds = [];
}
const t1: any = {}, const t1: any = {},
t2: any = {}; t2: any = {};
......
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