From 618e4014a70f4de4a8243632fbebe5a699249675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Fern=C3=A1ndez?= Date: Wed, 25 Sep 2024 13:30:36 +0200 Subject: [PATCH] Dashboards: `SaveButton` not available after changing the folder (#93216) --- .../dashboard-scene/saving/SaveDashboardAsForm.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard-scene/saving/SaveDashboardAsForm.tsx b/public/app/features/dashboard-scene/saving/SaveDashboardAsForm.tsx index 9232b5e9c68..84012e2f694 100644 --- a/public/app/features/dashboard-scene/saving/SaveDashboardAsForm.tsx +++ b/public/app/features/dashboard-scene/saving/SaveDashboardAsForm.tsx @@ -48,6 +48,7 @@ export function SaveDashboardAsForm({ dashboard, changeInfo }: Props) { const { state, onSaveDashboard } = useSaveDashboard(false); const [contentSent, setContentSent] = useState<{ title?: string; folderUid?: string }>({}); + const [hasFolderChanged, setHasFolderChanged] = useState(false); const onSave = async (overwrite: boolean) => { const data = getValues(); @@ -70,10 +71,10 @@ export function SaveDashboardAsForm({ dashboard, changeInfo }: Props) { ); - const saveButton = (overwrite: boolean) => ( - - ); - + const saveButton = (overwrite: boolean) => { + const showSaveButton = !isValid && hasFolderChanged ? true : isValid; + return ; + }; function renderFooter(error?: Error) { const formValuesMatchContentSent = formValues.title.trim() === contentSent.title && formValues.folder.uid === contentSent.folderUid; @@ -127,6 +128,8 @@ export function SaveDashboardAsForm({ dashboard, changeInfo }: Props) { { setValue('folder', { uid, title }); + const folderUid = dashboard.state.meta.folderUid; + setHasFolderChanged(uid !== folderUid); }} // Old folder picker fields value={formValues.folder?.uid}