NewPanelEdit: Fixes issue with angular panel clean up, and cleanup after leaving edit mode (#24224)
This commit is contained in:
@@ -33,7 +33,7 @@ describe('panelEditor actions', () => {
|
||||
panels: [{ id: 12, type: 'graph' }],
|
||||
});
|
||||
|
||||
const panel = sourcePanel.getEditClone();
|
||||
const panel = dashboard.initEditPanel(sourcePanel);
|
||||
panel.updateOptions({ prop: true });
|
||||
|
||||
const state: PanelEditorState = {
|
||||
@@ -65,7 +65,7 @@ describe('panelEditor actions', () => {
|
||||
panels: [{ id: 12, type: 'graph' }],
|
||||
});
|
||||
|
||||
const panel = sourcePanel.getEditClone();
|
||||
const panel = dashboard.initEditPanel(sourcePanel);
|
||||
panel.type = 'table';
|
||||
panel.plugin = getPanelPlugin({ id: 'table' });
|
||||
panel.updateOptions({ prop: true });
|
||||
@@ -77,6 +77,8 @@ describe('panelEditor actions', () => {
|
||||
querySubscription: { unsubscribe: jest.fn() },
|
||||
};
|
||||
|
||||
const panelDestroy = (panel.destroy = jest.fn());
|
||||
|
||||
const dispatchedActions = await thunkTester({
|
||||
panelEditor: state,
|
||||
dashboard: {
|
||||
@@ -89,6 +91,7 @@ describe('panelEditor actions', () => {
|
||||
expect(dispatchedActions.length).toBe(3);
|
||||
expect(dispatchedActions[0].type).toBe(panelModelAndPluginReady.type);
|
||||
expect(sourcePanel.plugin).toEqual(panel.plugin);
|
||||
expect(panelDestroy.mock.calls.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should discard changes when shouldDiscardChanges is true', async () => {
|
||||
@@ -101,7 +104,7 @@ describe('panelEditor actions', () => {
|
||||
panels: [{ id: 12, type: 'graph' }],
|
||||
});
|
||||
|
||||
const panel = sourcePanel.getEditClone();
|
||||
const panel = dashboard.initEditPanel(sourcePanel);
|
||||
panel.updateOptions({ prop: true });
|
||||
|
||||
const state: PanelEditorState = {
|
||||
|
||||
@@ -341,6 +341,7 @@ export class DashboardModel {
|
||||
}
|
||||
|
||||
exitPanelEditor() {
|
||||
this.panelInEdit.destroy();
|
||||
this.panelInEdit = undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,9 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
|
||||
scope.$on('$destroy', () => {
|
||||
elem.off();
|
||||
|
||||
panel.events.emit(PanelEvents.panelTeardown);
|
||||
panel.events.removeAllListeners();
|
||||
|
||||
if (panelScrollbar) {
|
||||
panelScrollbar.dispose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user