Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard): hydration warnings #2253

Merged
merged 8 commits into from
Oct 7, 2024

Conversation

unrenamed
Copy link
Contributor

@unrenamed unrenamed commented Oct 7, 2024

What does this PR do?

Resolves structural HTML warnings, such as improper nesting of <button> elements and <prev> inside <p>, adjusts the margins for the EmptyPlaceholder.Description component to enhance the UI, fixes an issue with unsupported async/await functionality in client components, and ensures that each child in arrays is assigned a unique "key" prop to prevent rendering errors.

Fixes #2243

⚠️ Important

This PR does not resolve all the warnings mentioned above. There may still be instances where these warnings could arise, especially due to the complexity of the various UI component renderings and business logic combinations that I'm not fully familiar with.

I have addressed the majority of the warnings that I was able to detect during the code analysis and live coding sessions, achieving the initial goal set for this PR.

🎯 The goal

The primary goal of this PR is to bring attention to potential issues that may cause unpredictable behavior during client-side rendering in the future (see #2243 for more details). This should help the repository maintainers determine whether to address these concerns during code reviews or consider enhancing the development and review processes to prevent such warnings from reaching production.

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
    • In development, open each page that renders the components affected by this PR
    • Ensure the are no following warnings in DevTools console on those pages:
      • In HTML, <button> cannot be a descendant of <button>. This will cause a hydration error.
      • In HTML, <pre> cannot be a descendant of <p>. This will cause a hydration error.
      • async/await is not yet supported in Client Components, only Server Components. This error is often caused by accidentally adding 'use client' to a module that was originally written for the server.
      • Each child in an array or iterator should have a unique "key" prop.
    • Ensure the changes made do not produce any unexpected UI/UX bugs

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

Release Notes

  • New Features

    • Enhanced tooltip functionality across various components by implementing the asChild prop, improving interaction and rendering.
    • Improved handling of permission and role dialogs with updated DialogTrigger components for better user experience.
  • Bug Fixes

    • Improved error message formatting in the Stripe success page to enhance clarity for users when sessions or customers are not found.
  • Style

    • Adjusted vertical spacing in the EmptyPlaceholder component for better visual consistency.
  • Chores

    • Removed unused imports to streamline the codebase.

Copy link

changeset-bot bot commented Oct 7, 2024

⚠️ No Changeset found

Latest commit: 8f9305c

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

Copy link

vercel bot commented Oct 7, 2024

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 Oct 7, 2024 7:41pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 7:41pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 7:41pm
workflows ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 7:41pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 7:41pm

Copy link

vercel bot commented Oct 7, 2024

@unrenamed is attempting to deploy a commit to the Unkey Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request primarily involve modifications to the RolesPage and StripeSuccess components within the dashboard application. Key adjustments include updating the TooltipTrigger component to use the asChild prop in the RolesPage, allowing a div to wrap the permission name and CopyButton. Additionally, the error handling in the StripeSuccess function has been enhanced, restructuring messages for clarity when a Stripe session or customer is not found. The overall logic and control flow of both components remain unchanged.

Changes

File Change Summary
apps/dashboard/app/(app)/authorization/permissions/[permissionId]/page.tsx Changed TooltipTrigger to use asChild prop, allowing a div to wrap the content instead of being a direct child.
apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx Restructured error messages for clarity when Stripe session or customer is not found.

Assessment against linked issues

Objective Addressed Explanation
No hydration warnings in development when visiting the dashboard application. (2243) The changes do not address nested button issues that cause hydration warnings.

Possibly related PRs

  • fix: truncate long permission names with ellipses #2071: This PR modifies the RolesPage component in the same file as the main PR, enhancing the user interface by integrating a tooltip feature around the permission name display, which is directly related to the changes made in the main PR regarding the TooltipTrigger component.
  • fix: Workspace Permissions overlaps with their descriptions on smaller windows #2127: This PR addresses visual issues in the Workspace permissions section, which is relevant as it deals with the layout and display of permission names, similar to the changes made in the main PR that enhance the layout structure of the RolesPage component.
  • fix: dashboard icon flickering #2170: This PR includes modifications to the RolesPage component, specifically ensuring that the permissions entity is correctly imported and utilized, which relates to the overall functionality of the RolesPage as discussed in the main PR.

Suggested labels

Good first issue

Suggested reviewers

  • chronark
  • mcstepp
  • perkinsjr

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5d9995d and 8f9305c.

📒 Files selected for processing (2)
  • apps/dashboard/app/(app)/authorization/permissions/[permissionId]/page.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/dashboard/app/(app)/authorization/permissions/[permissionId]/page.tsx
  • apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

Copy link
Contributor

github-actions bot commented Oct 7, 2024

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

🧹 Outside diff range and nitpick comments (11)
apps/dashboard/app/(app)/user-button.tsx (1)

Line range hint 1-92: Overall component structure is solid, with a minor suggestion for accessibility

The UserButton component is well-structured and follows React best practices. The use of the "use client" directive is appropriate for this interactive component. The component handles different user states correctly and uses custom UI components effectively.

To further improve accessibility, consider adding an aria-label to the DropdownMenuTrigger button to provide more context for screen readers.

Here's a suggested minor improvement:

 <DropdownMenuTrigger className="flex items-center justify-between gap-2 p-2 w-full h-12 rounded-[0.625rem] hover:bg-background-subtle hover:cursor-pointer text-content">
+  aria-label="User menu"
   <div className="flex items-center gap-2 whitespace-nowrap overflow-hidden">
     {/* ... existing content ... */}
   </div>
 </DropdownMenuTrigger>

This change will provide better context for users relying on assistive technologies.

apps/dashboard/app/(app)/authorization/roles/[roleId]/delete-role.tsx (1)

71-71: Improved component composition with asChild prop

The addition of the asChild prop to DialogTrigger is a positive change that aligns with the PR objectives. This modification:

  1. Improves the component structure by eliminating an unnecessary wrapper element.
  2. Enhances flexibility in composing the dialog trigger.
  3. Potentially resolves issues related to improper nesting of elements.

This change contributes to addressing the hydration warnings mentioned in the linked issue #2243 by ensuring a more predictable and semantically correct DOM structure.

Consider reviewing other similar component usages throughout the codebase for consistency. This pattern could be applied to other Radix UI components like TooltipTrigger or PopoverTrigger if they're used elsewhere in the application.

apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx (2)

57-66: Improved error message structure. Consider minor enhancement.

The restructuring of the error message for a missing Stripe session significantly improves readability and user experience. The separation of the title and description, along with the use of the Code component for the session ID, makes the message clearer and easier to understand.

Consider adding a brief explanation of what a Stripe session is or why it might be missing. This could help users better understand the context of the error. For example:

 <EmptyPlaceholder.Description>
-  The Stripe session
+  The Stripe session (a temporary checkout session)
 </EmptyPlaceholder.Description>
 <Code>{session_id}</Code>
 <EmptyPlaceholder.Description>
-  you are trying to access does not exist. Please contact 
+  you are trying to access does not exist or has expired. Please contact 
   support@unkey.dev.
 </EmptyPlaceholder.Description>

Line range hint 1-150: Overall improvements align with PR objectives. Consider removing unnecessary type check.

The changes made to the StripeSuccess function successfully address the PR objective of improving error message clarity. The restructured error messages for both Stripe session and customer not found scenarios enhance readability and user experience.

Based on the retrieved learning, TypeScript's type-checking ensures that new_plan only accepts "free", "pro", or undefined values. Therefore, the runtime check in the isUpgradingPlan variable assignment might be redundant. Consider simplifying it:

- const isUpgradingPlan = new_plan && new_plan !== ws.plan && new_plan === "pro";
+ const isUpgradingPlan = new_plan === "pro" && new_plan !== ws.plan;

This change maintains the same logic while relying on TypeScript's type safety, potentially improving code readability.

apps/dashboard/app/(app)/settings/vercel/page.tsx (1)

70-70: Approved: Enhanced error message formatting

The addition of JSON formatting for the error message is a good improvement. It enhances readability and aids in debugging, which aligns with the PR objective of improving error message clarity.

Consider adding a character limit to the error message to prevent potentially large error displays:

-        <Code className="text-left">{JSON.stringify(err, null, 2)}</Code>
+        <Code className="text-left">{JSON.stringify(err, null, 2).slice(0, 500)}{JSON.stringify(err, null, 2).length > 500 ? '...' : ''}</Code>

This change would limit the error message to 500 characters and add an ellipsis if it's truncated, balancing between providing useful information and preventing overly large error displays.

apps/dashboard/app/(app)/settings/root-keys/[keyId]/permissions/permission-manager-card.tsx (2)

Line range hint 72-72: Good addition of key prop, consider using a more unique identifier

Adding the key={action} prop to the PermissionToggle component is a good step towards preventing hydration warnings and improving rendering performance. This change aligns well with the PR objectives.

However, consider using a more unique identifier if available, such as ${category}-${action} or a dedicated id field if one exists. This would ensure uniqueness across all categories, not just within each category.

If a more unique identifier is available, consider updating the key prop:

- key={action}
+ key={`${category}-${action}`}

99-99: Good addition of key props, consider consistent key structure

Adding key={category} and key={action} props to the outer and inner divs in the activePermissions mapping is a significant improvement. This change addresses potential hydration warnings and aligns with the PR objectives.

For consistency with the earlier suggestion, consider using a compound key for the inner div to ensure uniqueness across all categories.

Consider updating the inner div key prop for consistency:

- <div key={action} className="flex items-center gap-8">
+ <div key={`${category}-${action}`} className="flex items-center gap-8">

This change would make the key structure consistent throughout the component and ensure uniqueness across all categories.

Also applies to: 108-108

apps/dashboard/app/(app)/authorization/roles/create-new-role.tsx (1)

98-98: Excellent use of asChild prop to improve component structure

The addition of the asChild prop to the DialogTrigger component is a positive change that aligns well with the PR objectives. This modification:

  1. Helps resolve potential hydration warnings by ensuring consistent DOM structure between server and client rendering.
  2. Improves accessibility by removing unnecessary DOM nesting.
  3. Enhances component composability, following Radix UI best practices.

This change effectively addresses the structural HTML warnings mentioned in the PR objectives and contributes to a more robust component architecture.

Consider reviewing other similar component usages throughout the codebase to ensure consistent application of this pattern, which could further reduce hydration warnings and improve overall application structure.

apps/dashboard/app/(app)/team-switcher.tsx (1)

Line range hint 83-87: Approved: Good use of asChild prop to improve component structure.

The introduction of the asChild prop on the TooltipTrigger component is a positive change. This modification addresses potential hydration warnings by allowing the child span element to act as the trigger, which aligns well with the PR objectives.

To further enhance accessibility, consider adding an aria-label to the span element:

 <TooltipTrigger asChild>
-  <span className="overflow-hidden text-sm font-medium text-ellipsis">
+  <span className="overflow-hidden text-sm font-medium text-ellipsis" aria-label="Current workspace">
     {currentOrg?.name ?? "Personal Workspace"}
   </span>
 </TooltipTrigger>

This addition will provide more context for screen reader users.

apps/dashboard/app/(app)/ratelimits/[namespaceId]/page.tsx (2)

276-279: Consistent UI improvement, but consider refactoring

The addition of the Code component with the snippet and CopyButton in this section maintains consistency with the earlier "Requests" section, which is great for user experience. However, this introduces code duplication.

Consider refactoring this repeated code block into a separate component to improve maintainability. For example:

const EmptyStateCodeSnippet = ({ snippet }: { snippet: string }) => (
  <Code className="flex items-start gap-8 p-4 my-8 text-xs text-left">
    {snippet}
    <CopyButton value={snippet} />
  </Code>
);

Then, you can use this component in both EmptyPlaceholder instances:

<EmptyPlaceholder>
  {/* ... other EmptyPlaceholder content ... */}
  <EmptyStateCodeSnippet snippet={snippet} />
</EmptyPlaceholder>

This refactoring would reduce duplication and make future updates to this UI element easier to manage.


Line range hint 1-379: Summary: Improved empty state UI with consistent code snippets

The changes in this file effectively address the PR objectives by enhancing the empty state UI for both the "Requests" and "Top identifiers" sections. The addition of code snippets with copy functionality provides valuable information to users when there's no data to display, which aligns well with the goal of improving user experience and addressing UI issues.

Key points:

  1. Consistent improvement across both empty state sections.
  2. No changes to core logic or data fetching, maintaining existing functionality.
  3. No new warnings or errors introduced.

While the changes are positive, consider the earlier suggestion to refactor the repeated code snippet into a separate component. This would enhance maintainability and adhere to the DRY (Don't Repeat Yourself) principle, which is particularly important as the codebase grows.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fde83b4 and c2c39e9.

📒 Files selected for processing (16)
  • apps/dashboard/app/(app)/authorization/permissions/[permissionId]/delete-permission.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/permissions/[permissionId]/page.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/permissions/create-new-permission.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/roles/[roleId]/delete-role.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/roles/[roleId]/update-role.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/roles/create-new-role.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/ratelimits/sparkline.tsx (1 hunks)
  • apps/dashboard/app/(app)/semantic-cache/[gatewayId]/analytics/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/billing/plans/button.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx (2 hunks)
  • apps/dashboard/app/(app)/settings/root-keys/[keyId]/permissions/permission-manager-card.tsx (4 hunks)
  • apps/dashboard/app/(app)/settings/vercel/page.tsx (1 hunks)
  • apps/dashboard/app/(app)/team-switcher.tsx (1 hunks)
  • apps/dashboard/app/(app)/user-button.tsx (1 hunks)
  • apps/dashboard/components/dashboard/empty-placeholder.tsx (1 hunks)
🧰 Additional context used
📓 Learnings (1)
apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx (1)
Learnt from: mcstepp
PR: unkeyed/unkey#2120
File: apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx:19-19
Timestamp: 2024-09-20T18:32:21.963Z
Learning: In the `StripeSuccess` function, TypeScript's type-checking of the `new_plan` parameter ensures that only "free", "pro", or undefined values are accepted, so additional runtime validation is not necessary.
🔇 Additional comments (16)
apps/dashboard/app/(app)/ratelimits/sparkline.tsx (1)

15-15: Correct removal of async keyword

The removal of the async keyword from the Sparkline component's function signature is appropriate and beneficial. This change:

  1. Aligns the component with its synchronous nature, as there are no asynchronous operations within it.
  2. Addresses the PR objective of fixing "unsupported async/await functionality in client components".
  3. Helps reduce potential hydration warnings and rendering issues.

The rest of the component's logic remains intact, ensuring that its functionality is preserved while improving its structure.

apps/dashboard/components/dashboard/empty-placeholder.tsx (1)

51-51: Confirm the intended margin reduction for EmptyPlaceholder.Description

The margin-bottom for the description has been reduced from mb-8 to mb-2. This change will decrease the vertical spacing below the description text.

While this modification doesn't directly address hydration warnings (the main focus of the PR), it does align with the PR objective of adjusting margins to improve the user interface. However, it's important to ensure that this change doesn't negatively impact the overall layout or readability of the dashboard.

To verify the impact of this change:

  1. Please provide before and after screenshots of the EmptyPlaceholder component in various contexts where it's used.
  2. Confirm that this margin adjustment is intentional and not an accidental modification.

Consider adding a comment explaining the reason for this specific margin value, which could help prevent unintended changes in the future.

apps/dashboard/app/(app)/user-button.tsx (1)

Line range hint 38-43: Improved component structure with asChild prop

The changes to the TooltipTrigger component are well-implemented and address the PR objectives. By using the asChild prop, you've improved the HTML structure and potentially resolved hydration warnings related to improper nesting.

This modification allows the TooltipTrigger to render its child span element directly, which can lead to a more predictable DOM structure during client-side rendering. This aligns well with the goal of preventing hydration mismatches between server and client rendering.

apps/dashboard/app/(app)/settings/billing/plans/button.tsx (1)

63-63: Approved: Good use of asChild to address nesting issues.

The addition of the asChild prop to the DialogTrigger component is a positive change that aligns with the PR objectives. It helps address the improper nesting of <button> elements and potentially resolves hydration warnings.

Please verify the following:

  1. Ensure that the disabled prop on DialogTrigger still functions correctly when used with asChild.
  2. Test the component thoroughly to confirm that this change doesn't introduce any new UI/UX issues.

To assist with verification, you can run the following script:

This will help identify other instances of DialogTrigger that might benefit from the asChild prop, ensuring consistency across the codebase.

apps/dashboard/app/(app)/authorization/permissions/[permissionId]/delete-permission.tsx (1)

70-70: Approved: Improved DialogTrigger implementation

The addition of the asChild prop to DialogTrigger is a positive change. This modification allows the trigger element to be rendered directly without an additional wrapper, which can help resolve potential HTML structure warnings and improve overall component composition.

This change:

  1. Enhances flexibility in styling and behavior of the trigger element.
  2. Aligns with Radix UI best practices.
  3. Contributes to addressing the hydration warnings mentioned in the PR objectives.

The core functionality of the DeletePermission component remains intact, making this a safe and beneficial improvement.

apps/dashboard/app/(app)/authorization/permissions/create-new-permission.tsx (1)

78-78: Approved: Addition of asChild prop resolves potential button nesting issues.

The addition of the asChild prop to DialogTrigger is a good solution to address the improper nesting of <button> elements, which aligns with the PR objectives and helps resolve hydration warnings.

To ensure this change doesn't introduce any accessibility issues, please verify that the trigger prop passed to CreateNewPermission is always an interactive element (e.g., a button or anchor tag). You can use the following script to check the usage of CreateNewPermission:

This script will help identify any instances where CreateNewPermission might be used with a non-interactive trigger element.

✅ Verification successful

Verified: All usages of CreateNewPermission utilize interactive elements for the trigger prop.

The addition of the asChild prop to DialogTrigger has been correctly implemented, ensuring accessibility and preventing hydration warnings without introducing any issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of CreateNewPermission component

# Search for CreateNewPermission usage
echo "Searching for CreateNewPermission usage:"
rg --type typescript --type typescriptreact 'CreateNewPermission' -C 3

# Search for potential non-interactive triggers
echo "\nChecking for potential non-interactive triggers:"
rg --type typescript --type typescriptreact 'CreateNewPermission.*trigger=\{[^}]*<div' -C 3
rg --type typescript --type typescriptreact 'CreateNewPermission.*trigger=\{[^}]*<span' -C 3

Length of output: 566


Script:

#!/bin/bash
# Description: Check usage of CreateNewPermission component

# Search for CreateNewPermission usage in .ts and .tsx files
echo "Searching for CreateNewPermission usage in .ts and .tsx files:"
rg 'CreateNewPermission' -g '*.ts' -g '*.tsx' -C 3

# Search for potential non-interactive triggers in .ts and .tsx files
echo -e "\nChecking for potential non-interactive triggers in .ts and .tsx files:"
rg 'CreateNewPermission.*trigger=\{[^}]*<div' -g '*.ts' -g '*.tsx' -C 3
rg 'CreateNewPermission.*trigger=\{[^}]*<span' -g '*.ts' -g '*.tsx' -C 3

Length of output: 5280

apps/dashboard/app/(app)/authorization/roles/[roleId]/update-role.tsx (1)

77-77: Approved: Improved DialogTrigger rendering

The addition of the asChild prop to the DialogTrigger component is a positive change. This modification allows the trigger content to be rendered directly as a child of DialogTrigger without an additional wrapping element.

This change aligns well with the PR objectives of addressing structural HTML warnings and improving component rendering. It may help resolve issues related to improper nesting of elements, which was mentioned in the linked issue #2243.

The functionality of the DialogTrigger remains intact, and this change follows modern React patterns and best practices for using Radix UI components.

apps/dashboard/app/(app)/settings/vercel/page.tsx (1)

Line range hint 1-146: Overall assessment: Positive improvement

The change in this file successfully addresses one of the PR objectives by improving error message clarity. The modification is minimal yet impactful, enhancing the developer experience without introducing new issues or altering the core functionality of the component.

The rest of the file, including the logic for fetching workspace data, handling integrations, and processing Vercel projects, remains intact. This ensures that the existing functionality is preserved while the error handling is improved.

apps/dashboard/app/(app)/authorization/permissions/[permissionId]/page.tsx (1)

87-90: Improved tooltip structure and layout

The changes to the TooltipTrigger component are well-implemented and address several important aspects:

  1. The use of the asChild prop on TooltipTrigger allows for more flexible rendering of its children, which can help resolve potential hydration issues.
  2. Wrapping the content in a div with flex layout improves the structure and alignment of the tooltip content.
  3. The truncate class on the permission name ensures that long names are displayed properly without breaking the layout.
  4. Wrapping the CopyButton in a div provides better control over its positioning within the layout.

These changes align well with the PR objectives of addressing structural HTML warnings and improving component structure. They should contribute to resolving hydration issues and enhancing the overall stability of the application.

apps/dashboard/app/(app)/settings/root-keys/[keyId]/permissions/permission-manager-card.tsx (3)

15-15: LGTM: Import changes improve code cleanliness

The addition of the Check import and removal of the unused Pencil import enhance code cleanliness. This change aligns with best practices for maintaining a clean and efficient codebase.


65-65: Excellent: Added key prop to improve list rendering

Adding the key={category} prop to the outer div in the mapping of props.permissionsStructure is a crucial improvement. This change helps React's reconciliation process and can prevent hydration warnings related to list rendering. It's an important step in addressing the issues mentioned in the PR objectives.


Line range hint 1-132: Overall: Good progress on addressing hydration warnings

The changes made in this file are a significant step towards addressing the hydration warnings mentioned in the PR objectives. The addition of key props to mapped elements in various parts of the PermissionManagerCard component will help prevent rendering issues and improve React's reconciliation process.

Key improvements:

  1. Added key props to all mapped elements.
  2. Removed unused imports, improving code cleanliness.

While these changes are positive, consider the suggestions for using more unique and consistent key structures throughout the component. This would further enhance the robustness of the rendering process.

No major issues were identified, and the changes align well with the PR objectives. Great job on improving the component structure and addressing potential hydration warnings!

apps/dashboard/app/(app)/semantic-cache/[gatewayId]/analytics/page.tsx (3)

9-9: Improved import specificity

The change to import only getSemanticCachesDaily and getSemanticCachesHourly is a good optimization. It aligns with the PR objectives by potentially reducing unnecessary code and improving performance.


220-223: Enhanced code snippet presentation

The changes to the Code component within EmptyPlaceholder improve the layout and readability of the code snippet. The added gap between the snippet and the copy button enhances usability. These modifications align with the PR objectives by improving the user interface.


Line range hint 1-243: Overall improvements to code organization and UI

The changes in this file effectively address the PR objectives by:

  1. Streamlining imports to focus on necessary functions, potentially improving performance.
  2. Enhancing the user interface for the code snippet display.

These modifications contribute to resolving hydration warnings and improve the overall code quality and user experience. No new issues or potential problems were introduced.

apps/dashboard/app/(app)/ratelimits/[namespaceId]/page.tsx (1)

232-235: Improved UI with code snippet and copy functionality

The addition of the Code component with the snippet and CopyButton enhances the user experience when there's no usage data. This change provides valuable information to users and allows for easy copying of the sample curl command, which aligns well with the PR objectives of improving the UI and addressing structural warnings.

@unrenamed
Copy link
Contributor Author

f2fcbd6 adjusts margin for <EmptyPlaceholder.Description />. Ideally, a common component like this shouldn't include styles, such as margins, that might vary based on its placement in the UI.

While refactoring this wasn't the focus of this PR, I had to reduce the margin to fix the UI after addressing the warnings. From my perspective, the updated UI now looks more consistent.

It’s something to review carefully, as it may influence layout in other parts of the application where this component is used.

@perkinsjr perkinsjr added this pull request to the merge queue Oct 7, 2024
Merged via the queue into unkeyed:main with commit 34c3ea0 Oct 7, 2024
24 of 25 checks passed
Copy link

oss-gg bot commented Oct 7, 2024

Awarding unrenamed: 150 points 🕹️ Well done! Check out your new contribution on oss.gg/unrenamed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hydration warnings in development when visiting the dashboard application
2 participants