Skip to content

Commit

Permalink
reset settings when navigate to choose-settings-step page
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed May 6, 2020
1 parent 3e9a12c commit 0480641
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ export function AgentConfigurationCreateEdit({
setNewConfig(getInitialNewConfig(existingConfig));
}, [existingConfig]);

useEffect(
() => {
// cleanup settings when navigating to "choose-settings-step" to not save invalid configurations
if (pageStep === 'choose-settings-step' && !isEditMode) {
setNewConfig({ ...newConfig, settings: {} });
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[pageStep]
);

useEffect(() => {
// the user tried to edit the service of an existing config
if (pageStep === 'choose-service-step' && isEditMode) {
Expand All @@ -100,7 +111,7 @@ export function AgentConfigurationCreateEdit({
) {
setPage('choose-service-step');
}
}, [isEditMode, newConfig, pageStep]);
}, [existingConfig, isEditMode, newConfig, pageStep]);

const unsavedChanges = getUnsavedChanges({ newConfig, existingConfig });

Expand Down

0 comments on commit 0480641

Please sign in to comment.