mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
NewPanelEditor: Fixed issue going back to dashboard after pull page reload (#22121)
* Fixed issue going back to dashboard * fixed logic * Fixed unit test * Fixed unit test
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { PanelModel, DashboardModel } from '../../../state';
|
||||
import { PanelData } from '@grafana/data';
|
||||
import { ThunkResult } from 'app/types';
|
||||
import { setEditorPanelData, updateEditorInitState } from './reducers';
|
||||
import { setEditorPanelData, updateEditorInitState, closeCompleted } from './reducers';
|
||||
|
||||
export function initPanelEditor(sourcePanel: PanelModel, dashboard: DashboardModel): ThunkResult<void> {
|
||||
return dispatch => {
|
||||
@@ -33,5 +33,7 @@ export function panelEditorCleanUp(): ThunkResult<void> {
|
||||
|
||||
dashboard.exitPanelEditor();
|
||||
querySubscription.unsubscribe();
|
||||
|
||||
dispatch(closeCompleted());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface PanelEditorStateNew {
|
||||
querySubscription?: Unsubscribable;
|
||||
initDone: boolean;
|
||||
shouldDiscardChanges: boolean;
|
||||
isOpen: boolean;
|
||||
}
|
||||
|
||||
export const initialState: PanelEditorStateNew = {
|
||||
@@ -29,6 +30,7 @@ export const initialState: PanelEditorStateNew = {
|
||||
mode: DisplayMode.Fill,
|
||||
initDone: false,
|
||||
shouldDiscardChanges: false,
|
||||
isOpen: false,
|
||||
};
|
||||
|
||||
interface InitEditorPayload {
|
||||
@@ -46,6 +48,7 @@ const pluginsSlice = createSlice({
|
||||
state.getSourcePanel = () => action.payload.sourcePanel;
|
||||
state.querySubscription = action.payload.querySubscription;
|
||||
state.initDone = true;
|
||||
state.isOpen = true;
|
||||
},
|
||||
setEditorPanelData: (state, action: PayloadAction<PanelData>) => {
|
||||
state.getData = () => action.payload;
|
||||
@@ -59,6 +62,10 @@ const pluginsSlice = createSlice({
|
||||
setDiscardChanges: (state, action: PayloadAction<boolean>) => {
|
||||
state.shouldDiscardChanges = action.payload;
|
||||
},
|
||||
closeCompleted: state => {
|
||||
state.isOpen = false;
|
||||
state.initDone = false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -68,6 +75,7 @@ export const {
|
||||
toggleOptionsView,
|
||||
setDisplayMode,
|
||||
setDiscardChanges,
|
||||
closeCompleted,
|
||||
} = pluginsSlice.actions;
|
||||
|
||||
export const panelEditorReducerNew = pluginsSlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user