NewPanelEdit: Fixes issue with angular panel clean up, and cleanup after leaving edit mode (#24224)

pull/24094/head
Torkel Ödegaard 5 years ago committed by GitHub
parent 5f621a736a
commit 5a20782499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      public/app/features/dashboard/components/PanelEditor/state/actions.test.ts
  2. 1
      public/app/features/dashboard/state/DashboardModel.ts
  3. 3
      public/app/features/panel/panel_directive.ts

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

Loading…
Cancel
Save