mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ChangeTracker: Unified unsaved changes handling with library panels (#34989)
* UnsavedChanges: Move Change tracker to use Prompt * Fix a lot of race conditions and stacking of changes in onConfirm and onDismiss * Listen to save event * add missing delay argument * migrated the change tracker unit tests * Updated snapshot * Removed unessary action * removed updateSourcePanel * Fix hiding save library panel modal prompt when clicking discard * change saved libray panel title and buttons so they are a bit different as Prompt and when used from save button * Fixed issue with saving new dashboard * Now all scenarios work * increase wait time * Fixed one more race condition
This commit is contained in:
@@ -32,13 +32,7 @@ export const UnsavedChangesModal: React.FC<UnsavedChangesModalProps> = ({
|
||||
<Button variant="secondary" onClick={onDismiss} fill="outline">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
onClick={() => {
|
||||
onDiscard();
|
||||
onDismiss();
|
||||
}}
|
||||
>
|
||||
<Button variant="destructive" onClick={onDiscard}>
|
||||
Discard
|
||||
</Button>
|
||||
<SaveDashboardButton dashboard={dashboard} onSaveSuccess={onSaveSuccess} />
|
||||
|
||||
@@ -31,12 +31,11 @@ export const useDashboardSave = (dashboard: DashboardModel) => {
|
||||
appEvents.publish(new DashboardSavedEvent());
|
||||
appEvents.emit(AppEvents.alertSuccess, ['Dashboard saved']);
|
||||
|
||||
// Using global locationService because save modals are rendered as a separate React tree
|
||||
const currentPath = locationService.getLocation().pathname;
|
||||
const newUrl = locationUtil.stripBaseFromUrl(state.value.url);
|
||||
|
||||
if (newUrl !== currentPath) {
|
||||
locationService.replace(newUrl);
|
||||
setTimeout(() => locationService.replace(newUrl));
|
||||
}
|
||||
}
|
||||
}, [dashboard, state]);
|
||||
|
||||
Reference in New Issue
Block a user