Repository navigation
refactor(ui): colocate the policies view, keeping PolicySelector shared - #32720
Conversation
Group-1 colocation split. The policies folder lived in the shared src/components dump but is only partly shared: PolicySelector (used by the Playground, ComplianceUI, and key edit view) and its types stay in @/components/policies, while the policy-management view (27 files: index, tables, forms, modals, pipeline builder, and their tests) moves to policies/_components. Moved files' imports of the retained shared files become @/components/policies paths; other escaping relative imports are absolutized against the @/ alias (including @/data/... and the repo test-utils via @/../tests/...), and moved test files have both their `from` imports and `vi.mock` paths rewritten so the mocks keep matching the source. Grandfathered lint suppressions for moved files are re-keyed. PolicySelector did not move, so its external consumers are untouched. No behavior change.
Greptile SummaryThis PR colocates the policy-management view components alongside the
Confidence Score: 5/5Pure file move and import path rewrite with no logic changes; all consumers, mocks, and ESLint suppressions are correctly updated. Every moved file has its imports rewritten to verified @/ aliases, every test vi.mock path matches the new source import path, the ESLint suppression keys are all re-keyed consistently, and the unmoved shared files (PolicySelector.tsx, types.ts) remain at their original locations with untouched external consumers. No behavioral changes were introduced. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/eslint-suppressions.json | All moved file keys properly re-keyed to new _components/ paths; PolicySelector.tsx suppression correctly retained at original src/components/policies/PolicySelector.tsx location. |
| ui/litellm-dashboard/src/app/(dashboard)/policies/page.tsx | Import of PoliciesPanel updated from @/components/policies to ./_components; behavior unchanged. |
| ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx | Imports rewritten from relative to @/components/... aliases; no logic changes. |
| ui/litellm-dashboard/src/app/(dashboard)/policies/_components/pipeline_flow_builder.tsx | Relative imports for types, networking, notifications, and @/data/compliancePrompts rewritten to absolute @/ aliases; no logic changes. |
| ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.test.tsx | vi.mock("../networking") updated to vi.mock("@/components/networking") matching the source file's new import path; renderWithProviders import updated to @/../tests/test-utils; mocks still intercept the correct module. |
| ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx | All imports and vi.mock paths updated to @/ aliases; mocks remain aligned with the source file's imports. |
| ui/litellm-dashboard/src/app/(dashboard)/policies/_components/impact_popover.test.tsx | Mock path updated from ../networking to @/components/networking to match source import; test logic unchanged. |
| ui/litellm-dashboard/src/app/(dashboard)/policies/_components/policy_info.test.tsx | Import and mock paths updated; vi.mock("./pipeline_flow_builder", ...) kept as a correct relative path since both files moved to the same folder. |
Reviews (2): Last reviewed commit: "fix(ui): keep PolicySelector.tsx eslint ..." | Re-trigger Greptile
PolicySelector.tsx stays in src/components/policies (only the management view moved to _components), but the suppression re-key wrongly moved its no-nested-ternary entry to the phantom _components path, orphaning the real file's suppression. Revert that one key. (Greptile P1 on #32720.)
|
Good catch. Fixed in e9e7414: reverted the |
|
Fix confirmed in e9e7414 — the 1-line change to |
|
@greptileai re review |
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Relocation with no behavior change; the proof is that the page renders and the shared PolicySelector still works for its other consumers. On a live proxy:
http://localhost:4000/ui/policiesrenders the policies view (create/edit policy, attachments, pipeline builder, policy test panel still work)Local checks:
npx vitest runon the moved folder plus PolicySelector and its ComplianceUI consumer passes with 123 tests across 12 files,npm run buildcompiles every route, andmake pre-commitpasses.Type
🧹 Refactoring
Changes
A "group 1" colocation split from the App Router follow-up. The policies folder lived in the shared
src/componentsdump but is only partly shared:PolicySelector(imported by the Playground, ComplianceUI, and the key edit view) and itstypesare genuinely reusable, while the policy-management view is owned by the policies route. Moving the whole folder would either break those consumers or bury a shared widget inside one route's private folder, so it is splitPolicySelectorandtypesstay in@/components/policies; the management view (27 files: the index panel, policy/attachment tables, forms, modals, the pipeline flow builder, the test panel, and their tests) moves intopolicies/_components. The moved files' imports of the retained shared files become@/components/policiespaths, other escaping relative imports are absolutized against the@/alias (including@/data/...and the repotest-utilsvia@/../tests/...), and moved test files have both theirfromimports and theirvi.mockpaths rewritten so the mocks keep matching the source. Grandfathered lint suppressions for the moved files are re-keyed with counts unchanged.PolicySelectordid not move, so its external consumers are untouched. No behavior changeThis is the same split pattern as the tag-management and vector-stores PR.
guardrailsis intentionally not included: likeagents, it is a file-plus-folder combo (guardrails.tsxsits beside theguardrails/folder), which needs different handling and will be a separate PR