fix: Add a check for teams so free users can't invite users... #3021
fix: Add a check for teams so free users can't invite users... #3021
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThis pull request introduces a new React component file for managing team settings and revises the related page component. The new file defines multiple components such as Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant SP as SettingsKeysPage
participant DB as Database
participant TP as TeamPage
participant UI as Additional UI Components
U->>SP: Request team settings page
SP->>DB: Call getTenantId() and query workspace data
DB-->>SP: Return tenant and workspace (team quota) data
SP->>TP: Render TeamPage with team prop
TP->>UI: Conditionally render Members, Invitations, RoleSwitcher, and StatusBadge
UI-->>TP: Provide role updates, invitation management feedbacks
TP-->>U: Display complete team management interface
Suggested labels
Suggested reviewers
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
apps/dashboard/app/(app)/settings/team/page.tsx (1)
7-13: Consider handling missing workspace scenarios.If no workspace is found, the code defaults
wstoundefined. Downstream, this simply setsteamtofalse. While functionally correct, you might improve user feedback by returning a clear message or redirect if there's no workspace.apps/dashboard/app/(app)/settings/team/client.tsx (2)
213-275: Consider confirming invitation revocations.Currently, invitation revocations happen immediately upon button click. Adding a confirmation step would be a nice UX enhancement and help prevent accidental revocations.
Here’s a sample diff to demonstrate adding a simple confirmation dialog:
<Button variant="destructive" - onClick={async () => { - await invitation.revoke(); - toast.success("Invitation revoked"); - }} + onClick={async () => { + if (confirm("Are you sure you want to revoke this invitation?")) { + await invitation.revoke(); + toast.success("Invitation revoked"); + } + }} > Revoke </Button>
276-328:RoleSwitcherlogic is clear; consider more detailed user-facing error messages.Currently, errors show only the raw exception message. You might want a more user-friendly fallback if the server returns unexpected errors.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/dashboard/app/(app)/settings/team/client.tsx(1 hunks)apps/dashboard/app/(app)/settings/team/page.tsx(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
apps/dashboard/app/(app)/settings/team/page.tsx (1)
apps/dashboard/app/(app)/settings/team/client.tsx (1) (1)
TeamPage(48-140)
⏰ Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: Test Go API Local / Test (Shard 6/8)
- GitHub Check: Test Go API Local / Test (Shard 3/8)
- GitHub Check: Test Go API Local / Test (Shard 7/8)
- GitHub Check: Test Packages / Test ./packages/hono
- GitHub Check: Test API / API Test Local
- GitHub Check: Test Go API Local / Test (Shard 1/8)
- GitHub Check: Test Go API Local / Test (Shard 2/8)
- GitHub Check: Test Agent Local / test_agent_local
- GitHub Check: Test Packages / Test ./internal/clickhouse
- GitHub Check: Test Packages / Test ./packages/cache
- GitHub Check: Test Packages / Test ./internal/keys
- GitHub Check: Build / Build
🔇 Additional comments (9)
apps/dashboard/app/(app)/settings/team/page.tsx (4)
1-3: Imports look good.These imports cleanly bring in required modules to fetch and render team data.
5-5: No-revalidate strategy is acceptable.Disabling revalidation ensures fresh data on every request. Verify if dynamic real-time updates or caching might be beneficial in other scenarios.
Would you like to confirm if other pages or routes in your application need a similar no-revalidate approach for consistency?
15-15: Graceful fallback forteamfield is consistent.Using the nullish coalescing to default to
falseis an elegant approach. No issues noted.
19-19: Clean integration with theTeamPagecomponent.The direct handoff of the
teamprop is straightforward for maintaining separate concerns between data fetching and UI rendering.apps/dashboard/app/(app)/settings/team/client.tsx (5)
1-8: Client file creation looks good.This file centralizes team-related UI and logic. The imports from external and internal libraries are well-organized.
49-73: Conditional checks align with the free-tier gating logic.These conditions block invitations for free-tier or no-organization scenarios. This fulfills the PR objective of preventing free/workspace-less users from inviting members. No apparent logical issues.
98-126: Role-based UI actions are properly safeguarded.The
isAdmincheck for revealing the invitations tab and invite button is a good practice. No concerns here.
142-211: Members listing and removal logic is efficient.You handle loading states properly and confirm membership removal. The usage of
Confirmfor destructive actions is a commendable practice.
330-343: StatusBadge rendering meets the intended workflow.The straightforward switch statement clarifies each invitation status. No issues noted.
What does this PR do?
Stops users from being able to invite users without being on a trial or paid tier.
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
How should this be tested?
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit
New Features
Refactor