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 <jacob@fleetdm.com>
This commit is contained in:
Jacob Shandling 2023-05-18 12:33:26 -07:00 committed by GitHub
parent 791183bb66
commit 0c13d8f2a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View file

@ -0,0 +1 @@
- Fix a bug where policy automations couldn't be updated without a webhook URL

View file

@ -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)) {