mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: panel crash after esc (#38646)
This commit is contained in:
parent
d90c822e69
commit
38b398feb4
@ -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);
|
||||
});
|
||||
|
@ -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());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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 };
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user