Save policy modal: editable automations on create - #46445
Conversation
| /** True when the new policy targets "All fleets" (global); only the | ||
| * webhook/ticket row is shown in the automations table. */ | ||
| isGlobalPolicy: boolean; | ||
| /** undefined for global, 0 for "Unassigned", positive for a fleet. */ | ||
| policyTeamId: number | undefined; | ||
| /** Config that owns the new policy's automations: global config for global | ||
| * policies, the team's config for team policies. */ | ||
| automationsConfig: IConfig | ITeamConfig | undefined; | ||
| /** Global config — needed for the conditional access row on the | ||
| * "Unassigned" view. */ | ||
| globalConfig: IConfig | undefined; | ||
| /** Display name of the fleet the new policy belongs to. */ | ||
| fleetName: string; |
There was a problem hiding this comment.
We're passing soooo many props, so I'll look into abstracting these, which are needed for PolicyAutomationsFields only. But prefer to do so as a follow-up.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## policy-automations-continuous-retries #46445 +/- ##
========================================================================
Coverage ? 66.81%
========================================================================
Files ? 2764
Lines ? 220065
Branches ? 11186
========================================================================
Hits ? 147040
Misses ? 59750
Partials ? 13275
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| try { | ||
| await saveAutomations(policy); | ||
| } catch (automationsErr) { | ||
| console.error(automationsErr); |
There was a problem hiding this comment.
please remove console statements
juan-fdz-hawa
left a comment
There was a problem hiding this comment.
LGTM! - just left a small observation about a label that doesn't match what we have on the Figma
eb6657a to
af840e4
Compare
3ae4c4e to
abfd879
Compare
- Extract the automations table + Learn more + Continuous-retry checkbox
into a shared PolicyAutomationsFields component (in
pages/policies/components/PolicyAutomationsFields/), used by both the
ManageAutomationsModal and the Edit policy page.
- Render the editable automations section in PolicyForm between Target and
Critical, gated on automationsConfig being loaded so the initial state
(incl. the webhook/ticket row) initializes correctly on a cold refresh.
- Wire automations into the page's existing Save: per-policy fields +
webhook/ticket config persist via useUpdatePolicyAutomations alongside
the core policy update.
- Remove the Cancel button (the back button already does the same) and
rename "Run" -> "Run policy".
- Unify getTicketOrWebhookState + getWebhookOrTicketPolicyIds into a
single getTicketOrWebhookInfo helper returning { state, policyIds }.
- Make getAutomationsPayload pure (returns error string instead of
flashing), so the shared component no longer depends on
NotificationContext.
- Extract the automations table + Learn more + Continuous-retry checkbox
into a shared PolicyAutomationsFields component (in
pages/policies/components/PolicyAutomationsFields/), used by both the
ManageAutomationsModal and the Edit policy page.
- Render the editable automations section in PolicyForm between Target and
Critical, gated on automationsConfig being loaded so the initial state
(incl. the webhook/ticket row) initializes correctly on a cold refresh.
- Wire automations into the page's existing Save: per-policy fields +
webhook/ticket config persist via useUpdatePolicyAutomations alongside
the core policy update.
- Remove the Cancel button (the back button already does the same) and
rename "Run" -> "Run policy".
- Unify getTicketOrWebhookState + getWebhookOrTicketPolicyIds into a
single getTicketOrWebhookInfo helper returning { state, policyIds }.
- Make getAutomationsPayload pure (returns error string instead of
flashing), so the shared component no longer depends on
NotificationContext.
Adds an "+ Add automations" section to the new-policy save modal that reuses PolicyAutomationsFields. After the policy is created, the per-policy update + webhook/ticket membership PATCH run before navigation, and the React Query cache (and AppContext for global) is hydrated so the next page reads fresh data without a refresh. Details page now reads webhook membership from the global config for global policies.
75827cf to
aafe0c7
Compare
@juan-fdz-hawa yeah that looks kinda inconsistent. I'm not sure what's the right thing to show so I left a question in Slack to Rachael to see what should be shown there. But I'll tackle as a follow-up so I can close this chain of PRs. |
fb75399
into
policy-automations-continuous-retries

Related issue: Resolves #45148 (Save policy modal)
Testing
Screen.Recording.2026-05-29.at.9.44.03.AM.mov