Skip to content

chore: copy button with doc#3261

Merged
ogzhanolguncu merged 2 commits intomainfrom
move-copy-button-to-ui
May 16, 2025
Merged

chore: copy button with doc#3261
ogzhanolguncu merged 2 commits intomainfrom
move-copy-button-to-ui

Conversation

@MichaelUnkey
Copy link
Collaborator

@MichaelUnkey MichaelUnkey commented May 14, 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?

Dashboard CopyButtons still function as expected
Eng Doc makes sense

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

  • Documentation
    • Added new documentation and usage examples for the CopyButton component, including accessibility and behavior details.
  • Refactor
    • Consolidated the import of the CopyButton component across the app to use a single external UI library source instead of local paths.
  • New Features
    • Made the CopyButton component publicly available through the central UI library export.

@changeset-bot
Copy link

changeset-bot bot commented May 14, 2025

⚠️ No Changeset found

Latest commit: 960408a

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 May 14, 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 May 16, 2025 9:40am
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2025 9:40am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 14, 2025

📝 Walkthrough

Walkthrough

The changes update all usages of the CopyButton component throughout the codebase to import it from the @unkey/ui package instead of local paths. Documentation and example files for CopyButton are added, and the component is re-exported via the UI library's index. No functional or behavioral changes are made to the application logic.

Changes

Files/Paths (grouped) Change Summary
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/secret-key.tsx
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/page.tsx
apps/dashboard/app/(app)/authorization/roles/[roleId]/tree.tsx
apps/dashboard/app/(app)/identities/[identityId]/page.tsx
apps/dashboard/app/(app)/ratelimits/_components/ratelimit-client.tsx
apps/dashboard/app/(app)/settings/root-keys/new/client.tsx
apps/dashboard/app/(app)/settings/workspace-navbar.tsx
apps/dashboard/app/new/create-ratelimit.tsx
apps/dashboard/app/new/keys.tsx
apps/dashboard/components/navigation/copyable-id-button.tsx
Changed import source of CopyButton from local paths to @unkey/ui package; no logic or behavioral changes.
apps/engineering/content/design/components/button.mdx Removed import and usage of ButtonWithKeyboardShortcut.
apps/engineering/content/design/components/buttons/copy-button.examples.tsx Added new example component Default demonstrating CopyButton usage from @unkey/ui.
apps/engineering/content/design/components/copy-button.mdx Added new documentation file for CopyButton component, including overview, props, usage, accessibility, and behavior details.
internal/ui/src/components/copy-button.tsx Changed import path for cn utility from absolute to relative.
internal/ui/src/index.ts Added export for ./components/copy-button to re-export CopyButton via the UI library index.

Sequence Diagram(s)

sequenceDiagram
    participant AppComponent
    participant @unkey/ui.CopyButton
    participant Clipboard

    AppComponent->>@unkey/ui.CopyButton: Render with value to copy
    AppComponent->>@unkey/ui.CopyButton: User clicks button
    @unkey/ui.CopyButton->>Clipboard: Copy value to clipboard
    @unkey/ui.CopyButton-->>AppComponent: Show feedback (icon change)
    Note right of @unkey/ui.CopyButton: Icon resets after 2 seconds
Loading

Possibly related PRs

  • unkeyed/unkey#2652: Refactors and improves the internal implementation and state management of the CopyButton component, which is directly related to the consolidation of its imports in this PR.

Suggested labels

🕹️ oss.gg, hacktoberfest

Suggested reviewers

  • perkinsjr
  • mcstepp
  • chronark
  • ogzhanolguncu

Tip

⚡️ Free AI Code Reviews for VS Code, Cursor, Windsurf
  • CodeRabbit now supports VS Code, Cursor and Windsurf. This brings free AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Learn more

[!ANNOUNCEMENT]

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ 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 May 14, 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: 0

🧹 Nitpick comments (2)
apps/engineering/content/design/components/copy-button.mdx (2)

9-16: Feature list could include analytics tracking.

Consider adding an item such as:

  • Analytics tracking via the optional src prop
    This highlights the purpose of src for telemetry.

31-38: Behavior documentation is thorough.

Steps cover copy action, icon state transitions, and event suppression. Optionally, note that providing src will emit an analytics event if implemented.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1df84be and 6920381.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (17)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/secret-key.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/page.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/roles/[roleId]/tree.tsx (1 hunks)
  • apps/dashboard/app/(app)/identities/[identityId]/page.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/_components/ratelimit-client.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys/new/client.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/workspace-navbar.tsx (1 hunks)
  • apps/dashboard/app/new/create-ratelimit.tsx (1 hunks)
  • apps/dashboard/app/new/keys.tsx (1 hunks)
  • apps/dashboard/components/navigation/copyable-id-button.tsx (1 hunks)
  • apps/engineering/content/design/components/button.mdx (0 hunks)
  • apps/engineering/content/design/components/buttons/copy-button.examples.tsx (1 hunks)
  • apps/engineering/content/design/components/copy-button.mdx (1 hunks)
  • internal/ui/src/components/copy-button.tsx (1 hunks)
  • internal/ui/src/index.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/engineering/content/design/components/button.mdx
⏰ Context from checks skipped due to timeout of 90000ms (25)
  • GitHub Check: Test Go API Local / Test (Shard 1/8)
  • GitHub Check: Test Go API Local / Test (Shard 6/8)
  • GitHub Check: Test Go API Local / Test (Shard 7/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 8/8)
  • GitHub Check: Test Go API Local / Test (Shard 3/8)
  • GitHub Check: Test Go API Local / Test (Shard 2/8)
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Build / Build
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Packages / Test ./apps/dashboard
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./internal/hash
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (20)
internal/ui/src/components/copy-button.tsx (1)

4-4: Import path updated to use relative path.

The change from an absolute import path to a relative path for the cn utility is appropriate and aligns with the component being exported from the central UI package.

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

6-6: Import source updated to use the centralized UI package.

Good refactoring to import CopyButton from the @unkey/ui package instead of a local path, improving consistency across the codebase.

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

19-19: Import source updated to use the centralized UI package.

Good refactoring to import CopyButton from the @unkey/ui package instead of a local path, maintaining consistency with other UI component imports (like Button on line 20).

apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/secret-key.tsx (1)

5-5: Consolidated imports from the UI package.

Good improvement to import both Button and CopyButton from the @unkey/ui package, creating a more consistent import pattern.

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

6-6: Centralize CopyButton import.
Importing CopyButton from @unkey/ui correctly replaces the local component path and aligns with the updated UI library. All <CopyButton> usages in this file will now resolve.

apps/dashboard/app/(app)/settings/workspace-navbar.tsx (1)

7-7: Switch CopyButton to the shared UI package.
The CopyButton is now imported alongside Button from @unkey/ui, matching the refactor pattern across dashboard files. The <CopyButton> in the workspace navbar will function as expected.

apps/dashboard/app/new/keys.tsx (1)

17-17: Consolidate imports from @unkey/ui.
Combining Button, CopyButton, and Empty into a single import from @unkey/ui simplifies the import statements and ensures consistent usage of the shared UI components.

apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx (1)

8-8: Standardize CopyButton import path.
Replacing the local CopyButton import with the shared export from @unkey/ui centralizes the component reference. All instances of <CopyButton> in this dialog will now resolve properly.

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

2-2: Expose CopyButton via library index.
Adding export * from "./components/copy-button"; makes the CopyButton component publicly available through @unkey/ui, enabling the import changes in the dashboard to function.

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

6-6: LGTM: Import centralization looks good

Successfully updated the import path to use the centralized CopyButton from @unkey/ui instead of a local path. This aligns with the PR objective of maintaining CopyButton functionality while improving engineering documentation.

apps/dashboard/app/(app)/ratelimits/_components/ratelimit-client.tsx (1)

3-3: LGTM: Import consolidation looks good

Successfully consolidated the CopyButton import along with other UI components from @unkey/ui. This provides better consistency in component sourcing.

apps/dashboard/app/new/create-ratelimit.tsx (1)

6-6: LGTM: Import path update is correct

The import has been properly updated to source CopyButton from the centralized UI package alongside Button. This maintains consistency with other files in the codebase.

apps/dashboard/components/navigation/copyable-id-button.tsx (1)

1-1: LGTM: Import path correctly updated

Successfully updated the import to source both Button and CopyButton from the centralized @unkey/ui package. The component functionality remains unchanged.

apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx (1)

3-10: Import consolidation to @unkey/ui looks good.

All UI components, including CopyButton, are now consistently sourced from @unkey/ui, which aligns with the rest of the codebase and removes the prior split import pattern.

apps/engineering/content/design/components/buttons/copy-button.examples.tsx (2)

1-2: Verify example imports.

The imports for RenderComponentWithSnippet and CopyButton are correct. Please confirm that the alias @/app/components/render resolves properly in the docs build.


3-19: Example component demonstrates correct usage.

The Default example cleanly showcases both basic and styled uses of CopyButton, including src and className props. The snippet is clear, focused, and ready for documentation.

apps/engineering/content/design/components/copy-button.mdx (4)

1-4: Frontmatter is well-formed.

The MDX frontmatter including title and summary is correctly specified and aligns with repository conventions.


5-5: Import of Default example is correct.

The relative path ./buttons/copy-button.examples matches the file structure and will load the example component as intended.


18-24: Props table is comprehensive.

All props (value, src, className) are documented with correct types and descriptions, matching the component API.


27-28: Usage section is clear.

Embedding <Default /> effectively demonstrates component incorporation; no further changes needed here.

@ogzhanolguncu ogzhanolguncu added this pull request to the merge queue May 16, 2025
Merged via the queue into main with commit 7e95903 May 16, 2025
30 of 37 checks passed
@ogzhanolguncu ogzhanolguncu deleted the move-copy-button-to-ui branch May 16, 2025 10:26
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