Skip to content

fix: Key settings is missing from keys/keyAuthId/keyId#4093

Merged
perkinsjr merged 5 commits intomainfrom
key-settings-is-missing
Oct 10, 2025
Merged

fix: Key settings is missing from keys/keyAuthId/keyId#4093
perkinsjr merged 5 commits intomainfrom
key-settings-is-missing

Conversation

@perkinsjr
Copy link
Member

What does this PR do?

Puts the Settings button back on the Key specific page.
Screenshot 2025-10-10 at 13 40 07

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?

  • Go to API select Keys, click on a key ID and make sure Settings shows up in the top corner alongside the KeyId

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

@changeset-bot
Copy link

changeset-bot bot commented Oct 10, 2025

⚠️ No Changeset found

Latest commit: c4bdde9

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 Oct 10, 2025

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

Project Deployment Preview Comments Updated (UTC)
dashboard Ready Ready Preview Comment Oct 10, 2025 6:01pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
engineering Ignored Ignored Preview Oct 10, 2025 6:01pm

@github-actions
Copy link
Contributor

github-actions bot commented Oct 10, 2025

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

📝 Walkthrough

Walkthrough

Adds a new KeySettingsDialog React component and updates the API ID navbar to fetch key data via TRPC and conditionally render key settings, copy ID, or key-creation UI based on key context and fetched keyData.

Changes

Cohort / File(s) Summary
New KeySettingsDialog component
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/key-settings-dialog.tsx
Adds KeySettingsDialog and KeySettingsDialogProps { keyData: KeyDetails }. Uses trpc.useUtils() and getKeysTableActionItems(keyData, trpcUtils) to compute action items; renders a TableActionPopover wrapping a NavbarActionButton with a Gear icon labeled "Settings".
Navbar actions logic update
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx
Introduces client-side TRPC fetch for a specific key and conditionally renders: when keyData present show KeySettingsDialog + CopyableIDButton; when key context exists but data missing show a basic Settings button + CopyableIDButton; when no key context fall back to CreateKeyDialog or disabled create button. Adds imports for CopyableIDButton and KeySettingsDialog.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant Navbar as API ID Navbar
  participant TRPC as TRPC Client
  participant Dialog as KeySettingsDialog
  participant Popover as TableActionPopover

  User->>Navbar: Open API page
  Navbar->>TRPC: fetchKey(keyId)
  alt keyData available
    TRPC-->>Navbar: keyData
    Navbar->>Dialog: render Dialog(keyData)
    Dialog->>Popover: build items via getKeysTableActionItems(keyData, utils)
    Popover-->>User: show Settings actions
  else key context present, no data
    Navbar-->>User: show Settings button + CopyableIDButton
  else no key context
    Navbar-->>User: show CreateKeyDialog or disabled Create button
  end
Loading
sequenceDiagram
  participant Dialog as KeySettingsDialog
  participant Utils as trpc.useUtils()
  participant Actions as getKeysTableActionItems
  participant UI as TableActionPopover / NavbarActionButton

  Dialog->>Utils: obtain TRPC utils
  Dialog->>Actions: compute items(keyData, utils)
  Actions-->>Dialog: return action items[]
  Dialog->>UI: render Popover trigger "Settings" with items
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

Bug

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description includes the required sections for summarizing the change, type of change, testing instructions, and checklist but omits the reference to the issue being fixed (“Fixes #…”) under the description template’s “What does this PR do?” section. Without the explicit issue link, it is harder to track the bug this PR addresses. Please add the missing “Fixes #” line under the “What does this PR do?” header and include any relevant dependency information required by the change.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely describes the main fix by indicating that the key settings feature was missing on the specific key detail path, matching the primary change of restoring the Settings button in that view.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch key-settings-is-missing

📜 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 5418140 and c4bdde9.

📒 Files selected for processing (1)
  • apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx (3)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/key-settings-dialog.tsx (1)
  • KeySettingsDialog (14-26)
apps/dashboard/components/navigation/copyable-id-button.tsx (1)
  • CopyableIDButton (10-91)
apps/dashboard/components/navigation/action-button.tsx (1)
  • NavbarActionButton (33-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Build / Build

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

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

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: 1

🧹 Nitpick comments (1)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/key-settings-dialog.tsx (1)

8-8: Consider simplifying the deeply nested import path.

The import path contains _components/components/table/components/actions, with multiple components segments. While functional, this suggests the directory structure could be flattened or reorganized for better maintainability.

Example improvement (if feasible):

// Current
import { getKeysTableActionItems } from "../keys/[keyAuthId]/_components/components/table/components/actions/keys-table-action.popover.constants";

// Potential alternative
import { getKeysTableActionItems } from "../keys/[keyAuthId]/_components/table-actions/keys-table-action.popover.constants";
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4183a26 and 0f4dac2.

📒 Files selected for processing (2)
  • apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/key-settings-dialog.tsx (1 hunks)
  • apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/key-settings-dialog.tsx (4)
apps/dashboard/lib/trpc/routers/api/keys/query-api-keys/schema.ts (1)
  • KeyDetails (52-52)
apps/dashboard/components/logs/table-action.popover.tsx (1)
  • TableActionPopover (37-156)
apps/dashboard/components/navigation/action-button.tsx (1)
  • NavbarActionButton (33-70)
internal/icons/src/icons/gear.tsx (1)
  • Gear (16-205)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx (3)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/key-settings-dialog.tsx (1)
  • KeySettingsDialog (14-26)
apps/dashboard/components/navigation/copyable-id-button.tsx (1)
  • CopyableIDButton (10-91)
apps/dashboard/components/navigation/action-button.tsx (1)
  • NavbarActionButton (33-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Build / Build
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx (1)

175-202: LGTM: Conditional rendering correctly handles all key states.

The conditional logic properly handles three scenarios:

  1. Key context exists with loaded data → shows KeySettingsDialog
  2. Key context exists but data is loading → shows disabled Settings button
  3. No key context → shows CreateKeyDialog or disabled Create button

The addition of CopyableIDButton in key view modes improves UX.

apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/key-settings-dialog.tsx (1)

14-26: LGTM: Component correctly wires up key settings.

The component properly:

  • Retrieves TRPC utilities for action handlers
  • Generates action items specific to the key
  • Wraps the popover trigger with appropriate styling via NavbarActionButton
  • Uses the Gear icon consistently with the design system

@vercel vercel bot temporarily deployed to Preview – dashboard October 10, 2025 17:55 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: 1

🧹 Nitpick comments (3)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx (3)

109-128: Significant efficiency improvement over previous implementation!

The query now uses server-side filtering with the keyIds parameter and limit: 1, which is much more efficient than the previous approach of fetching 1000 keys and filtering client-side. This addresses the past review concern.

However, consider creating a dedicated trpc.api.keys.get endpoint for better semantics and to avoid the empty string fallbacks required by the .list endpoint signature.


116-119: Empty string fallbacks are a code smell.

Using empty strings to "silence TS errors" is not ideal. While this is safe because the query is guarded by the enabled condition, consider:

  • Restructuring the query parameters to properly handle optional values
  • Using a dedicated endpoint that accepts optional parameters with proper types

134-134: Redundant client-side filtering.

Since the query now filters server-side to return exactly one key (with keyIds filter and limit: 1), the .find() operation is redundant. Consider simplifying to direct array access:

-const specificKey = keyData?.keys.find((key) => key.id === keyId);
+const specificKey = keyData?.keys[0];
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f4dac2 and 5418140.

📒 Files selected for processing (1)
  • apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx (4)
apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/key-settings-dialog.tsx (1)
  • KeySettingsDialog (14-26)
apps/dashboard/components/navigation/copyable-id-button.tsx (1)
  • CopyableIDButton (10-91)
apps/dashboard/components/navigation/action-button.tsx (1)
  • NavbarActionButton (33-70)
internal/icons/src/icons/gear.tsx (1)
  • Gear (16-205)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Build / Build

@vercel vercel bot temporarily deployed to Preview – dashboard October 10, 2025 18:01 Inactive
@mcstepp mcstepp self-assigned this Oct 10, 2025
Copy link
Collaborator

@mcstepp mcstepp left a comment

Choose a reason for hiding this comment

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

👍

tested in preview

@perkinsjr perkinsjr merged commit 25132cb into main Oct 10, 2025
16 of 17 checks passed
@perkinsjr perkinsjr deleted the key-settings-is-missing branch October 10, 2025 18:11
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