mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
Fleet UI: Fix policy automations from resetting automations on other pages (#16505)
This commit is contained in:
parent
4416a68496
commit
3bdae3629d
2 changed files with 25 additions and 1 deletions
1
changes/16504-policy-automation-bug
Normal file
1
changes/16504-policy-automation-bug
Normal file
|
|
@ -0,0 +1 @@
|
|||
- Fix a bug where policy automations when saved were resetting automations on other pages
|
||||
|
|
@ -225,11 +225,34 @@ const ManagePolicyAutomationsModal = ({
|
|||
// newPolicyIds = [];
|
||||
// }
|
||||
|
||||
const updatedEnabledPoliciesAcrossPages = () => {
|
||||
if (webhook.policy_ids) {
|
||||
// Array of policy ids on the page
|
||||
const availablePoliciesIds = availablePolicies.map(
|
||||
(policy) => policy.id
|
||||
);
|
||||
|
||||
// Array of policy ids enabled NOT on the page
|
||||
const enabledPoliciesOnOtherPages = webhook.policy_ids.filter(
|
||||
(policyId) => !availablePoliciesIds.includes(policyId)
|
||||
);
|
||||
|
||||
// Concatenate with array of policies enabled on the page
|
||||
const allEnabledPolicies = enabledPoliciesOnOtherPages.concat(
|
||||
newPolicyIds
|
||||
);
|
||||
|
||||
return allEnabledPolicies;
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
// NOTE: backend uses webhook_settings to store automated policy ids for both webhooks and integrations
|
||||
const newWebhook = {
|
||||
failing_policies_webhook: {
|
||||
destination_url: destinationUrl,
|
||||
policy_ids: newPolicyIds,
|
||||
policy_ids: updatedEnabledPoliciesAcrossPages(),
|
||||
enable_failing_policies_webhook:
|
||||
isPolicyAutomationsEnabled && isWebhookEnabled,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue