Commit 3ff32f8
authored
feat(console): persist audit-log filters in the query string (#1395)
Follow-up to #1394.
## What
Every audit-log filter is now mirrored into the URL query string, so a
filtered
`/admin/audit-log` view is **shareable and survives reload**:
- event type (`type`), severity (`severity`), origin (`origin`) —
comma-separated
- date range (`from` / `to`, ISO)
- admin workspace filter (`ws` = id, `wsName` = label)
## How
Shared `AuditLog` component (used by both `/admin/audit-log` and the
workspace-scoped view), `components/AuditLog/AuditLog.tsx`:
- **Hydrate once** `router.query` is ready → seed filter state from the
URL.
- **Mirror back** on every filter change via a shallow `router.replace`
(no
history spam).
- The `hydrated` gate is **state, not a ref**, so the write-back effect
can't
run with the still-empty initial state and wipe the incoming params
before
hydration commits.
- Non-filter params (e.g. the `[workspaceId]` route segment) are
preserved —
only the managed keys are rewritten.
- The workspace **label** is carried in the URL next to its id so the
chip
renders a name without an extra lookup (the workspace search is keyed by
name, not id).
- Pagination (`cursor`) is intentionally **not** persisted.
## Testing
- `tsc --noEmit` clean (pre-existing errors are unrelated missing
dev-deps:
`msw`, `testcontainers`, `@storybook/*`).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01SeUP6H1fsHsJjo2FLKKqUS1 file changed
Lines changed: 62 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
254 | 315 | | |
255 | 316 | | |
256 | 317 | | |
| |||
0 commit comments