mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Call destroy when panel is removed (#77017)
This commit is contained in:
parent
059ba25973
commit
f53839e4fd
@ -189,6 +189,16 @@ describe('DashboardModel', () => {
|
|||||||
expect(dashboard.panels[1].repeat).toBe(undefined);
|
expect(dashboard.panels[1].repeat).toBe(undefined);
|
||||||
expect(dashboard.panels[1].scopedVars).toBe(undefined);
|
expect(dashboard.panels[1].scopedVars).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('remove panel should call destroy', () => {
|
||||||
|
dashboard.addPanel({ type: 'test', title: 'test' });
|
||||||
|
const panel = dashboard.panels[0];
|
||||||
|
panel.destroy = jest.fn();
|
||||||
|
|
||||||
|
dashboard.removePanel(panel);
|
||||||
|
|
||||||
|
expect(panel.destroy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Given editable false dashboard', () => {
|
describe('Given editable false dashboard', () => {
|
||||||
|
@ -864,6 +864,7 @@ export class DashboardModel implements TimeModel {
|
|||||||
|
|
||||||
removePanel(panel: PanelModel) {
|
removePanel(panel: PanelModel) {
|
||||||
this.panels = this.panels.filter((item) => item !== panel);
|
this.panels = this.panels.filter((item) => item !== panel);
|
||||||
|
panel.destroy();
|
||||||
this.events.publish(new DashboardPanelsChangedEvent());
|
this.events.publish(new DashboardPanelsChangedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user