Skip to content

chore: Dialog container into UI step 1#3294

Merged
MichaelUnkey merged 10 commits intomainfrom
dialog-container-into-ui
Jun 4, 2025
Merged

chore: Dialog container into UI step 1#3294
MichaelUnkey merged 10 commits intomainfrom
dialog-container-into-ui

Conversation

@MichaelUnkey
Copy link
Collaborator

@MichaelUnkey MichaelUnkey commented Jun 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 new dialog components, including a customizable DialogContainer and a multi-step NavigableDialog with sidebar navigation and enhanced accessibility.
    • Added example components and comprehensive documentation for DialogContainer and NavigableDialog, including usage instructions and accessibility details.
  • Improvements

    • Dialog-related components are now sourced from a shared UI library for consistency and reusability.
  • API Updates

    • The permission creation API now accepts an optional slug field and updates the example value for the name field.

@changeset-bot
Copy link

changeset-bot bot commented Jun 2, 2025

⚠️ No Changeset found

Latest commit: 86f4024

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 Jun 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 💬 Add feedback Jun 4, 2025 0:28am
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2025 0:28am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 2, 2025

📝 Walkthrough

Walkthrough

This set of changes introduces new dialog UI components and documentation into the codebase, migrating internal dashboard usage to a shared UI package. It adds a generic navigable dialog system, updates OpenAPI type definitions for permissions, and enhances the UI package with Radix-based dialog primitives, parts, and documentation examples.

Changes

Files / Groups Change Summary
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/index.tsx
apps/dashboard/app/(app)/apis/_components/create-api-button.tsx
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.constants.tsx
Migrated dialog component imports from local paths to the shared @unkey/ui package.
apps/engineering/content/design/components/dialog-container.mdx
apps/engineering/content/design/components/navigable-dialog.mdx
Added new documentation files for DialogContainer and NavigableDialog components, detailing features, usage, and accessibility.
apps/engineering/content/design/components/dialog/dialog-container.example.tsx
apps/engineering/content/design/components/dialog/navigable-dialog.example.tsx
Added example React components demonstrating usage of DialogContainer and NavigableDialog.
internal/ui/package.json Added @radix-ui/react-dialog as a dependency.
internal/ui/src/components/dialog/dialog-container.tsx Introduced new DialogContainer React component with customizable header, content, and footer.
internal/ui/src/components/dialog/navigable-dialog.tsx Refactored navigable dialog components to arrow functions; added a generic, type-safe navigable dialog system with context-based step navigation and subcomponents.
internal/ui/src/components/dialog/parts/dialog-parts.tsx Added reusable dialog UI parts: header, content area, and footer.
internal/ui/src/components/dialog/parts/dialog.tsx Introduced Radix-based dialog primitives, overlay, content, header, footer, and close warning support.
internal/ui/src/index.ts Exported new dialog components from the UI package.
packages/api/src/openapi.d.ts Updated createPermission request schema: changed name example, added optional slug property with description and example.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant UI_Package as @unkey/ui
    participant DialogContainer
    participant NavigableDialogRoot

    User->>App: Clicks "Open Dialog" button
    App->>UI_Package: Renders DialogContainer or NavigableDialogRoot
    UI_Package->>DialogContainer: Displays modal with header, content, footer
    UI_Package->>NavigableDialogRoot: Displays navigable dialog with sidebar and content panels
    User->>DialogContainer: Inputs, submits, closes dialog
    User->>NavigableDialogRoot: Navigates steps, submits, closes dialog
    DialogContainer-->>App: Calls onOpenChange callback
    NavigableDialogRoot-->>App: Calls onOpenChange callback
Loading

Possibly related PRs

  • feat: keys create wizard #3156: Introduces a multi-step key creation wizard with form components and validation, related to the key creation dialog components modified here.

Suggested labels

Dashboard

Suggested reviewers

  • perkinsjr
  • chronark
  • mcstepp

📜 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 a5b3be5 and 86f4024.

📒 Files selected for processing (3)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.constants.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/index.tsx (1 hunks)
  • internal/ui/src/components/dialog/navigable-dialog.tsx (8 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.constants.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/index.tsx
  • internal/ui/src/components/dialog/navigable-dialog.tsx
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • 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 Go API Local / Test (Shard 8/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 7/8)
  • GitHub Check: Test Go API Local / Test (Shard 6/8)
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Build / Build
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • 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.
    • 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
Contributor

github-actions bot commented Jun 2, 2025

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

@MichaelUnkey MichaelUnkey changed the title Dialog container into UI step 1 Chore: Dialog container into UI step 1 Jun 2, 2025
@MichaelUnkey MichaelUnkey changed the title Chore: Dialog container into UI step 1 chore: Dialog container into UI step 1 Jun 3, 2025
@MichaelUnkey MichaelUnkey marked this pull request as ready for review June 4, 2025 12:00
@MichaelUnkey MichaelUnkey enabled auto-merge June 4, 2025 12:00
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: 5

🧹 Nitpick comments (9)
packages/api/src/openapi.d.ts (1)

1-4: Note: Changes should be made in the OpenAPI source specification.

This file is auto-generated and contains a warning not to make direct changes. Ensure these modifications are reflected in the actual OpenAPI specification source file that generates this TypeScript definition.

apps/engineering/content/design/components/dialog/dialog-container.example.tsx (2)

41-43: Consider using appropriate text color class.

Using text-error-11 for descriptive footer text is semantically incorrect since this isn't an error message.

-                <div className="text-error-11 text-xs">
+                <div className="text-gray-11 text-xs">
                  This is an example of a footer with a button for actions needed to be done
                </div>

12-15: Consider adding input validation to the example.

The submit handler could demonstrate basic validation patterns for a more complete example.

  const handleSubmit = () => {
+    if (!inputValue.trim()) {
+      return; // Could show validation message
+    }
    setInputResult(inputValue);
    setIsOpen(false);
  };
internal/ui/src/components/dialog/dialog-container.tsx (1)

38-42: Consider extracting complex responsive classes for better maintainability.

The responsive className configuration is quite complex and spans multiple lines. Consider extracting this into a separate constant or utility function to improve readability and maintainability.

+const dialogContentClasses = [
+  "drop-shadow-2xl border-gray-4 max-h-[90vh] overflow-y-auto !rounded-2xl p-0 gap-0",
+  "w-[90%] md:w-[70%] lg:w-[70%] xl:w-[50%] 2xl:w-[45%] max-w-[600px]",
+  "max-h-[90vh] sm:max-h-[90vh] md:max-h-[70vh] lg:max-h-[90vh] xl:max-h-[80vh]"
+].join(" ");

 <DialogContent
   className={cn(
-    "drop-shadow-2xl border-gray-4 max-h-[90vh] overflow-y-auto !rounded-2xl p-0 gap-0",
-    "w-[90%] md:w-[70%] lg:w-[70%] xl:w-[50%] 2xl:w-[45%] max-w-[600px] max-h-[90vh] sm:max-h-[90vh] md:max-h-[70vh] lg:max-h-[90vh] xl:max-h-[80vh]",
+    dialogContentClasses,
     className,
   )}
apps/engineering/content/design/components/navigable-dialog.mdx (2)

9-9: Consider using standard spelling for "multi-step".

The static analysis tool suggests "multistep" as the standard spelling.

-- Multi-step navigation with sidebar
+- Multistep navigation with sidebar
🧰 Tools
🪛 LanguageTool

[misspelling] ~9-~9: This word is normally spelled as one.
Context: ...igable-dialog.example"; ## Features - Multi-step navigation with sidebar - Icon support ...

(EN_COMPOUNDS_MULTI_STEP)


87-87: Consider using standard spelling for "auto-focus".

The static analysis tool suggests "autofocus" as the standard spelling.

-| preventAutoFocus | boolean              | true    | Whether to prevent auto-focus on open          |
+| preventAutoFocus | boolean              | true    | Whether to prevent autofocus on open           |
🧰 Tools
🪛 LanguageTool

[misspelling] ~87-~87: This word is normally spelled as one.
Context: ... | true | Whether to prevent auto-focus on open | | children | R...

(EN_COMPOUNDS_AUTO_FOCUS)

apps/engineering/content/design/components/dialog-container.mdx (1)

67-67: Consider using standard spelling for "auto-focus".

The static analysis tool suggests "autofocus" as the standard spelling.

-| preventAutoFocus | boolean                 | true      | Whether to prevent auto-focus on open            |
+| preventAutoFocus | boolean                 | true      | Whether to prevent autofocus on open             |
🧰 Tools
🪛 LanguageTool

[misspelling] ~67-~67: This word is normally spelled as one.
Context: ... | true | Whether to prevent auto-focus on open | | children ...

(EN_COMPOUNDS_AUTO_FOCUS)

internal/ui/src/components/dialog/parts/dialog.tsx (2)

55-56: Consider splitting long class names for readability

The button class names string is quite long. Consider splitting it across multiple lines for better readability.

-    const buttonClassNames =
-      "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent text-muted-foreground z-[51]";
+    const buttonClassNames = cn(
+      "absolute right-4 top-4 rounded-sm opacity-70",
+      "ring-offset-background transition-opacity hover:opacity-100", 
+      "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
+      "disabled:pointer-events-none data-[state=open]:bg-accent",
+      "text-muted-foreground z-[51]"
+    );

76-84: Address the TODO for more robust pointer down checks

The comment indicates that more robust checks might be needed for the pointer down outside handler. This could lead to edge cases where the dialog closes unexpectedly.

Would you like me to help implement a more robust solution or create an issue to track this improvement?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b972f0e and a5b3be5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/index.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/_components/create-api-button.tsx (1 hunks)
  • apps/engineering/content/design/components/dialog-container.mdx (1 hunks)
  • apps/engineering/content/design/components/dialog/dialog-container.example.tsx (1 hunks)
  • apps/engineering/content/design/components/dialog/navigable-dialog.example.tsx (1 hunks)
  • apps/engineering/content/design/components/navigable-dialog.mdx (1 hunks)
  • internal/ui/package.json (1 hunks)
  • internal/ui/src/components/dialog/dialog-container.tsx (1 hunks)
  • internal/ui/src/components/dialog/navigable-dialog.tsx (1 hunks)
  • internal/ui/src/components/dialog/parts/dialog-parts.tsx (1 hunks)
  • internal/ui/src/components/dialog/parts/dialog.tsx (1 hunks)
  • internal/ui/src/index.ts (1 hunks)
  • packages/api/src/openapi.d.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/ui/src/components/dialog/parts/dialog.tsx (1)
apps/dashboard/lib/utils.ts (1)
  • cn (5-7)
🪛 LanguageTool
apps/engineering/content/design/components/dialog-container.mdx

[misspelling] ~67-~67: This word is normally spelled as one.
Context: ... | true | Whether to prevent auto-focus on open | | children ...

(EN_COMPOUNDS_AUTO_FOCUS)

apps/engineering/content/design/components/navigable-dialog.mdx

[misspelling] ~9-~9: This word is normally spelled as one.
Context: ...igable-dialog.example"; ## Features - Multi-step navigation with sidebar - Icon support ...

(EN_COMPOUNDS_MULTI_STEP)


[misspelling] ~87-~87: This word is normally spelled as one.
Context: ... | true | Whether to prevent auto-focus on open | | children | R...

(EN_COMPOUNDS_AUTO_FOCUS)

🔇 Additional comments (14)
packages/api/src/openapi.d.ts (2)

3662-3662: LGTM! Improved example demonstrates human-readable permission names.

The change from a slug-like example to a descriptive name better illustrates the intended usage of the name field for human-readable permission descriptions.


3665-3669: Excellent addition of slug field for unique identifiers.

The new optional slug field provides a clean separation of concerns:

  • name for human-readable descriptions
  • slug for unique technical identifiers
  • Defaults to name if not provided, ensuring backward compatibility

The API design improvement maintains existing functionality while providing better clarity.

internal/ui/package.json (1)

23-23: LGTM - Appropriate dependency for dialog components.

The addition of @radix-ui/react-dialog properly supports the new dialog components being introduced in this package.

apps/dashboard/app/(app)/apis/_components/create-api-button.tsx (1)

19-19:

Details

✅ Verification successful

Clean migration to shared UI package.

The import path change from local component to @unkey/ui maintains the dynamic loading pattern and aligns with the goal of consolidating dialog components.

Let's verify that the DialogContainer export is available in the @unkey/ui package:


🏁 Script executed:

#!/bin/bash
# Verify DialogContainer is exported from @unkey/ui package
rg -A 3 "DialogContainer" internal/ui/src/index.ts

Length of output: 50


Let's search the entire UI package for any definition or export of DialogContainer:


🏁 Script executed:

#!/bin/bash
# Comprehensive search for DialogContainer in UI package
rg -n "DialogContainer" -A 3 internal/ui
rg -n "export.*DialogContainer" -A 3 internal/ui
rg -n "dialog-container" -A 3 internal/ui

Length of output: 1740


DialogContainer export confirmed in shared UI package.

internal/ui/src/components/dialog/dialog-container.tsx defines and exports DialogContainer.
internal/ui/src/index.ts re-exports it, making it available at @unkey/ui.

The dynamic import change to @unkey/ui is correct—no further action needed.

internal/ui/src/index.ts (1)

4-5: Properly exposes new dialog components.

The export statements correctly make the dialog components available as part of the @unkey/ui package's public API, enabling the migration seen in the dashboard files.

internal/ui/src/components/dialog/dialog-container.tsx (2)

24-55: Well-structured component with proper TypeScript patterns.

The DialogContainer implementation follows React best practices with:

  • Proper TypeScript prop definitions
  • Conditional rendering for optional elements
  • Correct event handling for preventAutoFocus
  • Clean composition of dialog parts

57-57: Clean re-export pattern for component composition.

The re-export of dialog subcomponents provides a clean API for consumers who need more granular control over dialog composition.

apps/engineering/content/design/components/dialog/navigable-dialog.example.tsx (3)

18-26: Excellent performance optimization with memoization.

The memoization of TabContent and assignment of displayName follows React best practices for performance and debugging.


29-70: Well-designed constant definitions prevent unnecessary re-renders.

Pre-defining NAV_ITEMS and CONTENT_ITEMS outside the component prevents object recreation on each render, which is an excellent performance optimization.


73-99: Clean component composition and state management.

The example demonstrates proper usage of the NavigableDialog components with straightforward state management and clear component composition.

apps/engineering/content/design/components/navigable-dialog.mdx (1)

1-122: Comprehensive and well-structured documentation.

The documentation provides excellent coverage of the NavigableDialog component with:

  • Clear feature descriptions
  • Detailed component structure explanation
  • Comprehensive prop tables
  • Accessibility considerations
  • Practical usage examples
🧰 Tools
🪛 LanguageTool

[misspelling] ~9-~9: This word is normally spelled as one.
Context: ...igable-dialog.example"; ## Features - Multi-step navigation with sidebar - Icon support ...

(EN_COMPOUNDS_MULTI_STEP)


[misspelling] ~87-~87: This word is normally spelled as one.
Context: ... | true | Whether to prevent auto-focus on open | | children | R...

(EN_COMPOUNDS_AUTO_FOCUS)

apps/engineering/content/design/components/dialog-container.mdx (1)

1-78: Well-crafted documentation with comprehensive coverage.

The DialogContainer documentation effectively covers:

  • Clear feature explanations
  • Component structure breakdown
  • Detailed prop specifications
  • Accessibility considerations
  • Practical usage examples

This provides excellent developer experience for using the component.

🧰 Tools
🪛 LanguageTool

[misspelling] ~67-~67: This word is normally spelled as one.
Context: ... | true | Whether to prevent auto-focus on open | | children ...

(EN_COMPOUNDS_AUTO_FOCUS)

internal/ui/src/components/dialog/parts/dialog-parts.tsx (1)

18-29: Well-structured header component

Good implementation with proper TypeScript types and conditional rendering for the subtitle.

internal/ui/src/components/dialog/navigable-dialog.tsx (1)

234-234:

Details

✅ Verification successful

Verify the scrollbar-hide utility class

The scrollbar-hide class might not be a standard Tailwind CSS utility. Ensure this custom class is defined in your CSS or consider using standard Tailwind utilities.

If not found, you might need to add it to your global CSS or use Tailwind's scrollbar utilities if available.


🏁 Script executed:

#!/bin/bash
# Check if scrollbar-hide is defined in CSS files
rg -A 2 "scrollbar-hide" --type css

Length of output: 424


Confirmed: custom scrollbar-hide utility is defined
The scrollbar-hide class is defined in apps/dashboard/styles/tailwind/tailwind.css, so no changes are needed here.

@MichaelUnkey MichaelUnkey added this pull request to the merge queue Jun 4, 2025
Merged via the queue into main with commit c2d7e75 Jun 4, 2025
33 of 38 checks passed
@MichaelUnkey MichaelUnkey deleted the dialog-container-into-ui branch June 4, 2025 19:29
@coderabbitai coderabbitai bot mentioned this pull request Jul 21, 2025
18 tasks
@coderabbitai coderabbitai bot mentioned this pull request Aug 20, 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.

2 participants