From 0c13d8f2a9958ef927eaeae8bf4fa8351a84df7d Mon Sep 17 00:00:00 2001 From: Jacob Shandling <61553566+jacobshandling@users.noreply.github.com> Date: Thu, 18 May 2023 12:33:26 -0700 Subject: [PATCH] UI: Fix bug with policy automations (#11781) ## Addresses #11714 - Allow saving policy automations to Ticket integrations without defining a webhook URL https://www.loom.com/share/208169b6081846809dc170fcfb43f689 # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling --- changes/11714-policy-automations-bug | 1 + .../ManageAutomationsModal.tsx | 20 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) create mode 100644 changes/11714-policy-automations-bug diff --git a/changes/11714-policy-automations-bug b/changes/11714-policy-automations-bug new file mode 100644 index 0000000000..0fe2a96187 --- /dev/null +++ b/changes/11714-policy-automations-bug @@ -0,0 +1 @@ +- Fix a bug where policy automations couldn't be updated without a webhook URL diff --git a/frontend/pages/policies/ManagePoliciesPage/components/ManageAutomationsModal/ManageAutomationsModal.tsx b/frontend/pages/policies/ManagePoliciesPage/components/ManageAutomationsModal/ManageAutomationsModal.tsx index c99c2781a7..b8bbdba759 100644 --- a/frontend/pages/policies/ManagePoliciesPage/components/ManageAutomationsModal/ManageAutomationsModal.tsx +++ b/frontend/pages/policies/ManagePoliciesPage/components/ManageAutomationsModal/ManageAutomationsModal.tsx @@ -173,12 +173,6 @@ const ManageAutomationsModal = ({ policyItems?.forEach((p) => p.isChecked && newPolicyIds.push(p.id)); const newErrors = { ...errors }; - // if (isPolicyAutomationsEnabled && !newPolicyIds.length) { - // newErrors.policyItems = - // "Please choose at least one policy you want to listen to:"; - // } else { - // delete newErrors.policyItems; - // } if ( isPolicyAutomationsEnabled && @@ -191,12 +185,14 @@ const ManageAutomationsModal = ({ delete newErrors.integration; } - if (isWebhookEnabled && !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; + 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; + } } if (!isEmpty(newErrors)) {