From f932952c68f19b853bb81bd55db03827a90aed67 Mon Sep 17 00:00:00 2001 From: kay delaney <45561153+kaydelaney@users.noreply.github.com> Date: Tue, 4 Apr 2023 19:56:47 +0100 Subject: [PATCH] Row-repeats: Fix disappearing panel when viewed panel is refreshed (#58392) * Row-repeats: Fix disappearing panel when viewed panel is refreshed Close #57159 --- .betterer.results | 3 +- .../state/DashboardModel.repeat.test.ts | 60 ------------------- .../dashboard/state/DashboardModel.ts | 2 +- 3 files changed, 2 insertions(+), 63 deletions(-) diff --git a/.betterer.results b/.betterer.results index 3a94de50eb6..50a78b99fb8 100644 --- a/.betterer.results +++ b/.betterer.results @@ -2523,8 +2523,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"] + [0, 0, 0, "Unexpected any. Specify a different type.", "6"] ], "public/app/features/dashboard/state/DashboardModel.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] diff --git a/public/app/features/dashboard/state/DashboardModel.repeat.test.ts b/public/app/features/dashboard/state/DashboardModel.repeat.test.ts index e95bc66d36d..1c6e8719856 100644 --- a/public/app/features/dashboard/state/DashboardModel.repeat.test.ts +++ b/public/app/features/dashboard/state/DashboardModel.repeat.test.ts @@ -5,8 +5,6 @@ import { DashboardPanelsChangedEvent } from 'app/types/events'; import { getDashboardModel } from '../../../../test/helpers/getDashboardModel'; import { DashboardModel } from '../state/DashboardModel'; -import { PanelModel } from './PanelModel'; - jest.mock('app/core/services/context_srv', () => ({})); describe('given dashboard with panel repeat', () => { @@ -802,61 +800,3 @@ describe('given dashboard with row and repeats on same row', () => { expect(dashboard.panels[17].gridPos).toEqual({ x: x2, y: 31, w: w2, h: h2 }); }); }); - -describe('given panel is in view mode', () => { - let dashboard: any; - - beforeEach(() => { - const dashboardJSON = { - panels: [ - { - id: 1, - repeat: 'apps', - repeatDirection: 'h', - gridPos: { x: 0, y: 0, h: 2, w: 24 }, - }, - ], - templating: { - list: [ - { - name: 'apps', - type: 'custom', - current: { - text: 'se1, se2, se3', - value: ['se1', 'se2', 'se3'], - }, - options: [ - { text: 'se1', value: 'se1', selected: true }, - { text: 'se2', value: 'se2', selected: true }, - { text: 'se3', value: 'se3', selected: true }, - { text: 'se4', value: 'se4', selected: false }, - ], - }, - ], - }, - }; - - dashboard = getDashboardModel(dashboardJSON); - dashboard.initViewPanel( - new PanelModel({ - id: 2, - repeat: undefined, - repeatDirection: 'h', - panels: [ - { - id: 2, - repeat: 'apps', - repeatDirection: 'h', - gridPos: { x: 0, y: 0, h: 2, w: 24 }, - }, - ], - repeatPanelId: 2, - }) - ); - dashboard.processRepeats(); - }); - - it('should set correct repeated panel to be in view', () => { - expect(dashboard.panels[1].isViewing).toBeTruthy(); - }); -}); diff --git a/public/app/features/dashboard/state/DashboardModel.ts b/public/app/features/dashboard/state/DashboardModel.ts index ebca913d348..b4cb4fbc8fc 100644 --- a/public/app/features/dashboard/state/DashboardModel.ts +++ b/public/app/features/dashboard/state/DashboardModel.ts @@ -576,7 +576,7 @@ export class DashboardModel implements TimeModel { } processRepeats() { - if (this.isSnapshotTruthy() || !this.hasVariables()) { + if (this.isSnapshotTruthy() || !this.hasVariables() || this.panelInView) { return; }