From 5c63ed829f5ccee09661fe424d684ad9b0026012 Mon Sep 17 00:00:00 2001 From: Julia Bardi <90178898+juliaElastic@users.noreply.github.com> Date: Mon, 31 Jan 2022 11:24:02 +0100 Subject: [PATCH] fix policy validation (#124040) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 860a2074c848238597b8b9e54ee32c684dd2779d) --- .../agent_policy/create_package_policy_page/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx index 447a5e704f044..b316218af9823 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx @@ -172,17 +172,17 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { if (updatedAgentPolicy) { setAgentPolicy(updatedAgentPolicy); if (packageInfo) { - setFormState('VALID'); + setHasAgentPolicyError(false); } } else { - setFormState('INVALID'); + setHasAgentPolicyError(true); setAgentPolicy(undefined); } // eslint-disable-next-line no-console console.debug('Agent policy updated', updatedAgentPolicy); }, - [packageInfo, setAgentPolicy, setFormState] + [packageInfo, setAgentPolicy] ); const hasErrors = validationResults ? validationHasErrors(validationResults) : false; @@ -225,6 +225,8 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { const hasAgentPolicy = newPackagePolicy.policy_id && newPackagePolicy.policy_id !== ''; if (hasPackage && hasAgentPolicy && !hasValidationErrors) { setFormState('VALID'); + } else { + setFormState('INVALID'); } }, [packagePolicy, updatePackagePolicyValidation]