Repository navigation
feat: add audit log page - #23
Conversation
Add an admin-only, per-connection audit log page at /audit-log: - New AuditLog page with a connection dropdown filter that drives the connectionId query param, gated on the connection's admin permission - Route wired in App.tsx; connection-validation redirect generalized to cover connection-scoped routes (/ and /audit-log) - Sidebar footer entry point: an audit-log icon plus the app version, with the git commit hash shown on hover Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds an admin-gated
Confidence Score: 3/5Safe to merge as a stub, but the permission gate will incorrectly deny every admin user during initial data load, which should be fixed before the page goes beyond placeholder content. The admin gate in AuditLog.tsx renders the 'need admin permission' message before connections data resolves, so every admin user sees the wrong state on first load. The gated view also hides the connection dropdown, making it impossible to recover to an admin connection without leaving the page. src/pages/AuditLog.tsx — the permission gate and connection-dropdown placement both need attention before this page carries live data. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User navigates to /audit-log] --> B{connectionId in URL?}
B -- No --> C[Redirect: pathname + first connection]
B -- Yes --> D{Valid connectionId?}
D -- No --> E[Show toast + Redirect: pathname + first connection]
D -- Yes --> F[Render AuditLog with selectedConnectionId]
F --> G{connections loaded?}
G -- Not yet --> H[Show 'need admin permission' message - false negative]
G -- Loaded --> I{hasAdmin?}
I -- No --> J[Show 'need admin permission' message - no dropdown]
I -- Yes --> K[Show Audit Log + Connection Dropdown stub]
K --> L{User changes connection}
L --> M[navigate /audit-log?connectionId=new-id]
M --> F
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[User navigates to /audit-log] --> B{connectionId in URL?}
B -- No --> C[Redirect: pathname + first connection]
B -- Yes --> D{Valid connectionId?}
D -- No --> E[Show toast + Redirect: pathname + first connection]
D -- Yes --> F[Render AuditLog with selectedConnectionId]
F --> G{connections loaded?}
G -- Not yet --> H[Show 'need admin permission' message - false negative]
G -- Loaded --> I{hasAdmin?}
I -- No --> J[Show 'need admin permission' message - no dropdown]
I -- Yes --> K[Show Audit Log + Connection Dropdown stub]
K --> L{User changes connection}
L --> M[navigate /audit-log?connectionId=new-id]
M --> F
Reviews (1): Last reviewed commit: "feat: add audit log page" | Re-trigger Greptile |
| @@ -57,9 +61,9 @@ function AppLayout() { | |||
| type: 'error', | |||
| }); | |||
| } | |||
| navigate(`/?connectionId=${connections[0].id}`, { replace: true }); | |||
| navigate(`${location.pathname}?connectionId=${connections[0].id}`, { replace: true }); | |||
| } | |||
There was a problem hiding this comment.
hasShownInvalidToast ref never resets on route change
The hasShownInvalidToast ref is set to true the first time an invalid connectionId triggers a redirect, but it is never cleared. Because the ref persists for the lifetime of AppLayout, switching between / and /audit-log with an invalid connectionId will only ever surface the toast once per session. A second invalid-connection navigation to a different connection-scoped route will redirect silently.
There was a problem hiding this comment.
Pull request overview
Adds a new admin-only, per-connection Audit Log page at /audit-log, wires it into routing, and introduces a sidebar footer entry point that links to the page and exposes build metadata.
Changes:
- Added a new
AuditLogpage with a connection dropdown and an empty-state placeholder. - Updated routing to include
/audit-logand generalized connectionId validation/redirect to connection-scoped routes. - Added an ObjectSidebar footer with an Audit Log icon and a version tooltip showing the git commit hash.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/pages/AuditLog.tsx |
New Audit Log page (stub UI) with connection selection and admin gating. |
src/components/sql-editor/ObjectSidebar.tsx |
Adds sidebar footer entry point to Audit Log + version/commit tooltip. |
src/App.tsx |
Registers /audit-log route and generalizes connectionId redirect logic to include it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- AuditLog: defer the admin gate until connections load so admins don't flash the denied state; keep the connection dropdown outside the gate so non-admins can switch to a connection they can access - App: gate useEditorNavigation to the editor route so /audit-log no longer writes editor URL params (schema/object) or fires schema/table queries; reset the invalid-connection toast guard on valid connections - useEditorNavigation/useQuery: thread an enabled flag through to disable schema/table queries and the URL-sync effect when inactive - ObjectSidebar: add aria-label to the audit-log icon button and make the version tooltip trigger keyboard-focusable Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| const { data: connections, isLoading } = useConnections() | ||
| const { hasAdmin } = useConnectionPermissions(connectionId) | ||
|
|
||
| // Permissions are derived from the connections query, so defer the admin gate | ||
| // until it resolves — otherwise admins briefly see the denied state on load. | ||
| const content = isLoading || !connections ? ( | ||
| <div className="text-gray-500 text-sm">Loading…</div> | ||
| ) : !hasAdmin ? ( | ||
| <p className="text-gray-600"> | ||
| You need admin permission on this connection to view its audit log. | ||
| </p> | ||
| ) : ( | ||
| <div className="flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-gray-300 py-16 text-gray-500"> | ||
| <ScrollText size={32} /> | ||
| <p className="text-sm">No audit log entries yet.</p> | ||
| </div> | ||
| ) |
Resolve useConnections() error and empty-list states explicitly before the admin gate, so a query error no longer shows "Loading…" forever and zero connections shows a clear message instead of "need admin permission". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the focusable <span tabIndex=0> with a <button type="button"> so the version/commit tooltip trigger has proper interactive semantics for keyboard and screen-reader users. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Adds an admin-only, per-connection Audit Log page at
/audit-log.AuditLogpage (src/pages/AuditLog.tsx) — full-width, with a connection dropdown filter that drives theconnectionIdquery param. Gated on the selected connection'sadminpermission (non-admins see a "need admin permission" message).App.tsx. The connection-validation redirect (missing/invalidconnectionId→ first connection) is generalized from editor-only to connection-scoped routes (/and/audit-log), preserving the current path.ObjectSidebar.tsx: a horizontal divider with an audit-log icon (navigates to/audit-log) on the left and the app version on the right; hovering the version shows the git commit hash.Notes
Test plan
/audit-log?connectionId=<id>renders for an admin on that connectionconnectionIdparam/audit-logwith no/invalidconnectionIdredirects to the first connection🤖 Generated with Claude Code