diff --git a/changes/24093-clear-policy-automation b/changes/24093-clear-policy-automation new file mode 100644 index 0000000000..4d77791615 --- /dev/null +++ b/changes/24093-clear-policy-automation @@ -0,0 +1 @@ +- Fleet UI: Fix ability to clear policy automation that empties webhook URL diff --git a/frontend/pages/policies/ManagePoliciesPage/components/OtherWorkflowsModal/OtherWorkflowsModal.tsx b/frontend/pages/policies/ManagePoliciesPage/components/OtherWorkflowsModal/OtherWorkflowsModal.tsx index 859b45fff5..3ddbec66b4 100644 --- a/frontend/pages/policies/ManagePoliciesPage/components/OtherWorkflowsModal/OtherWorkflowsModal.tsx +++ b/frontend/pages/policies/ManagePoliciesPage/components/OtherWorkflowsModal/OtherWorkflowsModal.tsx @@ -185,24 +185,23 @@ const OtherWorkflowsModal = ({ const newErrors = { ...errors }; - if ( - isPolicyAutomationsEnabled && - newPolicyIds.length && - !isWebhookEnabled && - !selectedIntegration - ) { - newErrors.integration = "Please enable at least one integration:"; - } else { - delete newErrors.integration; - } - - if (isWebhookEnabled) { - if (!destinationUrl) { - newErrors.url = "Please add a destination URL"; - } else if (!validUrl({ url: destinationUrl })) { - newErrors.url = `${destinationUrl} is not a valid URL`; + if (isPolicyAutomationsEnabled) { + // Ticket workflow validation + if (newPolicyIds.length && !isWebhookEnabled && !selectedIntegration) { + newErrors.integration = "Please enable at least one integration:"; } else { - delete newErrors.url; + delete newErrors.integration; + } + + // Webhook workflow validation + if (isWebhookEnabled) { + if (!destinationUrl) { + newErrors.url = "Please add a destination URL"; + } else if (!validUrl({ url: destinationUrl })) { + newErrors.url = `${destinationUrl} is not a valid URL`; + } else { + delete newErrors.url; + } } }