Skip to content

feat: root keys table - Merge after #3331#3332

Merged
ogzhanolguncu merged 4 commits intomainfrom
root-keys-table
Jun 25, 2025
Merged

feat: root keys table - Merge after #3331#3332
ogzhanolguncu merged 4 commits intomainfrom
root-keys-table

Conversation

@ogzhanolguncu
Copy link
Copy Markdown
Contributor

@ogzhanolguncu ogzhanolguncu commented Jun 16, 2025

What does this PR do?

This PR is continuation of #3331. This PR adds table view for root keys using tRPC defined in the previous PR.

Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

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?

/settings/root-keys-v2 check this page and compare it against /settings/root-keys.

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 comprehensive "Root Keys" management page with a virtualized, filterable, and paginated table displaying root key details, permissions, creation dates, and last updated times.
    • Added filter controls synchronized with URL parameters for advanced search and filtering of root keys.
    • Implemented visual indicators for critical permissions and last activity, along with interactive tooltips and action menus.
    • Provided skeleton loaders for a smoother experience during data fetching.
    • Added navigation enhancements with quick links and contextual actions for settings pages.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jun 16, 2025

⚠️ No Changeset found

Latest commit: 45a6c2d

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 16, 2025

Warning

Rate limit exceeded

@ogzhanolguncu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 11 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4d138bd and 45a6c2d.

📒 Files selected for processing (3)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/assigned-items-cell.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/last-updated.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/skeletons.tsx (1 hunks)
📝 Walkthrough

Walkthrough

This change introduces a complete "Root Keys" feature to the dashboard settings, including frontend React components for list display, filtering, navigation, and skeleton loaders, as well as backend TRPC API endpoints and schema validation for querying root keys with categorized permissions and pagination. All logic is modularized and strongly typed.

Changes

File(s) Change Summary
.../components/table/components/assigned-items-cell.tsx Adds AssignedItemsCell React component for displaying permission summary in the root keys table.
.../components/table/components/critical-perm-warning.tsx Adds CriticalPermissionIndicator React component to show critical permission warnings in the table.
.../components/table/components/last-updated.tsx Adds LastUpdated React component to display last updated timestamp with tooltip in the table.
.../components/table/components/skeletons.tsx Adds multiple skeleton loader components for table columns (root key, creation date, key, assigned keys, permissions, last updated, actions).
.../components/table/hooks/use-root-keys-list-query.ts Adds useRootKeysListQuery React hook for fetching paginated root keys data with infinite scroll, using TRPC.
.../components/table/query-logs.schema.ts Adds Zod schema and TypeScript types for validating/querying root keys payloads, including filter structure.
.../components/table/root-keys-list.tsx Adds RootKeysList React component: a virtualized, filterable table for displaying root keys with details and actions.
.../components/table/utils/get-row-class.ts Adds utility function and style constants for determining table row class names based on selection state.
.../filters.schema.ts Adds filter schema, field/operator enums, and types for root keys filtering, using Zod and strong typing.
.../hooks/use-filters.ts Adds useFilters React hook to manage filter state synchronized with URL query parameters.
.../navigation.tsx Adds Navigation React component for settings navigation bar with breadcrumbs and context-sensitive actions.
.../page.tsx Adds RootKeysPage React page component that renders the navigation and root keys list for the settings section.
.../lib/trpc/routers/index.ts Adds settings.rootKeys.query endpoint to the main TRPC router for querying root keys.
.../lib/trpc/routers/settings/root-keys/query.ts Adds queryRootKeys TRPC procedure: paginated query for root keys, with permission categorization, critical flag, and error handling.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant RootKeysPage
  participant RootKeysList
  participant useRootKeysListQuery
  participant TRPC API (queryRootKeys)
  participant Database

  User->>RootKeysPage: Navigates to Root Keys page
  RootKeysPage->>RootKeysList: Render table UI
  RootKeysList->>useRootKeysListQuery: Request root keys data (with filters, cursor)
  useRootKeysListQuery->>TRPC API (queryRootKeys): Fetch paginated root keys
  TRPC API (queryRootKeys)->>Database: Query root keys, permissions, apply filters
  Database-->>TRPC API (queryRootKeys): Return root keys and permissions
  TRPC API (queryRootKeys)-->>useRootKeysListQuery: Return data (with permission summary, critical flag)
  useRootKeysListQuery-->>RootKeysList: Provide root keys data, loading state
  RootKeysList-->>User: Display table rows, skeletons, and navigation actions
Loading

Possibly related PRs

  • unkeyed/unkey#3331: Adds and modifies the root keys feature, including the TRPC query procedure and filters schema, directly related at the code level.
  • unkeyed/unkey#2743: Introduces the Navbar component used by the new Navigation component for settings navigation, related at the component usage and extension level.

Suggested labels

🕹️ oss.gg, :joystick: 150 points

Suggested reviewers

  • perkinsjr
  • mcstepp
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 16, 2025

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

@ogzhanolguncu ogzhanolguncu changed the title feat: root keys table feat: root keys table - Merge after #3331 Jun 16, 2025
@vercel
Copy link
Copy Markdown

vercel bot commented Jun 16, 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 Jun 25, 2025 1:53pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2025 1:53pm

@vercel vercel bot temporarily deployed to Preview – dashboard June 16, 2025 14:51 Inactive
@ogzhanolguncu ogzhanolguncu marked this pull request as ready for review June 25, 2025 13:43
Copy link
Copy Markdown
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: 7

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 365c748 and 4d138bd.

📒 Files selected for processing (14)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/assigned-items-cell.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/critical-perm-warning.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/last-updated.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/skeletons.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/hooks/use-root-keys-list-query.ts (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/query-logs.schema.ts (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/root-keys-list.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/components/table/utils/get-row-class.ts (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/filters.schema.ts (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/hooks/use-filters.ts (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/navigation.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys-v2/page.tsx (1 hunks)
  • apps/dashboard/lib/trpc/routers/index.ts (2 hunks)
  • apps/dashboard/lib/trpc/routers/settings/root-keys/query.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/dashboard/app/(app)/settings/root-keys-v2/hooks/use-filters.ts (1)
Learnt from: ogzhanolguncu
PR: unkeyed/unkey#3401
File: apps/dashboard/app/(app)/logs/filters.query-params.ts:10-0
Timestamp: 2025-06-24T13:29:10.129Z
Learning: The `buildQueryParams` function in `apps/dashboard/app/(app)/logs/filters.query-params.ts` calls `useFilters()` hook inside it, but this is valid because the function is only called from within other React hooks, maintaining the Rules of Hooks compliance.
🔇 Additional comments (23)
apps/dashboard/app/(app)/settings/root-keys-v2/components/table/utils/get-row-class.ts (1)

15-24: Well-structured styling configuration.

The STATUS_STYLES constant provides a clean separation of styling concerns with appropriate Tailwind classes for different states.

apps/dashboard/lib/trpc/routers/index.ts (2)

88-88: LGTM! Proper import addition.

The import follows the established pattern and correctly imports the query function from the appropriate module.


125-129: LGTM! Router structure follows established patterns.

The nested router structure for settings.rootKeys.query is consistent with other endpoints in the codebase and provides a clean API surface.

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

5-23: Clean component structure and proper client-side rendering.

The component structure is well-organized with appropriate use of "use client" directive and clean JSX layout.


9-12: ```shell
#!/bin/bash

List all .tsx files under the settings directory

fd -t f -e tsx apps/dashboard/app/(app)/settings

Search those files for Next.js client hook useParams

rg -n 'useParams' -g '*.tsx' apps/dashboard/app/(app)/settings

Search for data fetching patterns (trpc.useQuery) in settings pages

rg -n 'trpc.useQuery' -g '.tsx' apps/dashboard/app/(app)/settings


</details>
<details>
<summary>apps/dashboard/app/(app)/settings/root-keys-v2/components/table/hooks/use-root-keys-list-query.ts (3)</summary>

`15-40`: **Robust filter validation and query parameter construction.**

The query parameter construction includes proper validation of operators against field configuration and handles edge cases appropriately.

---

`42-53`: **Well-configured infinite query with appropriate options.**

The TRPC infinite query is properly configured with pagination, infinite stale time, and disabled refetch options suitable for this use case.

---

`55-72`: **Efficient state management with Map data structure.**

The use of Map for storing root keys provides efficient lookups and the effect properly consolidates data from all fetched pages.

</details>
<details>
<summary>apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/critical-perm-warning.tsx (3)</summary>

`10-18`: **Clean conditional rendering pattern.**

The early return pattern for non-critical permissions is clean and avoids unnecessary DOM elements while maintaining consistent layout with the fixed-width div.

---

`20-38`: **Well-implemented interactive indicator with informative tooltip.**

The combination of `InfoTooltip` with conditional styling provides good user experience with clear visual feedback and helpful explanatory content.

---

`24-27`: **Clear and actionable tooltip content.**

The tooltip message effectively communicates the significance of critical permissions to users.

</details>
<details>
<summary>apps/dashboard/app/(app)/settings/root-keys-v2/components/table/query-logs.schema.ts (1)</summary>

`1-26`: **Well-structured schema implementation.**

The schema definition is clean and follows Zod best practices. The dynamic construction of filter fields using `reduce` is appropriate, and the type inference provides good TypeScript integration.

</details>
<details>
<summary>apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/assigned-items-cell.tsx (1)</summary>

`4-45`: **Clean component implementation with good separation of concerns.**

The component properly handles both empty and populated states with appropriate styling. The conditional class name logic is well-organized and readable.

</details>
<details>
<summary>apps/dashboard/app/(app)/settings/root-keys-v2/components/table/root-keys-list.tsx (1)</summary>

`161-161`: ```shell
#!/bin/bash
# Show the RootKeyResponse zod schema to verify available properties
rg -n -C5 "const RootKeyResponse" apps/dashboard/lib/trpc/routers/settings/root-keys/query.ts
apps/dashboard/app/(app)/settings/root-keys-v2/hooks/use-filters.ts (3)

13-15: LGTM! Clean mapping of filter fields to parsers.

The use of Object.fromEntries with type assertion is appropriate here for constructing the query params configuration.


22-45: Well-structured filter computation with proper validation.

Good use of useMemo to avoid unnecessary recomputations. The validation ensures only valid filters with string values and operators are included.


47-91: Robust filter update implementation with comprehensive validation.

Excellent error handling with clear messages for invalid fields, operators, and value types. The approach of initializing all fields to null ensures clean state updates.

apps/dashboard/lib/trpc/routers/settings/root-keys/query.ts (3)

7-37: Well-defined response schemas with appropriate pagination limit.

The Zod schemas provide good type safety and the pagination limit of 50 is reasonable for performance.


58-90: Efficient parallel queries with smart pagination check.

Good use of Promise.all for concurrent execution and the LIMIT+1 technique for checking if more results exist.


97-124: Clean data transformation with proper null handling.

Good use of filter(Boolean) to ensure only valid permissions are processed. The response structure properly matches the defined schema.

apps/dashboard/app/(app)/settings/root-keys-v2/components/table/components/skeletons.tsx (1)

1-66: Well-structured skeleton components with consistent styling.

Clean implementation of skeleton loaders that match the actual table columns. Good use of the animate-pulse class for loading indication.

apps/dashboard/app/(app)/settings/root-keys-v2/filters.schema.ts (2)

41-43: Excellent defensive programming with runtime validation.

Good practice to validate the configuration at runtime to catch potential issues early.


18-37: Well-structured filter configuration with clear field definitions.

The configuration is comprehensive and the comments help clarify the purpose of each field. The consistent operator set across fields maintains a good user experience.

@vercel vercel bot temporarily deployed to Preview – engineering June 25, 2025 13:51 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard June 25, 2025 13:53 Inactive
@perkinsjr perkinsjr self-assigned this Jun 25, 2025
@ogzhanolguncu ogzhanolguncu enabled auto-merge June 25, 2025 14:10
@ogzhanolguncu ogzhanolguncu added this pull request to the merge queue Jun 25, 2025
Merged via the queue into main with commit 73e7b92 Jun 25, 2025
31 checks passed
@ogzhanolguncu ogzhanolguncu deleted the root-keys-table branch June 25, 2025 14:13
github-merge-queue bot pushed a commit that referenced this pull request Jun 25, 2025
* feat: add trpc and filters schema for root keys

* refactor: get rid of extra round trip and simplify query

* feat: add root keys table

* feat: add filters

* fix: nitpick

* fix: coderabbit issues

* fix: typos and coderabbit issues

---------

Co-authored-by: James P <james@unkey.dev>
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.

2 participants