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 f4b1b5b commit 84d20b0
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ 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 Down Expand Up @@ -143,7 +132,10 @@ export function AgentConfigurationCreateEdit({
<ServicePage
newConfig={newConfig}
setNewConfig={setNewConfig}
onClickNext={() => setPage('choose-settings-step')}
onClickNext={() => {
resetSettings();
setPage('choose-settings-step');
}}
/>
)}

Expand Down

0 comments on commit 84d20b0

Please sign in to comment.