PanelEditor: Fixes issue where panel edit would show the panel plugin options of the previous edit panel (#59861)

* PanelEditor: Fixes issues with panel edit state cleanup

* Removed console log

* Fixed test
This commit is contained in:
Torkel Ödegaard 2022-12-11 09:57:49 +01:00 committed by GitHub
parent 5d6bdc60b1
commit 50c4430661
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 10 deletions

View File

@ -471,7 +471,7 @@ export function getBasicAndGradientStyles(props: Props): BasicAndGradientStyles
};
const emptyBar: CSSProperties = {
background: `rgba(${theme.isDark ? '255,255,255' : '0,0,0'}, 0.07)`,
background: theme.colors.background.secondary,
flexGrow: 1,
display: 'flex',
borderRadius: '3px',

View File

@ -24,12 +24,10 @@ describe('panelEditor actions', () => {
.givenThunk(initPanelEditor)
.whenThunkIsDispatched(sourcePanel, dashboard);
expect(dispatchedActions.length).toBe(2);
expect(dispatchedActions[0].type).toBe(panelModelAndPluginReady.type);
expect(dispatchedActions[1].payload.sourcePanel).toBe(sourcePanel);
expect(dispatchedActions[1].payload.panel).not.toBe(sourcePanel);
expect(dispatchedActions[1].payload.panel.id).toBe(sourcePanel.id);
expect(dispatchedActions.length).toBe(1);
expect(dispatchedActions[0].payload.sourcePanel).toBe(sourcePanel);
expect(dispatchedActions[0].payload.panel).not.toBe(sourcePanel);
expect(dispatchedActions[0].payload.panel.id).toBe(sourcePanel.id);
});
});

View File

@ -1,7 +1,7 @@
import { pick } from 'lodash';
import store from 'app/core/store';
import { cleanUpPanelState, initPanelState } from 'app/features/panel/state/actions';
import { cleanUpPanelState } from 'app/features/panel/state/actions';
import { panelModelAndPluginReady } from 'app/features/panel/state/reducers';
import { ThunkResult } from 'app/types';
@ -20,8 +20,6 @@ export function initPanelEditor(sourcePanel: PanelModel, dashboard: DashboardMod
return async (dispatch) => {
const panel = dashboard.initEditPanel(sourcePanel);
await dispatch(initPanelState(panel));
dispatch(
updateEditorInitState({
panel,

View File

@ -109,6 +109,8 @@ const pluginsSlice = createSlice({
state.tableViewEnabled = !state.tableViewEnabled;
},
closeEditor: (state) => {
state.getPanel = () => new PanelModel({});
state.getSourcePanel = () => new PanelModel({});
state.isOpen = false;
state.initDone = false;
state.isVizPickerOpen = false;