Skip to content

Commit

Permalink
fix policy validation
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Jan 28, 2022
1 parent e774ab4 commit 30e6b4d
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,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;
Expand Down Expand Up @@ -227,6 +227,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]
Expand Down

0 comments on commit 30e6b4d

Please sign in to comment.