Skip to content

Command palette: deep-link Manage policy automations to AutomationsModal - #46884

Merged
RachelElysia merged 2 commits into
mainfrom
command-palette-4.87
Jun 5, 2026
Merged

Command palette: deep-link Manage policy automations to AutomationsModal#46884
RachelElysia merged 2 commits into
mainfrom
command-palette-4.87

Conversation

@RachelElysia

@RachelElysia RachelElysia commented Jun 5, 2026

Copy link
Copy Markdown
Member

Issue

Closes #43757

Description

  • in 4.87.0 The five Policy automation sub-items (Tickets & webhooks, Install software, Run script, Calendar events, Conditional access) are now dead links — ManagePoliciesPage declared a ?manage_automations query param but never parsed it, and the team-level AutomationsModal also dropped its Install software / Run script sections (per-policy now). Replace the parent + five sub-items with a single flat entry whose path is /policies?manage_automations=1, mirroring the reports pattern.

  • ManagePoliciesPage now reads the param, re-checks role + hasPoliciesToAutomate, opens AutomationsModal, and strips the param. Keywords scope to the sections the modal actually renders for the current fleet: All fleets gets webhook-only keywords, Unassigned adds conditional access, a specific team adds calendar too.

Screen recording of fix

Screen.Recording.2026-06-05.at.7.32.15.AM.mov

Related issue: Resolves #

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features

    • Deep-linking to the automations management modal via a query parameter (opens modal when conditions met)
  • Bug Fixes / Behavior Changes

    • Simplified command palette automations entry into a single item and tightened its visibility to specific admin roles and team contexts
    • Palette keyword visibility now adapts to All/Team/Unassigned contexts
  • Tests

    • Updated tests for the automations palette entry and keyword-filtering logic

The five Policy automation sub-items (Tickets & webhooks, Install software,
Run script, Calendar events, Conditional access) were dead links —
ManagePoliciesPage declared a `?manage_automations` query param but never
parsed it, and the team-level AutomationsModal also dropped its Install
software / Run script sections (per-policy now). Replace the parent + five
sub-items with a single flat entry whose path is
`/policies?manage_automations=1`, mirroring the reports pattern.

ManagePoliciesPage now reads the param, re-checks role +
hasPoliciesToAutomate, opens AutomationsModal, and strips the param.
Keywords scope to the sections the modal actually renders for the current
fleet: All fleets gets webhook-only keywords, Unassigned adds conditional
access, a specific team adds calendar too.
Copilot AI review requested due to automatic review settings June 5, 2026 11:38
@RachelElysia
RachelElysia requested a review from a team as a code owner June 5, 2026 11:38

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

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.

// Manage automations — policies (admins and maintainers). Mirrors
// the reports pattern: ManagePoliciesPage reads ?manage_automations=1
// and opens AutomationsModal. The page re-checks role +
// hasPoliciesToAutomate before opening, then strips the param.

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.

❯ do we still care about hasPoliciesToAutomate in the command-palette-4.87

⏺ Yes — keep it. Two reasons:

  1. Symmetry with the in-page button. ManagePoliciesPage.tsx:852 disables when !hasPoliciesToAutomate. Our useEffect's
    canEditAutomationsSettings && hasPoliciesToAutomate gate is the URL-driven equivalent of that disabled state. Dropping it would mean clicking the
    palette opens a modal that clicking the button refuses to open — same user, same scope, different outcome based on entry path.
  2. The modal isn't useful with zero non-inherited policies. The webhook/calendar/conditional-access automations are team-level configs attached to
    policies. With no policies, there's nothing to attach them to — which is why the product gates the button in the first place.

The palette itself can't (cheaply) check this — the context has no policy count — so the page is the right place for the check. If the user clicks
the palette item on an empty team, they land on /policies?manage_automations=1, the param gets stripped, no modal opens, and they see the
empty-policies page with the grayed-out Automations button. That's a coherent dead-end-with-explanation, not a silent failure.

If you wanted to make it punchier, the only real lever would be hiding the palette item itself for premium teams with zero policies — but that
needs a fetched count and probably isn't worth it given how rare "premium tier + admin role + zero policies" is.

Copilot AI 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.

Pull request overview

This PR fixes broken command-palette links for policy automations by deep-linking to the Policies page with a ?manage_automations=1 query param and having ManagePoliciesPage open the AutomationsModal when appropriate, then stripping the param to avoid reopening on refresh.

Changes:

  • Add a deep-link handler to ManagePoliciesPage that opens AutomationsModal (only when authorized and there are policies to automate) and then removes manage_automations from the URL.
  • Flatten “Manage policy automations” in the command palette to a single item (/policies?manage_automations=1) and scope keywords to what the modal actually renders for the selected fleet scope.
  • Update command palette unit tests to reflect the flattened entry and keyword scoping.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx Parses ?manage_automations=1, gates opening the modal on authorization + counts loaded, and strips the param via router.replace.
frontend/components/CommandPalette/helpers.tests.ts Updates tests to validate the flattened policy-automations entry and keyword behavior across fleet scopes.
frontend/components/CommandPalette/groups/automations.ts Replaces policy-automation sub-items with a single deep-link entry and adjusts keywords by scope.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +84 to +88
// Manage automations — policies (admins and maintainers). Mirrors
// the reports pattern: ManagePoliciesPage reads ?manage_automations=1
// and opens AutomationsModal. The page re-checks role +
// hasPoliciesToAutomate before opening, then strips the param.
//

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.

addressing in next commit

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.01%. Comparing base (cfcca6a) to head (2003116).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...policies/ManagePoliciesPage/ManagePoliciesPage.tsx 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46884      +/-   ##
==========================================
- Coverage   67.01%   67.01%   -0.01%     
==========================================
  Files        2857     2857              
  Lines      224601   224605       +4     
  Branches    11732    11733       +1     
==========================================
- Hits       150521   150515       -6     
- Misses      60438    60447       +9     
- Partials    13642    13643       +1     
Flag Coverage Δ
frontend 56.93% <33.33%> (-0.03%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5281694f-4f29-4e9e-a74a-e9ae6c56e183

📥 Commits

Reviewing files that changed from the base of the PR and between eedbfbd and 2003116.

📒 Files selected for processing (2)
  • frontend/components/CommandPalette/CommandPalette.tsx
  • frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx

Walkthrough

The PR consolidates the "Manage automations" workflow by restructuring the Command Palette entry from a multi-subitem parent into a single flat palette item that deep-links to the automations modal via ?manage_automations=1. Permission gating is tightened to require admin roles only. The palette builder drops premium-tier checks and adjusts keyword visibility based on fleet context (hiding calendar keywords on all-fleets and unassigned contexts). Tests validate the new flat structure and conditional keyword visibility. ManagePoliciesPage adds error state bindings to the policies count queries and implements a useEffect handler that detects the deep-link parameter, waits for relevant data to load, conditionally opens the AutomationsModal when permissions allow, and then cleans up the parameter via router.replace.

Possibly related PRs

  • fleetdm/fleet#46254: Implements the ManageAutomationsModal and expands ManagePoliciesPage to pass the modal props needed for automations UI, directly supporting the manage_automations deep-link wiring in this PR.
  • fleetdm/fleet#46023: Refactors ManagePoliciesPage modal initialization and automation config, providing the underlying automations modal infrastructure that this PR's deep-link handler invokes.
  • fleetdm/fleet#43756: Introduced the Command Palette automations group structure and entry builders that this PR refactors and extends with the manage_automations deep-link.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: replacing sub-items with a single deep-link entry to AutomationsModal via command palette.
Description check ✅ Passed The PR description covers the issue, solution, testing, and includes a screen recording, matching the template structure. Relevant checklist items are marked completed.
Linked Issues check ✅ Passed Changes implement the deep-link modal support objective [#43757] by consuming and stripping the manage_automations query param to open AutomationsModal when appropriate with proper permission gating.
Out of Scope Changes check ✅ Passed All changes directly address the stated objective: fixing dead links by consolidating sub-items, adding param handling, and aligning keywords with modal content for different fleet contexts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch command-palette-4.87

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx`:
- Around line 627-645: The current effect only strips the manage_automations
query when countLoaded is true, so if the count request errors the deep-link
param remains; update the effect so it still always removes manage_automations
from location.query but only opens the automations modal when countLoaded and
the other conditions hold. Concretely, keep computing countLoaded
(isAllTeamsSelected ? globalPoliciesCount !== undefined :
teamPoliciesCountResponse !== undefined), then if (countLoaded &&
canEditAutomationsSettings && hasPoliciesToAutomate) call
setShowAutomationsModal(true), and regardless of countLoaded always do "const {
manage_automations, ...rest } = location.query; router.replace({ pathname:
location.pathname, query: rest });" so the router.replace runs even when data
failed; preserve the same effect dependencies (location.query,
location.pathname, router, canEditAutomationsSettings, hasPoliciesToAutomate,
isAllTeamsSelected, globalPoliciesCount, teamPoliciesCountResponse).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: adb8160b-f5b8-41e6-8b01-49f148b5589a

📥 Commits

Reviewing files that changed from the base of the PR and between 8bda076 and eedbfbd.

📒 Files selected for processing (3)
  • frontend/components/CommandPalette/groups/automations.ts
  • frontend/components/CommandPalette/helpers.tests.ts
  • frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx

Comment thread frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx Outdated
@RachelElysia
RachelElysia merged commit 7903970 into main Jun 5, 2026
24 checks passed
@RachelElysia
RachelElysia deleted the command-palette-4.87 branch June 5, 2026 12:10
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.

Fleet spotlight (⌘ + K)

3 participants