Skip to content

Save policy modal: editable automations on create - #46445

Merged
nulmete merged 9 commits into
policy-automations-continuous-retriesfrom
45148-save-policy-modal-automations
May 29, 2026
Merged

Save policy modal: editable automations on create#46445
nulmete merged 9 commits into
policy-automations-continuous-retriesfrom
45148-save-policy-modal-automations

Conversation

@nulmete

@nulmete nulmete commented May 29, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #45148 (Save policy modal)

Testing

  • QA'd all new/changed functionality manually
Screen.Recording.2026-05-29.at.9.44.03.AM.mov

Comment on lines +62 to +74
/** 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;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nulmete
nulmete marked this pull request as ready for review May 29, 2026 12:49
@nulmete
nulmete requested a review from a team as a code owner May 29, 2026 12:49

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 32 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (policy-automations-continuous-retries@daf2267). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...mponents/SaveNewPolicyModal/SaveNewPolicyModal.tsx 54.41% 30 Missing and 1 partial ⚠️
...policies/edit/components/PolicyForm/PolicyForm.tsx 91.66% 1 Missing ⚠️
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           
Flag Coverage Δ
frontend 55.92% <60.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

try {
await saveAutomations(policy);
} catch (automationsErr) {
console.error(automationsErr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove console statements

@juan-fdz-hawa

juan-fdz-hawa commented May 29, 2026

Copy link
Copy Markdown
Contributor

Don't know if this is due an inconsistency with the Figma or if this is missing. But when creating policies, Jira/Zendesk/Webhook automation option says "Send webhook or create ticket" on the Figma.

image

@juan-fdz-hawa juan-fdz-hawa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! - just left a small observation about a label that doesn't match what we have on the Figma

@nulmete
nulmete force-pushed the 45148-edit-policy-automations branch from eb6657a to af840e4 Compare May 29, 2026 15:36
@nulmete
nulmete force-pushed the 45148-save-policy-modal-automations branch from 3ae4c4e to abfd879 Compare May 29, 2026 16:11
Base automatically changed from 45148-edit-policy-automations to policy-automations-continuous-retries May 29, 2026 16:24
nulmete added 9 commits May 29, 2026 13:27
- 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.
@nulmete
nulmete force-pushed the 45148-save-policy-modal-automations branch from 75827cf to aafe0c7 Compare May 29, 2026 16:45
@nulmete

nulmete commented May 29, 2026

Copy link
Copy Markdown
Member Author

LGTM! - just left a small observation about a label that doesn't match what we have on the Figma

@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.

@nulmete
nulmete merged commit fb75399 into policy-automations-continuous-retries May 29, 2026
16 checks passed
@nulmete
nulmete deleted the 45148-save-policy-modal-automations branch May 29, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants