mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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.", "3"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
[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.", "5"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
|
|
||||||
],
|
],
|
||||||
"public/app/features/dashboard/state/DashboardModel.test.ts:5381": [
|
"public/app/features/dashboard/state/DashboardModel.test.ts:5381": [
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import { DashboardPanelsChangedEvent } from 'app/types/events';
|
|||||||
import { getDashboardModel } from '../../../../test/helpers/getDashboardModel';
|
import { getDashboardModel } from '../../../../test/helpers/getDashboardModel';
|
||||||
import { DashboardModel } from '../state/DashboardModel';
|
import { DashboardModel } from '../state/DashboardModel';
|
||||||
|
|
||||||
import { PanelModel } from './PanelModel';
|
|
||||||
|
|
||||||
jest.mock('app/core/services/context_srv', () => ({}));
|
jest.mock('app/core/services/context_srv', () => ({}));
|
||||||
|
|
||||||
describe('given dashboard with panel repeat', () => {
|
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 });
|
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ export class DashboardModel implements TimeModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processRepeats() {
|
processRepeats() {
|
||||||
if (this.isSnapshotTruthy() || !this.hasVariables()) {
|
if (this.isSnapshotTruthy() || !this.hasVariables() || this.panelInView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user