[v11.0.x] Dashboards: Detect unsaved folder change (#88333)

Dashboards: Detect unsaved folder change (#88293)

(cherry picked from commit c0881cc970)

Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-05-27 13:06:05 +01:00
committed by GitHub
co-authored by kay delaney
parent 9cdfa6bf8a
commit 6c4cbf413a
@@ -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);