From f1cd74a5e9b0b1b994745535a0924688b0df572c Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 16 Mar 2022 01:24:01 -0700 Subject: [PATCH] Dashboards: Fixes repeating by row and no refresh (#46565) (#46614) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 31d141b2675245fb4366eff71b4a01995be05204) Co-authored-by: Torkel Ödegaard --- .../dashboard/state/DashboardModel.repeat.test.ts | 8 ++++++++ public/app/features/dashboard/state/DashboardModel.ts | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/state/DashboardModel.repeat.test.ts b/public/app/features/dashboard/state/DashboardModel.repeat.test.ts index 92ab69d029a..e393b98d8eb 100644 --- a/public/app/features/dashboard/state/DashboardModel.repeat.test.ts +++ b/public/app/features/dashboard/state/DashboardModel.repeat.test.ts @@ -587,6 +587,14 @@ describe('given dashboard with row and panel repeat', () => { expect(panelTypes).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph']); }); + it('Row repeat should create new panel keys every repeat cycle', () => { + // This is the first repeated panel inside the second repeated row + // Since we create a new panel model every time (and new panel events bus) we need to create a new key here to trigger a re-mount & re-subscribe + const key1 = dashboard.panels[3].key; + dashboard.processRepeats(); + expect(key1).not.toEqual(dashboard.panels[3].key); + }); + it('should clean up old repeated panels', () => { dashboardJSON.panels = [ { diff --git a/public/app/features/dashboard/state/DashboardModel.ts b/public/app/features/dashboard/state/DashboardModel.ts index e2ed3c0a0e6..91ac6253e0b 100644 --- a/public/app/features/dashboard/state/DashboardModel.ts +++ b/public/app/features/dashboard/state/DashboardModel.ts @@ -796,7 +796,6 @@ export class DashboardModel { updateRepeatedPanelIds(panel: PanelModel, repeatedByRow?: boolean) { panel.repeatPanelId = panel.id; panel.id = this.getNextPanelId(); - panel.key = `${panel.id}`; panel.repeatIteration = this.iteration; if (repeatedByRow) { panel.repeatedByRow = true;