Skip to content

chore: Navigation becomes loosely tied to the pages#2927

Merged
chronark merged 6 commits intomainfrom
navbar-fixes
Feb 28, 2025
Merged

chore: Navigation becomes loosely tied to the pages#2927
chronark merged 6 commits intomainfrom
navbar-fixes

Conversation

@perkinsjr
Copy link
Member

@perkinsjr perkinsjr commented Feb 27, 2025

What does this PR do?

I created a generic navigation.tsx in our components for the simple navigation that is reused multiple times. Any non generic got their own navigation.tsx in their respective folder structure to pass props around.

It looks like a lot of code but we actually remove code that was reused, in mutiple places like "settings".

Fixes # (issue)

Fixes Main issues at the same time.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

Click the dashboard like crazy! It worked for me, I tried all of screens to make sure none of them were broken.

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • New Features

    • Introduced a unified navigation experience across the dashboard, simplifying access to API management, keys, audits, permissions, roles, identities, logs, and settings.
  • Refactor

    • Streamlined and consolidated navigation elements into a cleaner, more intuitive interface for improved usability and consistency.

This breaks navigation to a simple navigation.tsx file allowing for full
control on each page or segment, with the ability to make single changes
without breaking entire layouts.
Refactors for a generic navigation and finishes the final ones
@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2025

⚠️ No Changeset found

Latest commit: 7be51ac

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Feb 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2025 9:58am
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2025 9:58am
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2025 9:58am
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2025 9:58am

@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2025

Thank you for following the naming conventions for pull request titles! 🙏

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

📝 Walkthrough

Walkthrough

The changes replace the legacy Navbar component with a new, consistently named Navigation component across various parts of the dashboard application. This refactoring spans API management (including key and settings pages), audit, authorization (permissions and roles), identities, logs, ratelimits, settings (billing, plans, general, root keys, team, user, vercel), and a shared navigation component. In most instances, the detailed breadcrumb structure and multiple action elements have been streamlined or consolidated into the new navigation pattern with simplified props (such as href, name, and icon).

Changes

File(s) Change Summary
apps/dashboard/app/(app)/apis/** (including /keys/..., /settings/..., /navigation.tsx, /page.tsx) Introduced new Navigation components to replace the legacy Navbar across API key management, API settings, and API listing pages. The new components handle breadcrumbs, copy actions, and creation buttons using simplified props.
apps/dashboard/app/(app)/audit/** Removed the old Navbar and its breadcrumbs, replacing it with a Navigation component that renders a single audit link with an InputSearch icon.
apps/dashboard/app/(app)/authorization/{permissions,roles}/** Replaced the detailed Navbar (with badges, tooltips, and action buttons such as delete/update) with new Navigation components. Permissions and roles pages now use streamlined navigation that accepts either identifiers or workspace data.
apps/dashboard/app/(app)/identities/** Substituted the Navbar (which used a Fingerprint icon) with a new Navigation component that takes the identityId prop for both detail and listing pages.
apps/dashboard/app/(app)/logs/** Replaced the multi-element Navbar with a simplified Navigation component that uses the Layers3 icon and directly renders navigation props.
apps/dashboard/app/(app)/ratelimits/** Updated the import in namespace-navbar.tsx and introduced a new Navigation component in ratelimits pages, incorporating a CreateNamespaceButton in the actions area.
apps/dashboard/app/(app)/settings/** (billing, billing plans, general, root-keys, team, user, vercel) Across various settings pages, the legacy Navbar and its breadcrumb/action structures have been replaced by the new Navigation component which accepts props (href, name, and icon) to render a simplified navigation link.
apps/dashboard/components/navigation/navigation.tsx Added a new reusable Navigation component that wraps the Navbar from the navigation library, accepting href, name, and icon props to render breadcrumbs in a consistent format.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant N as Navigation Component
  participant NB as Navbar UI Layer

  U->>N: Load page with navigation props
  N->>NB: Render breadcrumbs and action buttons
  U->>NB: Click on a breadcrumb or action (e.g., copy ID, create key)
  NB->>N: Handle the user interaction event
  N-->>U: Trigger navigation or copy action feedback
Loading

Suggested labels

Good first issue, Bug

Suggested reviewers

  • mcstepp
  • chronark
  • ogzhanolguncu

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a36a4f and 5c52b7f.

📒 Files selected for processing (1)
  • apps/dashboard/app/(app)/settings/vercel/page.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/app/(app)/settings/vercel/page.tsx
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: autofix
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Go API Local / test_agent_local
  • GitHub Check: Build / Build
  • GitHub Check: Analyze (javascript-typescript)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel vercel bot temporarily deployed to Preview – dashboard February 27, 2025 22:47 Inactive
Copy link
Contributor

@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.

Actionable comments posted: 3

🧹 Nitpick comments (10)
apps/dashboard/app/(app)/settings/root-keys/navigation.tsx (2)

8-23: Breadcrumb text doesn't fully match the navigation context.

The breadcrumb text is simply "Settings" but the href is "/settings/root-keys". Consider changing the text to be more specific (e.g., "Root Keys") to better represent where the user will navigate to, or add another breadcrumb to show the full navigation path (Settings > Root Keys).


11-15: Consider adding a more descriptive breadcrumb hierarchy.

For better user navigation context, consider adding a parent breadcrumb for "Settings" that leads to the main settings page, followed by the "Root Keys" as the active page:

<Navbar.Breadcrumbs icon={<Gear />}>
+  <Navbar.Breadcrumbs.Link href="/settings">Settings</Navbar.Breadcrumbs.Link>
-  <Navbar.Breadcrumbs.Link href="/settings/root-keys" active>
-    Settings
+  <Navbar.Breadcrumbs.Link href="/settings/root-keys" active>
+    Root Keys
  </Navbar.Breadcrumbs.Link>
</Navbar.Breadcrumbs>
apps/dashboard/app/(app)/authorization/roles/[roleId]/navigation.tsx (1)

13-19: Improve breadcrumb hierarchy clarity.

The first two breadcrumbs both say "Authorization" and "Roles" but have the same href. Consider changing the first breadcrumb to just link to the authorization page:

<Navbar.Breadcrumbs icon={<ShieldKey />}>
- <Navbar.Breadcrumbs.Link href="/authorization/roles">Authorization</Navbar.Breadcrumbs.Link>
+ <Navbar.Breadcrumbs.Link href="/authorization">Authorization</Navbar.Breadcrumbs.Link>
  <Navbar.Breadcrumbs.Link href="/authorization/roles">Roles</Navbar.Breadcrumbs.Link>
  <Navbar.Breadcrumbs.Link href={`/authorization/roles/${role.id}`} isIdentifier active>
    {role.id}
  </Navbar.Breadcrumbs.Link>
</Navbar.Breadcrumbs>
apps/dashboard/app/(app)/apis/[apiId]/settings/navigation.tsx (1)

23-31: Consider adding a more descriptive label for the API ID badge.

The badge shows only the raw ID without context. Consider adding a small label for clarity:

<Badge
  key="apiId"
  variant="secondary"
  className="flex justify-between w-full gap-2 font-mono font-medium ph-no-capture"
>
+ <span className="text-muted-foreground">API ID:</span>
  {api.id}
  <CopyButton value={api.id} />
</Badge>
apps/dashboard/components/navigation/navigation.tsx (1)

7-7: Consider adding optional props for flexibility.

To make this component even more reusable, you might want to add optional props for additional actions or multiple breadcrumbs:

export function Navigation({ 
  href, 
  name, 
  icon,
+ actions,
+ parentBreadcrumbs
}: { 
  href: string; 
  name: string; 
  icon: ReactNode;
+ actions?: ReactNode;
+ parentBreadcrumbs?: Array<{href: string; name: string}>;
}) {

This would allow the component to handle more complex navigation scenarios while maintaining the same streamlined API for simple cases.

apps/dashboard/app/(app)/settings/team/page.tsx (1)

104-104: Consider standardizing prop ordering for consistency.

The order of props differs from line 54 (href, name, icon) to line 104 (href, icon, name). While this doesn't affect functionality, consistent ordering improves readability and maintainability.

-      <Navigation href="/settings/team" icon={<Gear />} name="Settings" />
+      <Navigation href="/settings/team" name="Settings" icon={<Gear />} />
apps/dashboard/app/(app)/authorization/roles/navigation.tsx (2)

8-25: Consider strengthening the type definitions.

The interface uses any types for permissions which could be more strongly typed for better type safety.

-      permissions: Array<{
-        permission: any; // We could type this further if needed
-      }>;
+      permissions: Array<{
+        permission: {
+          id: string;
+          name: string;
+          description?: string | null;
+        };
+      }>;
-    permissions: Array<any>; // We need this for CreateNewRole component
+    permissions: Array<{
+      id: string;
+      name: string;
+      description?: string | null;
+    }>; // We need this for CreateNewRole component

37-40: Consider making the infinity limit more explicit.

Using Number.POSITIVE_INFINITY works but may be confusing in the UI when formatted.

-          {Intl.NumberFormat().format(Number.POSITIVE_INFINITY)} used{" "}
+          {Intl.NumberFormat().format(Number.POSITIVE_INFINITY)} used (unlimited){" "}
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/navigation.tsx (1)

42-43: Consider making the badge width more constrained.

The w-full class on the Badge might make it unnecessarily wide in some layouts.

-          className="flex justify-between w-full gap-2 font-mono font-medium ph-no-capture"
+          className="flex justify-between max-w-md gap-2 font-mono font-medium ph-no-capture"
apps/dashboard/app/(app)/authorization/permissions/[permissionId]/navigation.tsx (1)

14-14: Consider extracting the tooltip threshold to a constant.

The magic number 16 used for determining tooltip display could be extracted to a named constant at the top of the file for better maintainability.

+const PERMISSION_NAME_TOOLTIP_THRESHOLD = 16;
 export function Navigation({
   permissionId,
   permission,
 }: { permissionId: string; permission: Permission }) {
-  const shouldShowTooltip = permission.name.length > 16;
+  const shouldShowTooltip = permission.name.length > PERMISSION_NAME_TOOLTIP_THRESHOLD;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc5d6b1 and 8a36a4f.

📒 Files selected for processing (46)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/audit/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/audit/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/authorization/permissions/[permissionId]/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/permissions/[permissionId]/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/authorization/permissions/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/permissions/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/authorization/roles/[roleId]/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/authorization/roles/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/roles/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/identities/[identityId]/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/identities/[identityId]/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/identities/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/identities/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/logs/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/namespace-navbar.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/billing/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/billing/plans/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/plans/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/general/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/root-keys/[keyId]/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys/[keyId]/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/root-keys/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys/new/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/root-keys/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/team/page.tsx (3 hunks)
  • apps/dashboard/app/(app)/settings/user/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/vercel/page.tsx (3 hunks)
  • apps/dashboard/components/navigation/navigation.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/namespace-navbar.tsx
🧰 Additional context used
🧠 Learnings (1)
apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx (1)
Learnt from: AkshayBandi027
PR: unkeyed/unkey#2215
File: apps/dashboard/app/(app)/@breadcrumb/authorization/roles/[roleId]/page.tsx:28-29
Timestamp: 2024-11-10T16:45:16.994Z
Learning: In `authorization/roles/[roleId]/update-role.tsx`, the tag `role-${role.id}` is revalidated after updating a role to ensure that the caching mechanism is properly handled for roles.
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./internal/hash
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: Test Go API Local / test_agent_local
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: Build / Build
  • GitHub Check: Test API / API Test Local
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (59)
apps/dashboard/app/(app)/audit/page.tsx (1)

1-1: Navigation component simplification looks good

The replacement of the previous Navbar component with the new Navigation component creates a cleaner interface with direct props. This change aligns perfectly with the PR objective of creating a generic navigation component that reduces code duplication while maintaining the same functionality.

Also applies to: 16-16

apps/dashboard/app/(app)/settings/vercel/page.tsx (2)

2-2: Import updated to use the new Navigation component.

The component import has been correctly updated to use the new Navigation component from the dedicated navigation folder, which aligns with the PR objective of creating a generic navigation component.


54-54: Simplified navigation implementation.

The Navigation component provides a cleaner interface with simple props (href, name, icon) compared to the previous Navbar implementation, reducing complexity while maintaining the same functionality.

apps/dashboard/app/(app)/identities/navigation.tsx (1)

1-16: Looks good - clean implementation of the identities navigation component

The Navigation component follows the new pattern described in the PR objectives, creating a reusable navigation structure for the identities section. The component properly uses the Navbar from the shared component library with appropriate breadcrumb structure and icon.

apps/dashboard/app/(app)/audit/navigation.tsx (1)

1-14: Navigation component implementation looks good

The Navigation component for the audit section is well-structured and consistent with the pattern being implemented across the application. The component correctly uses the Navbar with appropriate breadcrumb and icon.

apps/dashboard/app/(app)/ratelimits/navigation.tsx (1)

1-17: Good implementation with appropriate action button

The Navigation component for ratelimits follows the same pattern as the other navigation components while appropriately including the CreateNamespaceButton in the actions section. This is a good example of how the navigation pattern can be extended for specific needs.

apps/dashboard/app/(app)/logs/navigation.tsx (1)

1-14: Clean implementation of logs navigation

The Navigation component for the logs section is well-implemented and follows the consistent pattern established across the application. The component correctly uses the appropriate icon and breadcrumb structure.

apps/dashboard/app/(app)/settings/billing/plans/navigation.tsx (1)

1-18: Clean implementation of reusable navigation component!

The implementation creates a reusable navigation component specifically for the Plans page, with a clear breadcrumb structure and proper active state. The comment on line 6 effectively communicates the purpose and reusability of this component.

apps/dashboard/app/(app)/ratelimits/page.tsx (2)

6-6: Good modularization of navigation

The import of the dedicated Navigation component aligns well with the PR's objective to make navigation loosely tied to pages.


33-33: Clean replacement of inline navbar with modular component

The implementation correctly replaces what was likely an inline Navbar implementation with the new modular Navigation component, reducing code duplication.

apps/dashboard/app/(app)/apis/navigation.tsx (2)

7-10: Well-defined props interface

The NavigationProps type is clear and provides flexibility to the Navigation component to handle different UI states.


12-23: Solid implementation with conditional rendering

The Navigation component is well-structured with properly organized breadcrumbs and actions sections. The conditional rendering of the CreateApiButton based on APIs length and isNewApi state is a good practice that improves UX.

apps/dashboard/app/(app)/identities/page.tsx (2)

13-13: Good modularization of navigation

The import of the dedicated Navigation component aligns well with the PR's objective to make navigation loosely tied to pages.


41-41: Clean replacement of inline navbar with modular component

The implementation correctly replaces what was likely an inline Navbar implementation with the new modular Navigation component, reducing code duplication.

apps/dashboard/app/(app)/apis/[apiId]/settings/navigation.tsx (1)

10-35: Verify prop type consistency with its usage.

The component accepts an api prop of type Api, which is correctly used throughout. However, make sure any dependent files also pass the complete api object, not just an ID or partial data.

Additionally, the component properly provides contextual navigation with breadcrumbs and relevant actions, which aligns well with the PR's goal of standardizing navigation.

apps/dashboard/components/navigation/navigation.tsx (1)

6-17: Well-designed reusable navigation component.

This component provides a simple, reusable navigation pattern for sections that need minimal breadcrumb structure. It aligns well with the PR objective to create generic navigation components and reduce duplicated code.

apps/dashboard/app/(app)/identities/[identityId]/navigation.tsx (1)

1-26: Well-structured navigation component for identity pages.

The new Navigation component is clean and focused, handling navigation for the identity details page. It effectively implements breadcrumbs with proper truncation for long identity IDs (with the w-[200px] truncate classes).

apps/dashboard/app/(app)/apis/[apiId]/navigation.tsx (1)

10-32: Consider handling potential null keyAuthId gracefully.

The component looks well-structured and provides good functionality with breadcrumbs and actions. However, line 28 uses a non-null assertion (!) for api.keyAuthId, which could cause runtime errors if it's null.

Consider adding a null check or providing a fallback:

-<CreateKeyButton apiId={api.id} keyAuthId={api.keyAuthId!} />
+{api.keyAuthId && <CreateKeyButton apiId={api.id} keyAuthId={api.keyAuthId} />}

Or if a CreateKeyButton should always be present, ensure that keyAuthId is never null in the API type definition or provide proper error handling.

apps/dashboard/app/(app)/authorization/permissions/[permissionId]/page.tsx (2)

8-8: Good import of dedicated Navigation component.

The new import follows the established pattern of specific navigation components for unique cases.


66-66: Simplified Navigation implementation reduces complexity.

Replacing what was likely a more complex navigation structure with this dedicated component improves readability and maintainability while reducing duplication.

apps/dashboard/app/(app)/logs/page.tsx (3)

4-4: Switched to using consistent icon library.

Using the @unkey/icons package maintains consistency across the application.


8-8: Using shared Navigation component follows PR objective.

This import shows the dual approach mentioned in the PR: using the generic Navigation component from a shared location for simpler navigation scenarios.


23-23: Simplified navigation implementation with generic component.

The generic Navigation component with basic props (href, name, icon) makes this implementation very clean and maintainable compared to what was likely a more complex structure before.

apps/dashboard/app/(app)/authorization/permissions/navigation.tsx (1)

1-28: Well-structured, reusable navigation component.

This new Navigation component is well designed with clear props and provides a consistent navigation experience for the permissions section. The comment on line 9 suggests this pattern will be reused elsewhere.

apps/dashboard/app/(app)/settings/root-keys/[keyId]/navigation.tsx (1)

1-22: Clean implementation with good attention to UI details.

The navigation component correctly handles key ID display with appropriate truncation and styling. The breadcrumb structure provides clear context for the user's location within the settings.

apps/dashboard/app/(app)/apis/page.tsx (2)

7-7: Import looks good.

The Navigation component import correctly replaces the previous Navbar import.


47-47:

Details

✅ Verification successful

Verify that all previous Navbar functionality is preserved.

The Navigation component now receives isNewApi and apisLength props. Ensure that the Navigation component implements all the functionality that was previously provided by the Navbar, including any actions like the CreateApiButton that was previously imported separately.


🏁 Script executed:

#!/bin/bash
# Check if Navigation component includes CreateApiButton functionality
rg -A 10 "export function Navigation" "./apps/dashboard/app/(app)/apis/navigation.tsx"

Length of output: 486


Navigation component functionality is preserved; CreateApiButton is correctly integrated.

The update passes both isNewApi and apisLength to Navigation, and the component renders the CreateApiButton within <Navbar.Actions> using a conditional (defaultOpen={apisLength === 0 || isNewApi}) that correctly mirrors the previous behavior.

  • The CreateApiButton is present in the Navigation component.
  • The conditional logic for opening the CreateApiButton matches the intended functionality (triggered when there are no APIs or a new API is indicated).
apps/dashboard/app/(app)/settings/root-keys/new/page.tsx (2)

6-6: Import looks good.

The Navigation component import correctly replaces the previous Navbar import.


32-32:

Details

✅ Verification successful

Consider whether navigation context is needed.

The Navigation component is used without props here. Verify that this provides sufficient context to users about their location in the app (previously handled by Navbar breadcrumbs).


🏁 Script executed:

#!/bin/bash
# Check the implementation of the root-keys Navigation component
rg -A 10 "export function Navigation" "./apps/dashboard/app/(app)/settings/root-keys/navigation.tsx"

Length of output: 506


Navigation Context Confirmed

The verification shows that the <Navigation /> component renders the complete navigation context—including breadcrumbs with an active "Settings" link and a primary action to create a new root key—ensuring users clearly understand their location in the app. No additional props are required at this time.

  • File: apps/dashboard/app/(app)/settings/root-keys/new/page.tsx (Line 32)
  • Component Details: The Navigation component internally renders <Navbar.Breadcrumbs> and <Navbar.Actions>, replicating the previous functionality of Navbar breadcrumbs.
apps/dashboard/app/(app)/settings/billing/plans/page.tsx (1)

10-10: Navigation component implementation looks good!

The change replaces the previous navigation structure with a dedicated Navigation component, aligning with the PR objective of creating a loosely coupled, reusable navigation system. This approach reduces code duplication and improves maintainability.

Also applies to: 23-23

apps/dashboard/app/(app)/settings/general/page.tsx (1)

3-3: Clean implementation of the new Navigation pattern!

The change properly implements the new Navigation component with appropriate props (href, name, and icon), following the consistent pattern across the codebase. This approach creates a cleaner separation of concerns while maintaining the necessary context for the settings page.

Also applies to: 29-29

apps/dashboard/app/(app)/authorization/permissions/page.tsx (1)

14-14: Good implementation of context-aware Navigation component!

The Navigation component is now provided with the numberOfPermissions as a prop, allowing it to maintain relevant page-specific information while adhering to the consistent navigation pattern. This approach effectively supports the PR's goal of reducing duplicated code while still preserving page-specific context.

Also applies to: 59-59

apps/dashboard/app/(app)/identities/[identityId]/page.tsx (1)

23-23: Proper implementation of dynamic Navigation component!

The change correctly passes the identityId to the Navigation component, which ensures that page-specific context is maintained while benefiting from the consistent navigation structure. This approach successfully balances the need for standardization with the requirements of contextual navigation.

Also applies to: 60-60

apps/dashboard/app/(app)/settings/user/page.tsx (2)

2-2: Import change looks good.

The import of the new Navigation component from the central location aligns with the PR objective of creating a reusable navigation component.


29-29: Navigation component implementation is clean.

The Navigation component successfully replaces the previous navbar with a simpler interface that takes only the essential props: href, name, and icon. This aligns with the PR's goal of reducing code duplication and creating a loosely-coupled navigation system.

apps/dashboard/app/(app)/settings/team/page.tsx (2)

24-24: Import change looks good.

The import of the new Navigation component from the central location aligns with the PR objective of creating a reusable navigation component.


54-54: Navigation component implemented correctly in conditional rendering.

The Navigation component is properly implemented in the conditional rendering path when no organization is present.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx (2)

23-23: Import of local navigation component looks good.

Using a context-specific navigation implementation aligns with the PR's goal of maintaining individual navigation files in their respective folder structures for specific cases.


264-264: Specialized Navigation component implementation is appropriate.

The specialized Navigation component takes context-specific objects (api and apiKey) rather than simple props, which is appropriate for this more complex navigation context. This aligns with the PR's approach of using specialized navigation components where needed.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/page.tsx (2)

6-6: Import of local navigation component looks good.

Using a context-specific navigation implementation aligns with the PR's goal of maintaining individual navigation files in their respective folder structures for specific cases.


30-30: Specialized Navigation component implementation is appropriate.

The specialized Navigation component takes context-specific parameters (apiId and keyA) rather than simple props, which is appropriate for this more complex navigation context. This aligns with the PR's approach of using specialized navigation components where needed.

apps/dashboard/app/(app)/settings/root-keys/[keyId]/page.tsx (2)

11-11: Clean import of the new Navigation component.

The import statement correctly references the Navigation component from a relative path.


130-130: Navigation component implementation looks good.

The Navigation component is cleanly implemented, passing just the keyId prop which simplifies the interface compared to the previous detailed Navbar implementation with breadcrumbs.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/navigation.tsx (1)

1-53: Well-structured Navigation component with clear type definitions.

The Navigation component implements a clean breadcrumb structure with properly typed props and clear navigation hierarchy. The component effectively:

  • Uses the Navbar component for consistent UI
  • Properly constructs the breadcrumb path from APIs to the current context
  • Includes the API identifier in a badge with a copy button for convenience

This implementation aligns with the PR objective of creating a generic navigation component that can be reused across the application.

apps/dashboard/app/(app)/apis/[apiId]/page.tsx (2)

14-14: Clean import of the Navigation component.

The import statement correctly references the Navigation component from a relative path.


140-140: Navigation component implementation looks good.

The Navigation component is cleanly implemented, passing the api object which contains all necessary information for constructing the navigation elements. This simplifies the interface compared to the previous detailed Navbar implementation.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/page.tsx (2)

9-9: Clean import of the Navigation component.

The import statement correctly references the Navigation component from a relative path.


36-36: Navigation component implementation looks good.

The Navigation component is cleanly implemented, passing both the apiId and keyAuth object (as keyA) which contain all necessary information for constructing the navigation elements. This implementation is consistent with the refactoring pattern applied throughout the application.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/navigation.tsx (1)

17-20: The NavigationProps interface doesn't match its usage.

The component's interface defines api and apiKey props, which aligns with how they're used in the component.

apps/dashboard/app/(app)/settings/root-keys/page.tsx (1)

38-38:

Details

❓ Verification inconclusive

Verify if Navigation component needs props.

The Navigation component is being used without props, which is different from its usage in other files. Ensure this is intentional and that the component has appropriate defaults.


🏁 Script executed:

#!/bin/bash
# Search for the Navigation component definition in the root-keys folder
fd "navigation.tsx" apps/dashboard/app/\\(app\\)/settings/root-keys --exec cat {} \;

Length of output: 267


Verify Navigation component's props usage

It appears the script execution failed due to shell escaping issues with parentheses, so we couldn’t confirm the component definition automatically. Please manually verify that the Navigation component is not missing any required props. In particular, ensure that its implementation either sets appropriate default props or does not expect props—especially since it’s used differently in other parts of the codebase. You may re-run a corrected search (e.g., using quotes around the folder path) to inspect the component’s definition and confirm its intended usage.

apps/dashboard/app/(app)/settings/billing/page.tsx (2)

44-44: LGTM: Navigation implementation is consistent with the PR objective.

The component usage with href, name, and icon props aligns with the PR goal of creating a simplified, reusable navigation structure.


2-2:

Details

❓ Verification inconclusive

Import path differs from other files.

This file imports Navigation from "@/components/navigation/navigation" while other files import from local "navigation" files. Verify if this is the intended pattern.


🏁 Script executed:

#!/bin/bash
# Check how Navigation is imported across the codebase
rg "import.*Navigation.*from" apps/dashboard

# Check if the shared Navigation component exists
fd "navigation.tsx" apps/dashboard/components

Length of output: 3045


Clarification on Navigation Import Patterns
In the dashboard’s settings routes (e.g. billing, user, general, team, vercel), the Navigation component is imported using the absolute path (@/components/navigation/navigation), which is consistent across these files. In contrast, other areas (such as several API and nested routes like billing/plans or root-keys) import Navigation using a relative path (e.g. ./navigation or ../navigation). Please confirm that this differentiation is intentional. If the shared Navigation component is meant for top-level settings while a locally scoped version is used in other contexts, consider documenting this design decision to avoid potential confusion.

apps/dashboard/app/(app)/apis/[apiId]/settings/page.tsx (1)

14-14: Implementation follows PR objective for navigation simplification.

The change replaces the previous navigation approach with a more specific Navigation component that is properly passed the API object. This aligns with the PR objective to create loosely coupled navigation components for specific cases.

Also applies to: 57-57

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/page.tsx (1)

11-11: Navigation component implementation is consistent with PR objective.

The new approach correctly passes both the apiId and apiKey objects to the Navigation component, maintaining the necessary context while simplifying the navigation structure.

Also applies to: 44-44

apps/dashboard/app/(app)/authorization/permissions/[permissionId]/navigation.tsx (1)

1-69: Well-structured reusable navigation component with appropriate UI features.

This navigation component implementation includes:

  • Clear breadcrumb hierarchy for authorization context
  • Appropriate tooltip handling for long permission names
  • Copy functionality for permission IDs and names
  • Integration with delete functionality

The comment on line 9 ("Reusable for settings where we only change the link") accurately describes the purpose of this component.

apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx (1)

5-5: Navigation implementation follows consistent pattern.

The change properly implements the same navigation pattern seen across other files, passing the role object to the component. This contributes to the overall goal of reducing code duplication as mentioned in the PR objectives.

Based on the retrieved learning, remember that updating a role involves revalidating the tag role-${role.id} for proper cache handling. Ensure that the new Navigation component preserves this behavior if it contains role update functionality.

Also applies to: 109-109

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/navigation.tsx (1)

1-59: Well-structured navigation component with clear organization.

The Navigation component is designed with clear typing, logical breadcrumb structure, and appropriate actions. This implementation aligns well with the PR objective of creating a generic navigation component that can be reused across different pages.

The breadcrumb structure provides a clear path for users to navigate through the application hierarchy, and the actions section offers useful functionality with the copy button and create key button.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/navigation.tsx (1)

47-47: Handle potential null keyAuthId value safely.

You're using a non-null assertion operator (!) on keyA.api.keyAuthId, but the type definition on line 14 indicates this property can be null. This could lead to runtime errors if a null value is encountered.

Consider handling the null case explicitly:

-<CreateKeyButton apiId={keyA.api.id} keyAuthId={keyA.api.keyAuthId!} />
+{keyA.api.keyAuthId ? (
+  <CreateKeyButton apiId={keyA.api.id} keyAuthId={keyA.api.keyAuthId} />
+) : (
+  // Fallback UI or disabled state when keyAuthId is null
+  <Button disabled>Create Key</Button>
+)}
apps/dashboard/app/(app)/authorization/roles/page.tsx (1)

13-13: Successful implementation of the navigation refactoring.

The addition of the Navigation component and its integration into the page structure successfully implements the PR objective of making navigation loosely tied to pages. This change simplifies the UI by moving the complex navigation logic into a dedicated component.

Also applies to: 59-59

Comment on lines +16 to +18
<Navbar.Breadcrumbs.Link href={`/authorization/permissions/${role.id}`} isIdentifier active>
{role.id}
</Navbar.Breadcrumbs.Link>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect link in breadcrumb navigation.

The link to permissions is using the role ID, but it should likely be linking to a role-specific page instead:

- <Navbar.Breadcrumbs.Link href={`/authorization/permissions/${role.id}`} isIdentifier active>
+ <Navbar.Breadcrumbs.Link href={`/authorization/roles/${role.id}`} isIdentifier active>
  {role.id}
</Navbar.Breadcrumbs.Link>

This appears to be a copy-paste error as you're in the roles section but linking to the permissions route.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Navbar.Breadcrumbs.Link href={`/authorization/permissions/${role.id}`} isIdentifier active>
{role.id}
</Navbar.Breadcrumbs.Link>
<Navbar.Breadcrumbs.Link href={`/authorization/roles/${role.id}`} isIdentifier active>
{role.id}
</Navbar.Breadcrumbs.Link>

@vercel vercel bot temporarily deployed to Preview – play February 27, 2025 23:49 Inactive
@vercel vercel bot temporarily deployed to Preview – www February 27, 2025 23:50 Inactive
@vercel vercel bot temporarily deployed to Preview – engineering February 27, 2025 23:50 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard February 27, 2025 23:53 Inactive
Copy link
Collaborator

@chronark chronark left a comment

Choose a reason for hiding this comment

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

This is nice, I haven't had time to check the deployment yet, but I like the refactor

Copy link
Contributor

@chronark lemme check the pages one by one then i'll merge

Copy link
Contributor

@ogzhanolguncu ogzhanolguncu left a comment

Choose a reason for hiding this comment

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

Pages look good I checked on preview.

@vercel vercel bot temporarily deployed to Preview – www February 28, 2025 09:53 Inactive
@vercel vercel bot temporarily deployed to Preview – play February 28, 2025 09:53 Inactive
@vercel vercel bot temporarily deployed to Preview – engineering February 28, 2025 09:54 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard February 28, 2025 09:58 Inactive
@chronark chronark merged commit bc8ebdb into main Feb 28, 2025
27 of 29 checks passed
@chronark chronark deleted the navbar-fixes branch February 28, 2025 09:59
@coderabbitai coderabbitai bot mentioned this pull request Apr 15, 2025
18 tasks
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.

3 participants