From 50c4430661a89f0c06f48839446064c0ea6bcf4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 11 Dec 2022 09:57:49 +0100 Subject: [PATCH] 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 --- .../grafana-ui/src/components/BarGauge/BarGauge.tsx | 2 +- .../components/PanelEditor/state/actions.test.ts | 10 ++++------ .../dashboard/components/PanelEditor/state/actions.ts | 4 +--- .../dashboard/components/PanelEditor/state/reducers.ts | 2 ++ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/grafana-ui/src/components/BarGauge/BarGauge.tsx b/packages/grafana-ui/src/components/BarGauge/BarGauge.tsx index ac80738dd0e..d3065703a30 100644 --- a/packages/grafana-ui/src/components/BarGauge/BarGauge.tsx +++ b/packages/grafana-ui/src/components/BarGauge/BarGauge.tsx @@ -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', diff --git a/public/app/features/dashboard/components/PanelEditor/state/actions.test.ts b/public/app/features/dashboard/components/PanelEditor/state/actions.test.ts index 13e5d7f78fe..946dfc7f77d 100644 --- a/public/app/features/dashboard/components/PanelEditor/state/actions.test.ts +++ b/public/app/features/dashboard/components/PanelEditor/state/actions.test.ts @@ -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); }); }); diff --git a/public/app/features/dashboard/components/PanelEditor/state/actions.ts b/public/app/features/dashboard/components/PanelEditor/state/actions.ts index b10c845b3f5..2a2bbff694c 100644 --- a/public/app/features/dashboard/components/PanelEditor/state/actions.ts +++ b/public/app/features/dashboard/components/PanelEditor/state/actions.ts @@ -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, diff --git a/public/app/features/dashboard/components/PanelEditor/state/reducers.ts b/public/app/features/dashboard/components/PanelEditor/state/reducers.ts index 9a366235f2f..9d7c6e088ee 100644 --- a/public/app/features/dashboard/components/PanelEditor/state/reducers.ts +++ b/public/app/features/dashboard/components/PanelEditor/state/reducers.ts @@ -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;