Fix: panel crash after esc (#38646)

This commit is contained in:
Zoltán Bedi 2021-08-30 09:57:07 +02:00 committed by GitHub
parent d90c822e69
commit 38b398feb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 15 deletions

View File

@ -1,5 +1,5 @@
import { thunkTester } from '../../../../../../test/core/thunk/thunkTester';
import { closeCompleted, initialState, PanelEditorState } from './reducers';
import { closeEditor, initialState, PanelEditorState } from './reducers';
import { initPanelEditor, exitPanelEditor } from './actions';
import { cleanUpEditPanel, panelModelAndPluginReady } from '../../../state/reducers';
import { DashboardModel, PanelModel } from '../../../state';
@ -52,8 +52,8 @@ describe('panelEditor actions', () => {
.whenThunkIsDispatched();
expect(dispatchedActions.length).toBe(2);
expect(dispatchedActions[0].type).toBe(cleanUpEditPanel.type);
expect(dispatchedActions[1].type).toBe(closeCompleted.type);
expect(dispatchedActions[0].type).toBe(closeEditor.type);
expect(dispatchedActions[1].type).toBe(cleanUpEditPanel.type);
expect(sourcePanel.getOptions()).toEqual({ prop: true });
expect(sourcePanel.id).toEqual(12);
});

View File

@ -1,7 +1,7 @@
import { DashboardModel, PanelModel } from '../../../state';
import { ThunkResult } from 'app/types';
import {
closeCompleted,
closeEditor,
PANEL_EDITOR_UI_STATE_STORAGE_KEY,
PanelEditorUIState,
setPanelEditorUIState,
@ -105,8 +105,8 @@ export function exitPanelEditor(): ThunkResult<void> {
dashboard.exitPanelEditor();
}
dispatch(closeEditor());
dispatch(cleanUpEditPanel());
dispatch(closeCompleted());
};
}

View File

@ -106,7 +106,7 @@ const pluginsSlice = createSlice({
toggleTableView(state) {
state.tableViewEnabled = !state.tableViewEnabled;
},
closeCompleted: (state) => {
closeEditor: (state) => {
state.isOpen = false;
state.initDone = false;
state.isVizPickerOpen = false;
@ -119,7 +119,7 @@ export const {
updateEditorInitState,
setEditorPanelData,
setDiscardChanges,
closeCompleted,
closeEditor,
setPanelEditorUIState,
toggleVizPicker,
toggleTableView,

View File

@ -68,14 +68,9 @@ const mapDispatchToProps = {
const connector = connect(mapStateToProps, mapDispatchToProps);
interface OwnProps {
isPanelEditorOpen?: boolean;
}
export type Props = Themeable2 &
GrafanaRouteComponentProps<DashboardPageRouteParams, DashboardPageRouteSearchParams> &
ConnectedProps<typeof connector> &
OwnProps;
ConnectedProps<typeof connector>;
export interface State {
editPanel: PanelModel | null;

View File

@ -76,14 +76,12 @@ const dashbardSlice = createSlice({
updatePanelState(state, action.payload.panelId, { plugin: action.payload.plugin });
},
cleanUpEditPanel: (state) => {
// TODO: refactor, since the state should be mutated by copying only
delete state.panels[EDIT_PANEL_ID];
},
setPanelAngularComponent: (state, action: PayloadAction<SetPanelAngularComponentPayload>) => {
updatePanelState(state, action.payload.panelId, { angularComponent: action.payload.angularComponent });
},
addPanel: (state, action: PayloadAction<PanelModel>) => {
// TODO: refactor, since the state should be mutated by copying only
state.panels[action.payload.id] = { pluginId: action.payload.type };
},
},