Skip to content

feat(console): persist audit-log filters in the query string#1395

Merged
vklimontovich merged 2 commits into
newjitsufrom
feat/console-audit-log-url-filters
Jul 10, 2026
Merged

feat(console): persist audit-log filters in the query string#1395
vklimontovich merged 2 commits into
newjitsufrom
feat/console-audit-log-url-filters

Conversation

@vklimontovich

Copy link
Copy Markdown
Contributor

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.ai/code/session_01SeUP6H1fsHsJjo2FLKKqUS

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
jitsu-code-review[bot]
jitsu-code-review Bot previously approved these changes Jul 9, 2026

@jitsu-code-review jitsu-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread webapps/console/components/AuditLog/AuditLog.tsx Outdated
@vklimontovich vklimontovich added the deploy:console Auto-deploy console to beta when this PR merges (JITSU-68) label Jul 9, 2026
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

@jitsu-code-review jitsu-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jitsu-code-review jitsu-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vklimontovich vklimontovich merged commit 3ff32f8 into newjitsu Jul 10, 2026
5 checks passed
@vklimontovich vklimontovich deleted the feat/console-audit-log-url-filters branch July 10, 2026 06:54
@github-actions

Copy link
Copy Markdown
Contributor

🚀 deploy:console label detected — triggered a beta console deployment to jitsu-cloud-infra. Track it in the deploy runs (newest at top): https://github.com/jitsucom/jitsu-cloud-infra/actions/workflows/deploy.yaml?query=event%3Aworkflow_dispatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy:console Auto-deploy console to beta when this PR merges (JITSU-68)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant