From 3794fb5d67c56866cb6e42c511be50dd8a1740b6 Mon Sep 17 00:00:00 2001 From: Scott Gress Date: Fri, 28 Feb 2025 15:22:11 -0600 Subject: [PATCH] allow disabling other workflows (#26717) For #26711 # Details Fix for unreleased bug where you are enable to disable "Other workflows", because after changing the slider from "enabled" to "disabled" the save button would also be disabled. The fix (easier to see [with whitespace disabled in the diff](https://github.com/fleetdm/fleet/pull/26717/files?w=1)) is to pull the PoliciesPaginatedList out of the `
` that gets the `__disabled` class applied to it when the slider is turned off, and instead disable it separately using its `disabled` property. ## Screenshota Before (note disabled "save" button): image After: image --- .../CalendarEventsModal.tsx | 4 +- .../OtherWorkflowsModal.tsx | 84 ++++++++++--------- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/frontend/pages/policies/ManagePoliciesPage/components/CalendarEventsModal/CalendarEventsModal.tsx b/frontend/pages/policies/ManagePoliciesPage/components/CalendarEventsModal/CalendarEventsModal.tsx index 66c7e6bd99..4fb2144d64 100644 --- a/frontend/pages/policies/ManagePoliciesPage/components/CalendarEventsModal/CalendarEventsModal.tsx +++ b/frontend/pages/policies/ManagePoliciesPage/components/CalendarEventsModal/CalendarEventsModal.tsx @@ -275,11 +275,11 @@ const CalendarEventsModal = ({ { + onToggleItem={(item: IFormPolicy) => { item.calendar_events_enabled = !item.calendar_events_enabled; return item; }} - renderItemRow={(item) => { + renderItemRow={(item: IFormPolicy) => { return (
{isWebhookEnabled ? renderWebhook() : renderIntegrations()} -
- {availablePolicies?.length ? ( - { - return newPolicyIds?.indexOf(item.id) > -1; - }} - onToggleItem={(item) => { - const updatedPolicyIds = newPolicyIds.slice(); - const index = newPolicyIds?.indexOf(item.id); - if (index > -1) { - updatedPolicyIds.splice(index, 1); - } else { - updatedPolicyIds.push(item.id); - } - setNewPolicyIds(updatedPolicyIds); - return item; - }} - footer={ -

- The workflow will be triggered when hosts fail these - policies.{" "} - -

+
+
+ {availablePolicies?.length ? ( + { + return newPolicyIds?.indexOf(item.id) > -1; + }} + onToggleItem={(item: IFormPolicy) => { + const updatedPolicyIds = newPolicyIds.slice(); + const index = newPolicyIds?.indexOf(item.id); + if (index > -1) { + updatedPolicyIds.splice(index, 1); + } else { + updatedPolicyIds.push(item.id); } - isUpdating={isUpdating} - onSubmit={onUpdateOtherWorkflows} - onCancel={onExit} - teamId={teamId} - /> - ) : ( - <> - You have no policies. -

Add a policy to turn on automations.

- - )} -
+ setNewPolicyIds(updatedPolicyIds); + return item; + }} + footer={ +

+ The workflow will be triggered when hosts fail these policies.{" "} + +

+ } + isUpdating={isUpdating} + onSubmit={onUpdateOtherWorkflows} + onCancel={onExit} + teamId={teamId} + disabled={!isPolicyAutomationsEnabled} + /> + ) : ( + <> + You have no policies. +

Add a policy to turn on automations.

+ + )}