Skip to content

feat: updated api settings page#3072

Merged
MichaelUnkey merged 53 commits intomainfrom
new-ratelimit-settings-page
Apr 25, 2025
Merged

feat: updated api settings page#3072
MichaelUnkey merged 53 commits intomainfrom
new-ratelimit-settings-page

Conversation

@MichaelUnkey
Copy link
Collaborator

@MichaelUnkey MichaelUnkey commented Apr 2, 2025

What does this PR do?

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?

  • Test A
  • Test B

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 API settings page with a streamlined layout for managing API details, default settings, IP whitelisting, and deletion controls.
    • Added animated shiny text effects and new status badges for enhanced visual feedback.
    • Expanded icon library with new icons for improved UI clarity.
  • Enhancements

    • Improved settings card layout and styling for better readability and responsiveness.
    • Updated color categorization for log status indicators.
  • Bug Fixes

    • Sidebar now refreshes automatically when switching workspaces.
  • Refactor

    • Consolidated multiple API settings components into a single, cohesive settings client for easier management and navigation.
  • Chores

    • Minor formatting improvements and code cleanup.

@vercel
Copy link

vercel bot commented Apr 2, 2025

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

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 6 resolved Apr 24, 2025 7:01pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 7:01pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 7:01pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 7:01pm

@changeset-bot
Copy link

changeset-bot bot commented Apr 2, 2025

⚠️ No Changeset found

Latest commit: 620467d

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
Contributor

coderabbitai bot commented Apr 2, 2025

📝 Walkthrough

Walkthrough

This change set introduces a major refactor and feature expansion for the API settings page in the dashboard application. Several new React components are added for managing API settings, including API name updates, API ID copying, default configuration, IP whitelist management, delete protection, and deletion. The settings UI is consolidated into a single SettingsClient component, which replaces the previous granular component usage in the settings page. Supporting UI enhancements include a new animated shiny text effect, a status badge component, and additional icons. Tailwind CSS configuration is updated to support the new shiny text animation. Several icons are also added to the icon library. Obsolete or replaced component files are removed accordingly.

Changes

File(s) / Path(s) Change Summary
apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx, .../default-bytes.tsx, .../default-prefix.tsx, .../delete-api.tsx, .../delete-protection.tsx, .../settings-client.tsx, .../status-badge.tsx, .../update-api-name.tsx, .../update-ip-whitelist.tsx New or refactored React components for API settings: copying API ID, updating default bytes/prefix, delete protection, deletion, updating API name, and IP whitelist management.
apps/dashboard/app/(app)/apis/[apiId]/settings/page.tsx Replaces multiple granular settings components with a single SettingsClient component, simplifying the page structure.
apps/dashboard/components/settings-card.tsx Updates SettingCardProps to allow React nodes for the title and refines layout and typography.
apps/dashboard/components/ui/shiny-text.tsx Adds AnimatedShinyText component for shiny text effects.
apps/dashboard/tailwind.config.js Adds shiny-text keyframe animation and animation utility to Tailwind CSS config.
apps/dashboard/app/(app)/logs/components/controls/components/logs-queries/utils.ts Refactors status color logic to use startsWith for broader status code matching.
apps/dashboard/components/navigation/sidebar/app-sidebar/index.tsx Adds router refresh on workspace ID change using useEffect and useRouter.
apps/engineering/content/design/icons.mdx Adds multiple new icon components and usage examples; minor formatting improvements.
internal/icons/src/icons/adjust-contrast-3.tsx, .../arrow-up-right.tsx, .../input-password-edit.tsx, .../input-password-settings.tsx, .../lock.tsx, .../number-input.tsx, .../shield.tsx, .../shield-alert.tsx, .../text-input.tsx Adds new icon components to the internal icon library.
internal/icons/src/index.ts Exports new icons from the icon library.
internal/ui/src/components/button.tsx Adds a blank line for formatting; no functional changes.
apps/dashboard/app/(app)/apis/[apiId]/settings/delete-api.tsx, .../delete-protection.tsx, .../update-api-name.tsx, .../update-ip-whitelist.tsx Removes old API settings components, replaced by new versions in the components directory.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SettingsClient
    participant SubComponent as [Settings Subcomponents]
    participant API

    User->>SettingsClient: Visit API Settings Page
    SettingsClient->>SubComponent: Render settings sections (API name, ID, defaults, IP whitelist, delete protection, delete)
    User->>SubComponent: Interact with forms/buttons (e.g., update name, copy ID, toggle protection)
    SubComponent->>API: Submit changes via mutation (e.g., update, delete, toggle)
    API-->>SubComponent: Respond with success/error
    SubComponent-->>User: Show toast/feedback, refresh UI as needed
Loading

Suggested labels

Feature, Dashboard

Suggested reviewers

  • perkinsjr
  • mcstepp
  • chronark

📜 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 b237242 and 620467d.

📒 Files selected for processing (1)
  • internal/ui/src/components/button.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/ui/src/components/button.tsx
⏰ Context from checks skipped due to timeout of 90000ms (18)
  • GitHub Check: Test Go API Local / Test (Shard 8/8)
  • GitHub Check: Test Go API Local / Test (Shard 7/8)
  • GitHub Check: Test Go API Local / Test (Shard 6/8)
  • GitHub Check: Test Go API Local / Test (Shard 5/8)
  • GitHub Check: Test Go API Local / Test (Shard 4/8)
  • GitHub Check: Test Go API Local / Test (Shard 3/8)
  • GitHub Check: Test Go API Local / Test (Shard 2/8)
  • GitHub Check: Test Go API Local / Test (Shard 1/8)
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Build / Build
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Analyze (javascript-typescript)
✨ 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.
    • 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 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
Contributor

github-actions bot commented Apr 2, 2025

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

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 (4)
apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx (4)

74-74: Remove console.error in production code.

The error logging to the console should be handled through a proper logging service rather than using console.error in production code.

- console.error(err);
+ // Use a proper logging service or remove this line

116-117: Improve button width for better responsiveness.

The current button width is very large on mobile (24rem) and much smaller on desktop (8rem), which seems counterintuitive since mobile screens are typically smaller.

- className="rounded-lg justify-end items-end px-3 text-error-9 font-medium text-[13px] leading-6 w-[24rem] lg:w-[8rem]"
+ className="rounded-lg justify-end items-end px-3 text-error-9 font-medium text-[13px] leading-6 w-full sm:w-[12rem] lg:w-[8rem]"

128-128: Fix typo in className.

There's a typo in the className where there's no space between items-center and w-full.

- <div className="flex flex-row justify-between w-full h-16 px-6 py-4 items-centerw-full">
+ <div className="flex flex-row justify-between w-full h-16 px-6 py-4 items-center w-full">

181-196: Consider using a more semantic color for the delete button.

While using error-9 for the delete button color is appropriate, consider defining a specific semantic color for destructive actions in your design system for better consistency across the application.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cbfd8a6 and 84a71c8.

📒 Files selected for processing (10)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-prefix.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-ip-whitelist.tsx (1 hunks)
  • apps/dashboard/components/navigation/sidebar/app-sidebar/index.tsx (2 hunks)
  • apps/dashboard/components/settings-card.tsx (2 hunks)
  • internal/icons/src/index.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-prefix.tsx
  • apps/dashboard/components/settings-card.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-ip-whitelist.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx
  • internal/icons/src/index.ts
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx (6)
apps/dashboard/lib/trpc/routers/index.ts (1)
  • router (84-216)
apps/dashboard/lib/trpc/routers/api/delete.ts (1)
  • deleteApi (7-117)
apps/dashboard/components/settings-card.tsx (1)
  • SettingCard (12-51)
apps/dashboard/app/(app)/apis/[apiId]/settings/components/status-badge.tsx (1)
  • StatusBadge (28-35)
internal/icons/src/icons/lock.tsx (1)
  • Lock (15-61)
internal/icons/src/icons/xmark.tsx (1)
  • XMark (15-42)
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: Test Go API Local / Test (Shard 8/8)
  • GitHub Check: Test Go API Local / Test (Shard 7/8)
  • GitHub Check: Test Go API Local / Test (Shard 4/8)
  • GitHub Check: Test Go API Local / Test (Shard 3/8)
  • GitHub Check: Test Go API Local / Test (Shard 6/8)
  • GitHub Check: Test Packages / Test ./apps/dashboard
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Go API Local / Test (Shard 5/8)
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Go API Local / Test (Shard 2/8)
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Go API Local / Test (Shard 1/8)
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Build / Build
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: autofix
🔇 Additional comments (7)
apps/dashboard/components/navigation/sidebar/app-sidebar/index.tsx (3)

20-21: Appropriate import updates.

The import statements have been properly updated to include useRouter from next/navigation and useEffect from React, which are necessary for the new workspace change detection functionality.


33-33: LGTM!

Properly initializing the router using the Next.js useRouter hook.


35-42:

Details

✅ Verification successful

Consider a more targeted refresh approach.

While the implementation correctly refreshes the sidebar when the workspace changes, the comment on line 40 mentions using "a more targeted approach" but still uses the generic router.refresh(). This might cause unnecessary re-renders of other components.

Consider investigating if a more granular refresh method is available that would only update the sidebar components affected by workspace changes, rather than triggering a full router refresh. This would be especially beneficial for performance in larger applications.


🏁 Script executed:

#!/bin/bash
# Check if there are any custom hooks or context providers that might offer more targeted refresh
rg -A 3 -B 3 "createContext|useContext|refresh" --glob "*.tsx" apps/dashboard/

Length of output: 61660


No granular refresh available — retaining router.refresh()

I searched the dashboard code for any existing hook or context that would allow a sidebar‑only update and found none. As it stands, router.refresh() is the only mechanism to re-fetch/sidebar state when the workspace changes.

– File: apps/dashboard/components/navigation/sidebar/app-sidebar/index.tsx
– Lines: 35–42

apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx (4)

46-84: Well-implemented deletion confirmation flow.

The component correctly implements a robust deletion confirmation process with appropriate validations:

  1. Requires the user to type the exact API name
  2. Requires confirming intent by typing a dynamically generated message that includes the number of keys
  3. Disables the button until both validations pass
  4. Handles API deletion through a proper mutation with success/error handling
  5. Redirects to the API listing page after successful deletion

The approach ensures users are fully aware of the consequences before proceeding with deletion.


90-109: Good use of the SettingCard component with proper UX indicators.

The implementation effectively uses SettingCard to maintain consistency with other settings components and provides clear visual indication when delete protection is enabled through the Lock badge. The description accurately explains the delete protection feature's purpose.


124-199: Well-structured confirmation dialog with clear warnings.

The confirmation dialog is well-structured with:

  1. Clear title and closing mechanism
  2. Detailed warning about the consequences of deletion
  3. Two separate validation inputs with clear instructions
  4. Disabled submit button until validations pass
  5. Loading state during submission
  6. Final warning about the permanent nature of the action

This multi-step confirmation process helps prevent accidental deletions while providing clear feedback to users.


49-50: Good use of dynamic confirmation text.

The dynamic generation of the confirmation intent string based on the number of keys is well implemented with proper singular/plural handling.

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.

clicking on the background during this dialog does not close it, I don't know why but it works in main

CleanShot 2025-04-23 at 08 59 07@2x

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)
internal/ui/src/components/button.tsx (1)

153-153: Fix incorrect comment for the info variant section.

The comment incorrectly identifies the following section as "Success" when it should be "Info" since it defines the info variant styles.

-      // Success
+      // Info
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between da2d376 and 1e51864.

📒 Files selected for processing (12)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-prefix.tsx (3 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/settings-client.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-ip-whitelist.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/update-api-name.tsx (0 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/update-ip-whitelist.tsx (0 hunks)
  • internal/ui/src/components/button.tsx (2 hunks)
💤 Files with no reviewable changes (2)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/update-api-name.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/update-ip-whitelist.tsx
🚧 Files skipped from review as they are similar to previous changes (9)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/page.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/settings-client.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-prefix.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-ip-whitelist.tsx
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Test Go API Local / Test (Shard 1/8)
  • GitHub Check: Test Go API Local / Test (Shard 8/8)
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Build / Build
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: Docs
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
internal/ui/src/components/button.tsx (1)

42-42: LGTM on adding the info color variant.

Good addition of the "info" color variant which follows the pattern of existing color variants. This enhances the button component's flexibility for the API settings page update.

MichaelUnkey and others added 2 commits April 23, 2025 14:03
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

Something broke I think, I'm pretty sure the delete api button was disabled before when protection is on, but now it's not the case anymore

CleanShot 2025-04-24 at 07 28 17@2x

The check in tRPC still catches it but, this is a regression I think?
https://share.cleanshot.com/GYtt3n0V

@chronark
Copy link
Collaborator

yeah this worked in the past
CleanShot 2025-04-24 at 07 31 25@2x

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