Skip to content

Commit

Permalink
[D&D] Fix duplicate title warning (opensearch-project#1950)
Browse files Browse the repository at this point in the history
fixes opensearch-project#1918

Signed-off-by: Josh Romero <rmerqg@amazon.com>
  • Loading branch information
joshuarrrr authored and kavilla committed Aug 3, 2022
1 parent 6a27314 commit b91c00b
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const getTopNavConfig = (
if (!savedWizardVis) {
return;
}
const currentTitle = savedWizardVis.title;
savedWizardVis.visualizationState = JSON.stringify(visualizationState);
savedWizardVis.styleState = JSON.stringify(styleState);
savedWizardVis.title = newTitle;
Expand Down Expand Up @@ -126,11 +127,13 @@ export const getTopNavConfig = (
pathname: `${EDIT_PATH}/${id}`,
});
}

return { id };
} else {
// reset title if save not successful
savedWizardVis.title = currentTitle;
}

throw new Error('Saved but no id returned');
// Even if id='', which it will be for a duplicate title warning, we still want to return it, to avoid closing the modal
return { id };
} catch (error: any) {
// eslint-disable-next-line no-console
console.error(error);
Expand All @@ -145,6 +148,9 @@ export const getTopNavConfig = (
text: error.message,
'data-test-subj': 'saveVisualizationError',
});

// reset title if save not successful
savedWizardVis.title = currentTitle;
return { error };
}
};
Expand Down

0 comments on commit b91c00b

Please sign in to comment.