Row-repeats: Fix disappearing panel when viewed panel is refreshed (#58392)

* Row-repeats: Fix disappearing panel when viewed panel is refreshed

Close #57159
This commit is contained in:
kay delaney 2023-04-04 19:56:47 +01:00 committed by GitHub
parent 445734888b
commit f932952c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 63 deletions

View File

@ -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"]

View File

@ -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();
});
});

View File

@ -576,7 +576,7 @@ export class DashboardModel implements TimeModel {
}
processRepeats() {
if (this.isSnapshotTruthy() || !this.hasVariables()) {
if (this.isSnapshotTruthy() || !this.hasVariables() || this.panelInView) {
return;
}