From 3b04efa4c081ccc3f99c686d63f3bc2d9fb42cff Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Fri, 16 Feb 2018 17:29:10 +0900 Subject: [PATCH] migrate minSpan (#10924) --- public/app/features/dashboard/dashboard_migration.ts | 3 +++ .../features/dashboard/specs/dashboard_migration.jest.ts | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/public/app/features/dashboard/dashboard_migration.ts b/public/app/features/dashboard/dashboard_migration.ts index 0a6c5d141c2..87039fccdc4 100644 --- a/public/app/features/dashboard/dashboard_migration.ts +++ b/public/app/features/dashboard/dashboard_migration.ts @@ -429,6 +429,9 @@ export class DashboardMigrator { for (let panel of row.panels) { panel.span = panel.span || DEFAULT_PANEL_SPAN; + if (panel.minSpan) { + panel.minSpan = Math.min(GRID_COLUMN_COUNT, GRID_COLUMN_COUNT / 12 * panel.minSpan); + } const panelWidth = Math.floor(panel.span) * widthFactor; const panelHeight = panel.height ? getGridHeight(panel.height) : rowGridHeight; diff --git a/public/app/features/dashboard/specs/dashboard_migration.jest.ts b/public/app/features/dashboard/specs/dashboard_migration.jest.ts index 4cfbc8eecd5..4858063ac09 100644 --- a/public/app/features/dashboard/specs/dashboard_migration.jest.ts +++ b/public/app/features/dashboard/specs/dashboard_migration.jest.ts @@ -363,6 +363,14 @@ describe('DashboardModel', function() { expect(dashboard.panels[0].repeat).toBe('server'); expect(dashboard.panels.length).toBe(2); }); + + it('minSpan should be twice', function() { + model.rows = [createRow({ height: 8 }, [[6]])]; + model.rows[0].panels[0] = { minSpan: 12 }; + + let dashboard = new DashboardModel(model); + expect(dashboard.panels[0].minSpan).toBe(24); + }); }); });