Dashboards: Fixes repeating by row and no refresh (#46565) (#46614)

(cherry picked from commit 31d141b267)

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-03-16 09:24:01 +01:00
committed by GitHub
co-authored by Torkel Ödegaard
parent c00e4668ab
commit f1cd74a5e9
2 changed files with 8 additions and 1 deletions
@@ -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 = [
{
@@ -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;