Disable "Invite/Add user" on UserInvitesTable by refactoring#607
Disable "Invite/Add user" on UserInvitesTable by refactoring#607lorenzbaum wants to merge 1 commit intonetbirdio:mainfrom
Conversation
📝 WalkthroughWalkthroughCentralized the InviteUserButton into Changes
Sequence Diagram(s)sequenceDiagram
participant User as "User"
participant UsersTable as "UsersTable (consumer)"
participant InviteBtn as "InviteUserButton"
participant Tooltip as "FullTooltip"
participant Modal as "UserInviteModal"
User->>UsersTable: sees invite button
UsersTable->>InviteBtn: render(props: show, groups)
alt account.settings.local_auth_disabled == true or no create perm
InviteBtn->>Tooltip: wrap disabled button
Tooltip-->>User: shows tooltip with message + external "Learn more" link
else enabled
InviteBtn->>Modal: wrap button with modal trigger
User->>InviteBtn: clicks button
InviteBtn->>Modal: open invite modal
Modal-->>User: show invite modal UI
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Pull request overview
Refactors the Users “Invites” view to reuse the shared InviteUserButton implementation so that invite/add actions are correctly disabled when local_auth_disabled is enabled.
Changes:
- Removed the duplicated
InviteUserButtonimplementation fromUserInvitesTable. - Switched
UserInvitesTableto import and useInviteUserButtonfromUsersTable. - Removed now-unneeded imports tied to the duplicated button implementation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/modules/users/UserInvitesTable.tsx`:
- Line 43: There is a cyclic import between UsersTable and UserInvitesTable
caused by InviteUserButton being declared in UsersTable and imported back by
UserInvitesTable; extract the InviteUserButton component into a new shared
module (e.g., a new component file) and update both UserInvitesTable and
UsersTable to import InviteUserButton from that shared module, ensuring the
original InviteUserButton export (component name) is preserved and that any
props or helper functions it relies on are moved or re-exported alongside it to
avoid reintroducing the cycle.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3715d4b0-3d0b-4c43-90af-9a1f1ec20d6e
📒 Files selected for processing (1)
src/modules/users/UserInvitesTable.tsx
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/modules/users/UsersTable.tsx`:
- Line 37: UsersTable.tsx currently imports InviteUserButton from
UserInvitesTable but does not re-export it, causing GroupUsersSection.tsx (which
still imports InviteUserButton from UsersTable) to break; fix by re-exporting
InviteUserButton from UsersTable.tsx (e.g., add an export that forwards
InviteUserButton from UserInvitesTable) so existing imports in
GroupUsersSection.tsx continue to work, or alternatively update
GroupUsersSection.tsx to import InviteUserButton directly from UserInvitesTable
to remove the need for the re-export.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 916cbed0-b195-4de3-bb5f-5e113c2fbf86
📒 Files selected for processing (2)
src/modules/users/UserInvitesTable.tsxsrc/modules/users/UsersTable.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/modules/users/UserInvitesTable.tsx
…erButton component with import from UserInvitesTable
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/InlineLink.tsx (1)
38-47: Extract sharedsafeRellogic to a helper to avoid drift.This logic is duplicated in
src/components/DropdownMenu.tsx(Line 114-122). A shared utility would keep behavior consistent in one place.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/InlineLink.tsx` around lines 38 - 47, The duplicated safeRel computation in InlineLink (const safeRel useMemo) and DropdownMenu should be extracted into a single helper (e.g., getSafeRel or buildSafeRel) that accepts (rel?: string, target?: string) and returns the normalized rel string; replace the inline logic in InlineLink (safeRel in useMemo) and the corresponding block in DropdownMenu with calls to this helper, export it from a shared utils module, and update imports accordingly so both components use the same implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/components/InlineLink.tsx`:
- Around line 38-47: The duplicated safeRel computation in InlineLink (const
safeRel useMemo) and DropdownMenu should be extracted into a single helper
(e.g., getSafeRel or buildSafeRel) that accepts (rel?: string, target?: string)
and returns the normalized rel string; replace the inline logic in InlineLink
(safeRel in useMemo) and the corresponding block in DropdownMenu with calls to
this helper, export it from a shared utils module, and update imports
accordingly so both components use the same implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0807aa86-e398-494d-b42f-b70730bf63eb
📒 Files selected for processing (10)
src/app/(dashboard)/control-center/page.tsxsrc/components/DropdownMenu.tsxsrc/components/InlineLink.tsxsrc/components/SidebarItem.tsxsrc/components/ui/HelpAndSupportButton.tsxsrc/modules/onboarding/OnboardingEnd.tsxsrc/modules/setup-netbird-modal/AndroidTab.tsxsrc/modules/setup-netbird-modal/DockerTab.tsxsrc/modules/setup-netbird-modal/IOSTab.tsxsrc/modules/setup-netbird-modal/MacOSTab.tsx
💤 Files with no reviewable changes (1)
- src/components/ui/HelpAndSupportButton.tsx
✅ Files skipped from review due to trivial changes (5)
- src/modules/onboarding/OnboardingEnd.tsx
- src/modules/setup-netbird-modal/AndroidTab.tsx
- src/modules/setup-netbird-modal/DockerTab.tsx
- src/app/(dashboard)/control-center/page.tsx
- src/modules/setup-netbird-modal/IOSTab.tsx
I moved the duplicate
InviteUserButtoncomponent fromUsersTabletoUserInvitesTableand imported it from there.This also fixes the issue that on the UserInvitesTable ("Show Invites" on /team/users) inviting/adding was possible even when
localAuthDisabledistrue, as I overwrote the old code there. (Also, the existing import fromGroupUsersSectionnow usesUserInvitesTableinstead ofUsersTable.)Result:
Issue ticket number and link
No issue
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit
Refactor
Bug Fix / UX
Security / Links