feat(policy): admin ui#114
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR adds a policies management feature to the admin UI: types and API client, React Query hooks, a validated PolicyForm, list/create/edit pages with bulk delete, route tree entries, a sidebar link, and English/Chinese translations. ChangesPolicies Management Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@crates/admin-ui/ui/src/lib/api/client.ts`:
- Around line 134-144: The get/update/delete methods in the client API embed raw
policy IDs into endpoint paths (see get, update, delete calling request with
`/policies/${id}`), which breaks for IDs with "/", "?", "#", or spaces; update
those callsites to URL-encode the id (e.g. use encodeURIComponent(id)) when
constructing the path passed to request so the requests target the correct
resource for all valid ID characters.
In `@crates/admin-ui/ui/src/lib/queries/policies.ts`:
- Around line 49-80: The mutation functions in useUpdatePolicy and
useDeletePolicy must guard against a missing admin key like the create mutation
does: inside each mutationFn (in useUpdatePolicy and useDeletePolicy) check that
key from useAdminKey is present before calling policiesApi.update or
policiesApi.delete, and if key is undefined immediately reject/throw a
descriptive error (or return Promise.reject) instead of calling the API with
key!, so malformed auth calls are prevented; update both mutationFn
implementations (and any other mutations using key) to follow this pattern.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 50b3d55d-a088-49f8-a8ed-c4577eff9040
📒 Files selected for processing (11)
crates/admin-ui/ui/src/components/layout/sidebar.tsxcrates/admin-ui/ui/src/components/policies/policy-form.tsxcrates/admin-ui/ui/src/i18n/locales/en.jsoncrates/admin-ui/ui/src/i18n/locales/zh-CN.jsoncrates/admin-ui/ui/src/lib/api/client.tscrates/admin-ui/ui/src/lib/api/types.tscrates/admin-ui/ui/src/lib/queries/policies.tscrates/admin-ui/ui/src/routeTree.gen.tscrates/admin-ui/ui/src/routes/_layout/policies/$id.tsxcrates/admin-ui/ui/src/routes/_layout/policies/create.tsxcrates/admin-ui/ui/src/routes/_layout/policies/index.tsx
Summary by CodeRabbit