Skip to content

fix(RecursivePermission): pass only one child to the tooltip#3288

Merged
ogzhanolguncu merged 5 commits intomainfrom
ENG-1802-permissions-roles
May 29, 2025
Merged

fix(RecursivePermission): pass only one child to the tooltip#3288
ogzhanolguncu merged 5 commits intomainfrom
ENG-1802-permissions-roles

Conversation

@mcstepp
Copy link
Collaborator

@mcstepp mcstepp commented May 29, 2025

What does this PR do?

Fixes # ENG-1802

Root cause: When description exists, the tooltip receives 2 children, which causes React.Children.only to throw an error.

Solution: Wrap everything in a single container

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?

  1. Have a workspace with at least 1 API, 1 role, 1 permission
  2. On the Authorization > Roles screen, expand the the Role Permissions tree for a role that has at least one permission that has a description
  3. Permission tree should expand without throwing an error.

A. Clicking to Expand
Screenshot 2025-05-29 at 1 22 06 PM

B. Clicking Expand All
Screenshot 2025-05-29 at 1 22 20 PM

C. With description
Screenshot 2025-05-29 at 1 26 09 PM

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

Summary by CodeRabbit

  • Style
    • Improved the layout of permission toggles, labels, and descriptions for better visual alignment and readability in the roles authorization section.
  • New Features
    • Added the ability to resume canceled subscriptions in billing settings.
    • Introduced a loading state with a pulsing animation on the billing page for a smoother user experience.
  • Bug Fixes
    • Enhanced dialog behavior by closing confirmation dialogs promptly before processing actions.

@linear
Copy link

linear bot commented May 29, 2025

@changeset-bot
Copy link

changeset-bot bot commented May 29, 2025

⚠️ No Changeset found

Latest commit: f4ad07b

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 29, 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 29, 2025 7:02pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2025 7:02pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 29, 2025

📝 Walkthrough

"""

Walkthrough

The update restructures the layout of leaf permission nodes in the RecursivePermission component, adjusting how the toggle, label, and description are grouped and rendered. The visual hierarchy changes, but there are no modifications to logic, state, or event handling. Additionally, subscription mutation hooks in the billing client are consolidated into a single Mutations function, adding support for resuming canceled subscriptions. The billing page now wraps the Client component in a Suspense with a loading fallback. The confirmation button's click handler order was adjusted to close the dialog before awaiting confirmation.

Changes

File(s) Change Summary
apps/dashboard/app/(app)/authorization/roles/[roleId]/tree.tsx Refactored the rendering structure of leaf permission nodes to adjust layout and description placement.
apps/dashboard/app/(app)/settings/billing/client.tsx Consolidated subscription mutation hooks into a Mutations function; added uncancelSubscription mutation; updated Client and CancelAlert to use this function.
apps/dashboard/app/(app)/settings/billing/components/confirmation.tsx Changed button onClick handler to close dialog before awaiting confirmation function.
apps/dashboard/app/(app)/settings/billing/page.tsx Wrapped Client component in a React Suspense with a loading fallback UI.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RecursivePermission
    User->>RecursivePermission: Render permission leaf node
    RecursivePermission->>RecursivePermission: Render toggle and label in flex container
    RecursivePermission->>RecursivePermission: Conditionally render description below flex container
Loading
sequenceDiagram
    participant ClientComponent
    participant MutationsFunction
    ClientComponent->>MutationsFunction: Call to get mutation hooks
    MutationsFunction-->>ClientComponent: Return create, update, cancel, uncancel mutations
    ClientComponent->>MutationsFunction: Use mutations for subscription operations
Loading
sequenceDiagram
    participant ConfirmationButton
    participant Dialog
    ConfirmationButton->>Dialog: setOpen(false) to close dialog
    ConfirmationButton->>ConfirmationFunction: Await confirmation function
Loading
sequenceDiagram
    participant BillingPage
    participant Suspense
    participant ClientComponent
    BillingPage->>Suspense: Render Suspense with fallback
    Suspense->>ClientComponent: Render Client component
Loading

Possibly related PRs

Suggested labels

Bug, 🕹️ oss.gg, :joystick: 150 points

Suggested reviewers

  • perkinsjr
  • ogzhanolguncu
    """

📜 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 0442bf6 and a9bce24.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • apps/dashboard/app/(app)/settings/billing/client.tsx (7 hunks)
  • apps/dashboard/app/(app)/settings/billing/components/confirmation.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/page.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (25)
  • GitHub Check: Test Go API Local / Test (Shard 8/8)
  • GitHub Check: Test Go API Local / Test (Shard 6/8)
  • GitHub Check: Test Go API Local / Test (Shard 2/8)
  • GitHub Check: Test Go API Local / Test (Shard 7/8)
  • GitHub Check: Test Go API Local / Test (Shard 3/8)
  • GitHub Check: Test Go API Local / Test (Shard 4/8)
  • GitHub Check: Test Go API Local / Test (Shard 5/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 ./internal/billing
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Packages / Test ./apps/dashboard
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/hash
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
apps/dashboard/app/(app)/settings/billing/components/confirmation.tsx (1)

39-40: Consider the UX implications of closing dialog before confirmation.

Closing the dialog before awaiting the confirmation provides immediate feedback to users, which improves perceived responsiveness. However, consider the error handling implications:

  • If props.onConfirm() fails, the dialog is already closed and users might miss error feedback
  • The loading state (setLoading(false)) will still execute, but the visual indicator might not be visible to users

Ensure that error handling in the calling components provides adequate user feedback when confirmation fails.

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

10-10: Good addition of Suspense import.

The import is correctly added for the Suspense component usage below.


168-201: Excellent implementation of Suspense boundary.

This addition significantly improves the user experience by:

  • Providing immediate loading feedback while the Client component initializes
  • Handling any potential async operations in the Client component gracefully
  • Maintaining consistent UI with WorkspaceNavbar in the fallback
  • Using appropriate loading animation and placeholder styling

The fallback UI design is well-thought-out and maintains visual consistency with the rest of the application.

apps/dashboard/app/(app)/settings/billing/client.tsx (7)

43-84: Excellent refactoring to centralize mutation logic.

The introduction of the Mutations function provides several benefits:

  • DRY principle: Eliminates code duplication across components
  • Consistency: All mutations have consistent error handling and success messages
  • Maintainability: Single place to manage mutation definitions
  • Reusability: Multiple components can easily access the same mutations

The uncancelSubscription mutation is a valuable addition that enables users to resume canceled subscriptions, improving the user experience.


87-87: Clean integration of centralized mutations.

The Client component now uses the centralized mutation pattern consistently, maintaining the same functionality while improving code organization.


160-161: Consistent usage of centralized mutations for subscription updates.

The update subscription functionality correctly uses the new mutations.updateSubscription pattern.


179-181: Proper implementation of create subscription functionality.

The create subscription flow correctly uses the new mutations.createSubscription pattern.


240-240: Correct implementation of cancel subscription functionality.

The cancel subscription functionality properly uses the new mutations.cancelSubscription pattern.


273-273: Good adoption of centralized mutations in CancelAlert.

The CancelAlert component correctly adopts the new centralized mutation pattern, demonstrating the reusability of the Mutations function.


296-298: Proper implementation of uncancel subscription functionality.

The uncancel subscription feature is well-implemented with:

  • Proper loading state management
  • Disabled state during mutation
  • Clear user interaction through the "Resubscribe" button

This provides users with a seamless way to resume their canceled subscriptions.

✨ 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 29, 2025

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

Copy link
Contributor

@mcstepp Working great tested against prod. Can you update lock file so we can merge?

Copy link
Member

Please don't update this branch with main for a few minutes

Fixes an issue where stripe is trying to render something before it's
ready. I also did some change to the way mutations are stored.

I also fixed the annoying double dialog on confirmation
Copy link
Collaborator Author

mcstepp commented May 29, 2025

oh shit

Copy link
Member

Give me a few mins it should be fine

Copy link
Member

You are good to merge

Copy link
Collaborator Author

mcstepp commented May 29, 2025

dang it. lemme see something

Copy link
Collaborator Author

mcstepp commented May 29, 2025

please sir may i have another approval?

Also some API tests are failing with 500 errors and i aint touched it

Copy link
Contributor

sure

Copy link
Contributor

🫡

Copy link
Contributor

@mcstepp is it normal to have that big lock file? 😄

Copy link
Member

There shouldn’t be a lock file at all for a single file change

Copy link
Collaborator Author

mcstepp commented May 29, 2025

I had to update my packages

Copy link
Collaborator Author

mcstepp commented May 29, 2025

i just ran pnpm i to make sure I picked up stuff from the last two weeks

Copy link
Collaborator Author

mcstepp commented May 29, 2025

on main

Copy link
Member

pnpm i shouldn’t generate a new lock file unless you explicitly upgrade a package or your using a different pnpm version than we are

Copy link
Member

e.g you aren’t using corepack to make sure you are on the same version.

Copy link
Contributor

I just double checked them most them look innocent minor updates

Copy link
Contributor

but yes we should use corepack

Copy link
Member

innocent minor changes shouldn’t go in a file change. That’s a recipe for fixing one thing and breaking ten.

Copy link
Collaborator Author

mcstepp commented May 29, 2025

I can yeet the lock file

Copy link
Member

Please. 🙏

Copy link
Contributor

Now Meg's branch is mixed with James latest PR I'm so confused 😄

Copy link
Collaborator Author

mcstepp commented May 29, 2025

its fiiiiiine

Copy link
Contributor

is it or you baiting me? 😄

Copy link
Member

It is fine; you can merge those changes were mine

Copy link
Contributor

good to go

@ogzhanolguncu ogzhanolguncu added this pull request to the merge queue May 29, 2025
Merged via the queue into main with commit 1bc4f95 May 29, 2025
30 checks passed
@ogzhanolguncu ogzhanolguncu deleted the ENG-1802-permissions-roles branch May 29, 2025 19:07
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.

3 participants