From 04806416c09de21bc45bec93a4cdb722d73aea81 Mon Sep 17 00:00:00 2001 From: cauemarcondes Date: Wed, 6 May 2020 18:07:21 +0200 Subject: [PATCH 1/3] reset settings when navigate to choose-settings-step page --- .../AgentConfigurationCreateEdit/index.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx index 3a6f94b975800..dce690d52e113 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx @@ -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) { @@ -100,7 +111,7 @@ export function AgentConfigurationCreateEdit({ ) { setPage('choose-service-step'); } - }, [isEditMode, newConfig, pageStep]); + }, [existingConfig, isEditMode, newConfig, pageStep]); const unsavedChanges = getUnsavedChanges({ newConfig, existingConfig }); From f4b1b5b7f0ba31bd77c1882ccaea4d14dd9004d1 Mon Sep 17 00:00:00 2001 From: cauemarcondes Date: Wed, 6 May 2020 18:16:43 +0200 Subject: [PATCH 2/3] reset settings when navigate to choose-settings-step page --- .../AgentConfigurations/AgentConfigurationCreateEdit/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx index dce690d52e113..dc1acea680c23 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx @@ -111,7 +111,7 @@ export function AgentConfigurationCreateEdit({ ) { setPage('choose-service-step'); } - }, [existingConfig, isEditMode, newConfig, pageStep]); + }, [isEditMode, newConfig, pageStep]); const unsavedChanges = getUnsavedChanges({ newConfig, existingConfig }); From 84d20b0f3ce3d5ef0da4d1961d4fa8d0ff6c0ad8 Mon Sep 17 00:00:00 2001 From: cauemarcondes Date: Wed, 6 May 2020 22:20:21 +0200 Subject: [PATCH 3/3] reset settings when navigate to choose-settings-step page --- .../AgentConfigurationCreateEdit/index.tsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx index dc1acea680c23..79a6370b4be46 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx @@ -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) { @@ -143,7 +132,10 @@ export function AgentConfigurationCreateEdit({ setPage('choose-settings-step')} + onClickNext={() => { + resetSettings(); + setPage('choose-settings-step'); + }} /> )}