Templating: Fixes flickering of repeated panels and rows (#43399)

This commit is contained in:
Torkel Ödegaard 2022-01-21 11:26:40 +01:00 committed by GitHub
parent 3cb0fb3ddc
commit f3859f8b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import { DashboardModel } from '../state/DashboardModel';
import { expect } from 'test/lib/common';
import { getDashboardModel } from '../../../../test/helpers/getDashboardModel';
import { PanelModel } from './PanelModel';
import { DashboardPanelsChangedEvent } from 'app/types/events';
jest.mock('app/core/services/context_srv', () => ({}));
@ -533,7 +534,7 @@ describe('given dashboard with row repeat', () => {
});
describe('given dashboard with row and panel repeat', () => {
let dashboard: any, dashboardJSON: any;
let dashboard: DashboardModel, dashboardJSON: any;
beforeEach(() => {
dashboardJSON = {
@ -605,11 +606,16 @@ describe('given dashboard with row and panel repeat', () => {
},
{ id: 12, type: 'graph', repeatPanelId: 2, repeatIteration: 101, gridPos: { x: 0, y: 3, h: 1, w: 6 } },
];
let panelChangedEvents: DashboardPanelsChangedEvent[] = [];
dashboard = getDashboardModel(dashboardJSON);
dashboard.events.subscribe(DashboardPanelsChangedEvent, (evt) => panelChangedEvents.push(evt));
dashboard.processRepeats();
const panelTypes = map(dashboard.panels, 'type');
expect(panelTypes).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph']);
// Make sure only a single DashboardPanelsChangedEvent event is emitted when processing repeats
expect(panelChangedEvents.length).toBe(1);
});
it('should set scopedVars for each row', () => {

View File

@ -564,7 +564,6 @@ export class DashboardModel {
pull(this.panels, ...panelsToRemove);
panelsToRemove.map((p) => p.destroy());
this.sortPanelsByGridPos();
this.events.publish(new DashboardPanelsChangedEvent());
}
processRepeats() {