Fleet UI: Ability to clear webhook address and still disable policy automation (#24163)

This commit is contained in:
RachelElysia 2024-12-02 16:18:42 -05:00 committed by GitHub
parent 6d468cada4
commit 54455e9958
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 17 deletions

View file

@ -0,0 +1 @@
- Fleet UI: Fix ability to clear policy automation that empties webhook URL

View file

@ -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;
}
}
}