Library Panels: Add "Discard" button to panel save modal (#31647)

* Library Panels: Add "Discard" button to panel save modal
This commit is contained in:
kay delaney
2021-03-09 17:05:38 +00:00
committed by GitHub
parent aee78f7527
commit 06a6fb405c
3 changed files with 25 additions and 2 deletions

View File

@@ -171,6 +171,7 @@ export class PanelEditorUnconnected extends PureComponent<Props> {
// the user exits the panel editor they aren't prompted to save again
this.props.updateSourcePanel(this.props.panel);
},
onDiscard: this.onDiscard,
},
});
};

View File

@@ -8,6 +8,7 @@ import {
PanelEditorUIState,
setPanelEditorUIState,
updateEditorInitState,
setDiscardChanges,
} from './reducers';
import { updateLocation } from 'app/core/actions';
import { cleanUpEditPanel, panelModelAndPluginReady } from '../../../state/reducers';
@@ -52,6 +53,11 @@ export function exitPanelEditor(): ThunkResult<void> {
})
);
const onDiscard = () => {
dispatch(setDiscardChanges(true));
onConfirm();
};
const panel = getPanel();
if (shouldDiscardChanges || !panel.libraryPanel) {
@@ -71,6 +77,7 @@ export function exitPanelEditor(): ThunkResult<void> {
folderId: dashboard!.meta.folderId,
isOpen: true,
onConfirm,
onDiscard,
},
});
};