feat(console): persist audit-log filters in the query string#1395
Conversation
Mirror every audit-log filter (event type, severity, origin, date range, and the admin workspace filter) into the URL so a filtered /admin/audit-log view is shareable and survives reload. State hydrates once router.query is ready, then a shallow replace keeps the URL in sync on every change. The workspace label is carried alongside its id so the chip renders a name without an extra lookup. Pagination is intentionally not persisted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SeUP6H1fsHsJjo2FLKKqUS
There was a problem hiding this comment.
Reviewed the AuditLog URL persistence changes in webapps/console/components/AuditLog/AuditLog.tsx. The filter-to-query-string approach looks good overall and keeps route params intact. I left one inline comment about a likely date parsing bug that can produce invalid API timestamps when hydrating from malformed query params.
Removes the leftover `useRef` import that failed lint, and validates `from`/`to` URL params with dayjs.isValid() before seeding the range — a malformed value no longer builds an invalid Dayjs that serializes back as "Invalid Date" and poisons the request. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SeUP6H1fsHsJjo2FLKKqUS
There was a problem hiding this comment.
Reviewed changes in for URL↔filter synchronization, hydration ordering, and query serialization/deserialization paths. I didn’t find additional correctness, security, or user-visible regression issues in this diff. Existing invalid-date concern appears addressed by the new guard during query hydration.
There was a problem hiding this comment.
Reviewed changes in webapps/console/components/AuditLog/AuditLog.tsx for URL/filter synchronization, hydration ordering, and query serialization/deserialization paths. I did not find additional correctness, security, or user-visible regression issues in this diff. The earlier invalid-date concern appears addressed by the new isValid() guard during query hydration.
|
🚀 |
Follow-up to #1394.
What
Every audit-log filter is now mirrored into the URL query string, so a filtered
/admin/audit-logview is shareable and survives reload:type), severity (severity), origin (origin) — comma-separatedfrom/to, ISO)ws= id,wsName= label)How
Shared
AuditLogcomponent (used by both/admin/audit-logand theworkspace-scoped view),
components/AuditLog/AuditLog.tsx:router.queryis ready → seed filter state from the URL.router.replace(nohistory spam).
hydratedgate is state, not a ref, so the write-back effect can'trun with the still-empty initial state and wipe the incoming params before
hydration commits.
[workspaceId]route segment) are preserved —only the managed keys are rewritten.
renders a name without an extra lookup (the workspace search is keyed by
name, not id).
cursor) is intentionally not persisted.Testing
tsc --noEmitclean (pre-existing errors are unrelated missing dev-deps:msw,testcontainers,@storybook/*).🤖 Generated with Claude Code
https://claude.ai/code/session_01SeUP6H1fsHsJjo2FLKKqUS