From ff89531849dc9feae4443c0520005c3f4b35f831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 14 Dec 2017 12:10:32 +0100 Subject: [PATCH] fix: ignore row clones in schema migration --- .../features/dashboard/dashboard_migration.ts | 4 ++++ .../dashboard/specs/dashboard_migration.jest.ts | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/public/app/features/dashboard/dashboard_migration.ts b/public/app/features/dashboard/dashboard_migration.ts index 95a70cbfcab..73f077c8400 100644 --- a/public/app/features/dashboard/dashboard_migration.ts +++ b/public/app/features/dashboard/dashboard_migration.ts @@ -387,6 +387,10 @@ export class DashboardMigrator { const showRows = _.some(old.rows, (row) => row.collapse || row.showTitle || row.repeat); for (let row of old.rows) { + if (row.repeatIteration) { + continue; + } + let height: any = row.height || DEFAULT_ROW_HEIGHT; const rowGridHeight = getGridHeight(height); diff --git a/public/app/features/dashboard/specs/dashboard_migration.jest.ts b/public/app/features/dashboard/specs/dashboard_migration.jest.ts index dfdcb7601a4..4254a633459 100644 --- a/public/app/features/dashboard/specs/dashboard_migration.jest.ts +++ b/public/app/features/dashboard/specs/dashboard_migration.jest.ts @@ -337,12 +337,24 @@ describe('DashboardModel', function() { expect(dashboard.panels[2].repeat).toBeUndefined(); expect(dashboard.panels[3].repeat).toBeUndefined(); }); + + it('should ignore repeated row', function() { + model.rows = [ + createRow({showTitle: true, title: "Row1", height: 8, repeat: "server"}, [[6]]), + createRow({showTitle: true, title: "Row2", height: 8, repeatIteration: 12313, repeatRowId: 1}, [[6]]), + ]; + + let dashboard = new DashboardModel(model); + expect(dashboard.panels[0].repeat).toBe("server"); + expect(dashboard.panels.length).toBe(2); + }); + }); }); function createRow(options, panelDescriptions: any[]) { const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN; - let {collapse, height, showTitle, title, repeat} = options; + let {collapse, height, showTitle, title, repeat, repeatIteration} = options; height = height * PANEL_HEIGHT_STEP; let panels = []; _.each(panelDescriptions, panelDesc => { @@ -352,7 +364,7 @@ function createRow(options, panelDescriptions: any[]) { } panels.push(panel); }); - let row = {collapse, height, showTitle, title, panels, repeat}; + let row = {collapse, height, showTitle, title, panels, repeat, repeatIteration}; return row; }