Dashboards: Detect unsaved folder change (#88293)

This commit is contained in:
kay delaney 2024-05-27 12:43:31 +01:00 committed by GitHub
parent 4248ff4688
commit c0881cc970
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,6 +18,7 @@ export const SaveDashboardDrawer = ({ dashboard, onDismiss, onSaveSuccess, isCop
const previous = dashboard.getOriginalDashboard();
const isProvisioned = dashboard.meta.provisioned;
const isNew = dashboard.version === 0;
const hasUnsavedFolderChange = Boolean(dashboard.meta.hasUnsavedFolderChange);
const [errorIsHandled, setErrorIsHandled] = useState(false);
const data = useMemo<SaveDashboardData>(() => {
@ -40,9 +41,9 @@ export const SaveDashboardDrawer = ({ dashboard, onDismiss, onSaveSuccess, isCop
clone,
diff,
diffCount,
hasChanges: diffCount > 0 && !isNew,
hasChanges: (diffCount > 0 || hasUnsavedFolderChange) && !isNew,
};
}, [dashboard, previous, options, isNew]);
}, [dashboard, previous, options, isNew, hasUnsavedFolderChange]);
const [showDiff, setShowDiff] = useState(false);
const { state, onDashboardSave } = useDashboardSave(isCopy);