From f47542db28a374f3c699c0539f564248a868f578 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Mon, 19 Feb 2018 17:07:29 +0900 Subject: [PATCH] migrate panels in collapsed rows (#10948) --- public/app/features/dashboard/dashboard_migration.ts | 7 ++++++- .../features/dashboard/specs/dashboard_migration.jest.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/dashboard_migration.ts b/public/app/features/dashboard/dashboard_migration.ts index 87039fccdc4..885ba9fdbac 100644 --- a/public/app/features/dashboard/dashboard_migration.ts +++ b/public/app/features/dashboard/dashboard_migration.ts @@ -18,7 +18,7 @@ export class DashboardMigrator { } updateSchema(old) { - var i, j, k; + var i, j, k, n; var oldVersion = this.dashboard.schemaVersion; var panelUpgrades = []; this.dashboard.schemaVersion = 16; @@ -372,6 +372,11 @@ export class DashboardMigrator { for (j = 0; j < this.dashboard.panels.length; j++) { for (k = 0; k < panelUpgrades.length; k++) { panelUpgrades[k].call(this, this.dashboard.panels[j]); + if (this.dashboard.panels[j].panels) { + for (n = 0; n < this.dashboard.panels[j].panels.length; n++) { + panelUpgrades[k].call(this, this.dashboard.panels[j].panels[n]); + } + } } } } diff --git a/public/app/features/dashboard/specs/dashboard_migration.jest.ts b/public/app/features/dashboard/specs/dashboard_migration.jest.ts index 4858063ac09..931527ec732 100644 --- a/public/app/features/dashboard/specs/dashboard_migration.jest.ts +++ b/public/app/features/dashboard/specs/dashboard_migration.jest.ts @@ -371,6 +371,14 @@ describe('DashboardModel', function() { let dashboard = new DashboardModel(model); expect(dashboard.panels[0].minSpan).toBe(24); }); + + it('should assign id', function() { + model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]])]; + model.rows[0].panels[0] = { }; + + let dashboard = new DashboardModel(model); + expect(dashboard.panels[0].id).toBe(1); + }); }); });