fix(dashboard): paginate members and hide invite from non-admins - #416
fix(dashboard): paginate members and hide invite from non-admins#416duyetbot wants to merge 1 commit into
Conversation
Members and invitations used pageSize 10 with no fetchNext, so a 15-member org showed "15 members" but only the first page. InviteMemberForm rendered for everyone; Clerk rejected non-admin submits. Switching org via ?org= called setActive without reload, so the sidebar stayed on the previous org. Raise pageSize to 50, append via Clerk infinite + Load more, gate the invite form on isAdmin, and reload after setActive like the sidebar. Fixes #408 Co-Authored-By: Duyet Le <me@duyet.net> Co-Authored-By: duyetbot <bot@duyet.net>
Reviewer's GuidePaginated organization members and invitations using Clerk’s infinite pagination, added a "Load more" control, gated the invite form to admins only, and aligned org switching via the ?org= query param with the sidebar behavior by reloading after setActive. Sequence diagram for members pagination with Load moresequenceDiagram
actor User
participant MembersContent
participant MembersList
participant MemberListCard
participant ClerkUseOrganization
User->>MemberListCard: click Button_onClick
MemberListCard->>MembersList: onLoadMore()
MembersList->>MembersContent: onLoadMore()
MembersContent->>ClerkUseOrganization: memberships.fetchNext()
ClerkUseOrganization-->>MembersContent: memberships.data (next page)
MembersContent-->>MembersList: memberships.data (appended)
MembersList-->>MemberListCard: data, hasMore, isLoadingMore
MemberListCard-->>User: updated table and Load more state
Sequence diagram for org switching via org query paramsequenceDiagram
actor Browser
participant MembersContent
participant ClerkSetActive
participant Window
Browser->>MembersContent: initial_render_with_orgParam
MembersContent->>MembersContent: React.useEffect [orgParam and isOrgLoaded]
MembersContent->>ClerkSetActive: setActive(organization)
ClerkSetActive-->>MembersContent: setActive_resolved
MembersContent->>Window: window.location.reload()
Window-->>Browser: trigger_full_page_reload
Browser->>MembersContent: rerender_with_new_active_org
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 117 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
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. Comment |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
useEffectthat callssetActiveand thenwindow.location.reload()may be heavy-handed for org switching; consider using router navigation or a scoped state reset to avoid a full-page reload while still re-triggeringProjectScopeProvider. - In the pagination logic,
isLoadingMoreis inferred asBoolean(isFetching && !isLoading); if Clerk exposes a more specificisFetchingNextPage(or equivalent), using that would avoid potential UI flicker when initial loads and background refetches overlap.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `useEffect` that calls `setActive` and then `window.location.reload()` may be heavy-handed for org switching; consider using router navigation or a scoped state reset to avoid a full-page reload while still re-triggering `ProjectScopeProvider`.
- In the pagination logic, `isLoadingMore` is inferred as `Boolean(isFetching && !isLoading)`; if Clerk exposes a more specific `isFetchingNextPage` (or equivalent), using that would avoid potential UI flicker when initial loads and background refetches overlap.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Sourcery's two review-body nits are left as-is:
|
Summary
Fixes the members dashboard bugs in #408:
pageSize: 50with Clerkinfinite+fetchNext, and a Load more button when more pages remain. The UI no longer claims “15 members” while rendering only the first 10.InviteMemberFormrenders only whenisAdmin. Non-admins still see the lists (without manage actions).?org=nowsetActivethenwindow.location.reload(), matching the sidebar org switcher soProjectScopeProviderrefetches for the new org.Test plan
/dashboard/settings/organizations/members/?org=<other-org-id>— page reloads onto that org and sidebar projects matchCloses #408
Summary by Sourcery
Paginate organization members and invitations in the dashboard and align org switching behavior with the sidebar while restricting invite controls to admins.
New Features:
Bug Fixes:
Enhancements: