Conversation
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.
| <Redirect from="queries/:id" to="reports/:id" /> | ||
| <Redirect from="queries/:id/edit" to="reports/:id/edit" /> | ||
| <Redirect from="queries/:id/live" to="reports/:id/live" /> | ||
| <Route path="reports"> |
There was a problem hiding this comment.
/policies URL routes now match /reports URL routes
There was a problem hiding this comment.
Pull request overview
This PR follows up on #41753 by restructuring the policies UI/routes so policy SQL is less prominent, introducing a read-only policy details view and separating edit + live-run flows.
Changes:
- Adds a new policy details page (
/policies/:id) with read-only policy information and action buttons. - Splits policy editing into a dedicated edit route (
/policies/:id/edit) and adds a dedicated live-run route (/policies/:id/live, plus/policies/new/live). - Reorganizes
/policiesfrontend directories to mirror the/queriesstructure and updates internal imports/URL params.
Reviewed changes
Copilot reviewed 15 out of 39 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/router/paths.ts | Adds LIVE_POLICY path helper for /policies/:id/live and /policies/new/live. |
| frontend/router/index.tsx | Updates routing to use new policies details/edit/live pages and nested new/live route. |
| frontend/pages/policies/PolicyPage/index.ts | Removes legacy re-export for the old PolicyPage location. |
| frontend/pages/policies/ManagePoliciesPage/components/PoliciesTable/PoliciesTableConfig.tsx | Updates policy details link query param to fleet_id. |
| frontend/pages/policies/live/screens/RunQuery.tsx | Repoints PolicyResults import to the new edit components location. |
| frontend/pages/policies/live/LivePolicyPage/LivePolicyPage.tsx | Introduces the live policy run flow page (targets + run). |
| frontend/pages/policies/live/LivePolicyPage/index.ts | Barrel export for LivePolicyPage. |
| frontend/pages/policies/live/LivePolicyPage/_styles.scss | Styles for the new live policy page wrapper. |
| frontend/pages/policies/edit/screens/QueryEditor.tsx | Updates PolicyForm import path and switches URL param to fleet_id for back navigation. |
| frontend/pages/policies/edit/index.ts | Barrel export for EditPolicyPage. |
| frontend/pages/policies/edit/EditPolicyPage.tsx | Refactors the policy edit page to route into the new live flow instead of in-page steps. |
| frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tsx | Adds a modal for saving a new policy (name/description/resolution/platform/labels/critical). |
| frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tests.tsx | Adds tests for SaveNewPolicyModal behavior (tier gating + label payload behavior). |
| frontend/pages/policies/edit/components/SaveNewPolicyModal/index.ts | Barrel export for SaveNewPolicyModal. |
| frontend/pages/policies/edit/components/SaveNewPolicyModal/_styles.scss | Adds styles for the modal’s “Critical” checkbox label weight. |
| frontend/pages/policies/edit/components/PolicyResultsTable/PolicyResultsTableConfig.tsx | New table config for live policy results host list. |
| frontend/pages/policies/edit/components/PolicyResultsTable/PolicyResultsTable.tsx | New PolicyResultsTable wrapper around TableContainer. |
| frontend/pages/policies/edit/components/PolicyResultsTable/index.ts | Barrel export for PolicyResultsTable. |
| frontend/pages/policies/edit/components/PolicyResultsTable/_styles.scss | Styles for PolicyResultsTable UI. |
| frontend/pages/policies/edit/components/PolicyResults/PolicyResults.tsx | Adds live policy results UI with Results/Errors tabs and export + show query. |
| frontend/pages/policies/edit/components/PolicyResults/index.ts | Barrel export for PolicyResults. |
| frontend/pages/policies/edit/components/PolicyResults/helpers.tsx | Adds helper for yes/no counts used by results UI. |
| frontend/pages/policies/edit/components/PolicyResults/_styles.scss | Styles for the new results UI. |
| frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx | Updates redirect effect dependency list (permissions/route inputs). |
| frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tests.tsx | Adds/updates tests for PolicyForm behavior (tier gating, targeting, patch policies). |
| frontend/pages/policies/edit/components/PolicyForm/index.ts | Barrel export for PolicyForm. |
| frontend/pages/policies/edit/components/PolicyForm/_styles.scss | Updates warning class selector to match renamed edit policy base class. |
| frontend/pages/policies/edit/components/PolicyErrorsTable/PolicyErrorsTableConfig.tsx | New table config for live policy errors list. |
| frontend/pages/policies/edit/components/PolicyErrorsTable/PolicyErrorsTable.tsx | New PolicyErrorsTable wrapper around TableContainer. |
| frontend/pages/policies/edit/components/PolicyErrorsTable/index.ts | Barrel export for PolicyErrorsTable. |
| frontend/pages/policies/edit/components/PolicyErrorsTable/_styles.scss | Styles for PolicyErrorsTable UI. |
| frontend/pages/policies/edit/components/PolicyAutomations/PolicyAutomations.tsx | Moves/introduces PolicyAutomations component under the new edit component tree. |
| frontend/pages/policies/edit/components/PolicyAutomations/index.ts | Barrel export for PolicyAutomations. |
| frontend/pages/policies/edit/components/PolicyAutomations/_styles.scss | Styles for PolicyAutomations UI. |
| frontend/pages/policies/edit/_styles.scss | Adds new base styles for the refactored edit policy page. |
| frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tsx | Adds team-aware policy loading, updates buttons to edit/live routes, and updates fleet_id usage. |
| frontend/pages/policies/details/PolicyDetailsPage/index.ts | Barrel export for PolicyDetailsPage. |
| frontend/pages/policies/details/PolicyDetailsPage/_styles.scss | Adds styles for the new policy details page layout. |
| changes/41753-policy-details-page | Adds user-visible changelog entries for the new details/edit/live policy pages. |
Comments suppressed due to low confidence (1)
frontend/pages/policies/edit/EditPolicyPage.tsx:52
- The component in
EditPolicyPage.tsxis still namedPolicyPageand exported as such. Renaming the component toEditPolicyPagewould better match the file/route name and reduce confusion when debugging React trees and stack traces.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| onSuccess: (host) => { | ||
| setTargetedHosts((prevHosts) => | ||
| prevHosts.filter((h) => h.id !== host.id).concat(host) | ||
| ); | ||
| const targets = selectedTargets; | ||
| host.target_type = "hosts"; | ||
| targets.push(host); | ||
| setSelectedTargets([...targets]); |
There was a problem hiding this comment.
onSuccess mutates stateful values directly (const targets = selectedTargets; targets.push(host); and host.target_type = ...). Mutating React state arrays/objects can cause hard-to-debug issues with stale renders. Prefer creating a new targets array via the setter’s functional form and avoid mutating the host object returned from the cache (derive a new object with target_type).
There was a problem hiding this comment.
This follows the same pattern on LiveQueryPage and PolicyPage and this is intended
ac66fe7 to
0b21e36
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #43324 +/- ##
==========================================
- Coverage 66.88% 66.86% -0.02%
==========================================
Files 2588 2586 -2
Lines 207496 207485 -11
Branches 9314 9209 -105
==========================================
- Hits 138783 138743 -40
- Misses 56090 56112 +22
- Partials 12623 12630 +7
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:
|
Issue
Closes #41753
Closes #43263
Description
/policies/:id/live, plus/policies/new/live) mirroring reports routes/policiesfrontend directories to mirror the/queriesstructure and updates internal imports/URL params.Screen recording
Watch in 2x
https://fleetdm.zoom.us/clips/share/hjB-2XOJQj2qQEncAImRgQ
More
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing