Skip to content

fix (audit-logs): audit logs page breaking due to react-router-dom import #1394

Merged
paanSinghCoder merged 3 commits intomainfrom
fix/vite-config
Feb 18, 2026
Merged

fix (audit-logs): audit logs page breaking due to react-router-dom import #1394
paanSinghCoder merged 3 commits intomainfrom
fix/vite-config

Conversation

@paanSinghCoder
Copy link
Contributor

@paanSinghCoder paanSinghCoder commented Feb 18, 2026

The issue

Opening the audit logs side panel caused:
Cannot destructure property 'basename' of 'h.useContext(...)' as it is null — Router context was null where expected it.

Why it happened

lib should be react-router-dom agnostic.

What the Vite config does

Removing the react-router-dom import from lib.

…with path aliasing to avoid conflict with host
@vercel
Copy link

vercel bot commented Feb 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Feb 18, 2026 10:17am

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Enhanced navigation functionality in the audit logs details panel for Actor and Organization links.
  • Chores

    • Updated @raystack/apsara development dependency to v0.56.2.

Walkthrough

This pull request adds a navigation callback mechanism to audit logs components by propagating an onNavigate prop through the component hierarchy, and replaces react-router Link with a custom Button implementation in list item links. A dependency version bump is also included.

Changes

Cohort / File(s) Summary
Dependency Update
web/lib/package.json
Bumped @raystack/apsara from ^0.56.0 to ^0.56.2.
Navigation Prop Propagation
web/apps/admin/src/pages/audit-logs/AuditLogsPage.tsx, web/lib/admin/views/audit-logs/index.tsx, web/lib/admin/views/audit-logs/sidepanel-details.tsx
Added useNavigate hook in AuditLogsPage and propagated onNavigate callback prop through component hierarchy. AuditLogsView and SidePanelDetails now accept and forward the optional onNavigate: (path: string) => void prop.
Navigation Implementation
web/lib/admin/views/audit-logs/sidepanel-list-link.tsx
Removed react-router Link dependency and replaced with a Button component that conditionally calls onNavigate(href) on click when both isLink and onNavigate are provided. Added optional data-test-id prop for testing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


Comment @coderabbitai help to get the list of available commands and usage tips.

@paanSinghCoder paanSinghCoder requested a review from rsbh February 18, 2026 10:00
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
web/apps/admin/vite.config.ts (1)

37-40: Make the alias robust to workspace hoisting.
path.resolve(__dirname, "node_modules/react-router-dom") assumes a local node_modules folder. In pnpm/yarn workspaces, this path can be absent, causing the alias to point to a non-existent location. Consider resolving via Node’s module resolution instead.

♻️ Suggested change
 import path from "path";
+import { createRequire } from "module";
 import { fileURLToPath } from "url";

 const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const require = createRequire(import.meta.url);
+const reactRouterDomPath = require.resolve("react-router-dom");

   resolve: {
     alias: {
-      "react-router-dom": path.resolve(__dirname, "node_modules/react-router-dom"),
+      "react-router-dom": reactRouterDomPath,
     },
   },

@paanSinghCoder paanSinghCoder changed the title chore: update @raystack/apsara to version 0.56.2 and add Vite config … fix (vite.config): audit logs page breaking Feb 18, 2026
@paanSinghCoder paanSinghCoder changed the title fix (vite.config): audit logs page breaking fix (vite.config): audit logs page breaking due to duplicate react-router-dom Feb 18, 2026
@coveralls
Copy link

coveralls commented Feb 18, 2026

Pull Request Test Coverage Report for Build 22135299149

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 38.323%

Totals Coverage Status
Change from base Build 22087710772: 0.0%
Covered Lines: 16156
Relevant Lines: 42158

💛 - Coveralls

@paanSinghCoder paanSinghCoder changed the title fix (vite.config): audit logs page breaking due to duplicate react-router-dom fix (audit-logs): audit logs page breaking due to react-router-dom import Feb 18, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
web/lib/admin/views/audit-logs/sidepanel-list-link.tsx (1)

5-33: Discriminated union recommended to prevent silent non-link rendering when isLink is true without onNavigate.

All current usages correctly pass onNavigate when using SidepanelListItemLink. However, the current prop design allows isLink={true} with missing onNavigate, which silently renders as plain text instead of a link. Consider adopting the discriminated union pattern to enforce this constraint at compile time and prevent future misconfiguration:

🔧 Suggested type tightening (discriminated union)
-type SidepanelListItemLinkProps = {
-  isLink: boolean;
-  children: ReactNode;
-  href: string;
-  label: string;
-  onNavigate?: (path: string) => void;
-  "data-test-id"?: string;
-};
+type SidepanelListItemLinkProps =
+  | {
+      isLink: true;
+      children: ReactNode;
+      href: string;
+      label: string;
+      onNavigate: (path: string) => void;
+      "data-test-id"?: string;
+    }
+  | {
+      isLink: false;
+      children: ReactNode;
+      href: string;
+      label: string;
+      onNavigate?: never;
+      "data-test-id"?: string;
+    };

@paanSinghCoder paanSinghCoder merged commit 523ef56 into main Feb 18, 2026
8 checks passed
@paanSinghCoder paanSinghCoder deleted the fix/vite-config branch February 18, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants