Skip to content

Disable "Invite/Add user" on UserInvitesTable by refactoring#607

Open
lorenzbaum wants to merge 1 commit intonetbirdio:mainfrom
lorenzbaum:main
Open

Disable "Invite/Add user" on UserInvitesTable by refactoring#607
lorenzbaum wants to merge 1 commit intonetbirdio:mainfrom
lorenzbaum:main

Conversation

@lorenzbaum
Copy link
Copy Markdown

@lorenzbaum lorenzbaum commented Apr 8, 2026

I moved the duplicate InviteUserButton component from UsersTable to UserInvitesTable and imported it from there.

This also fixes the issue that on the UserInvitesTable ("Show Invites" on /team/users) inviting/adding was possible even when localAuthDisabled is true, as I overwrote the old code there. (Also, the existing import from GroupUsersSection now uses UserInvitesTable instead of UsersTable.)

Result:

image

Issue ticket number and link

No issue

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

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

    • Consolidated invite-button logic into a single shared implementation for consistency.
  • Bug Fix / UX

    • Invite button is disabled when local authentication is off and shows a tooltip with a “Learn more” link; when enabled, it opens the invite modal as before.
  • Security / Links

    • External links updated to use safer new-tab behavior (noopener noreferrer) and related link handling.

Copilot AI review requested due to automatic review settings April 8, 2026 21:39
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

Centralized the InviteUserButton into src/modules/users/UserInvitesTable.tsx; it now disables when account?.settings.local_auth_disabled and wraps the disabled button in a FullTooltip with an external “Learn more” link. Consumers (UsersTable, GroupUsersSection) import the component from the new location. Several external links across the app now include rel="noopener noreferrer" and link-rel handling was hardened.

Changes

Cohort / File(s) Summary
User invites component
src/modules/users/UserInvitesTable.tsx
Moved/updated InviteUserButton: compute localAuthDisabled = account?.settings.local_auth_disabled; `disabled = !permission.users.create
Users table consumer
src/modules/users/UsersTable.tsx
Removed local InviteUserButton implementation and related imports (FullTooltip, MailPlus, Group, UserInviteModal); now imports InviteUserButton from @/modules/users/UserInvitesTable.
Group users consumer
src/modules/groups/details/GroupUsersSection.tsx
Updated InviteUserButton import to @/modules/users/UserInvitesTable; usage and props unchanged.
Link safety & rel handling
src/components/DropdownMenu.tsx, src/components/InlineLink.tsx, src/components/SidebarItem.tsx, src/components/ui/HelpAndSupportButton.tsx, src/app/(dashboard)/control-center/page.tsx, src/modules/onboarding/OnboardingEnd.tsx, src/modules/setup-netbird-modal/*
Added or normalized rel="noopener noreferrer" for external target="_blank" links; DropdownMenu now computes a safe rel via useMemo; InlineLink Props extended with rel?: string and guarantees noopener,noreferrer when opening new tabs; SidebarItem uses window.open(..., "noopener,noreferrer"); HelpAndSupportButton had some rel attributes removed.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mlsmaycon
  • heisbrot

Poem

🐇 I hopped a button into its cozy burrow,

When local auth sleeps, a tooltip will show.
Click wakes a modal, or a gentle sign:
“Learn more” opens windows, safe and fine.
Carrots, code, and tiny hops—celebrate the flow!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main refactoring work (moving InviteUserButton) and the key fix (disabling the invite action when localAuthDisabled).
Description check ✅ Passed The PR description includes a clear explanation of changes, the bug fix, and the visual result. Documentation status is addressed and marked as not needed with reasonable justification.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 InviteUserButton implementation from UserInvitesTable.
  • Switched UserInvitesTable to import and use InviteUserButton from UsersTable.
  • Removed now-unneeded imports tied to the duplicated button implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9701e65 and d0dce0f.

📒 Files selected for processing (1)
  • src/modules/users/UserInvitesTable.tsx

@lorenzbaum lorenzbaum marked this pull request as draft April 8, 2026 21:49
@lorenzbaum lorenzbaum marked this pull request as ready for review April 8, 2026 22:01
@lorenzbaum lorenzbaum requested a review from Copilot April 8, 2026 22:01
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between d0dce0f and bb6e407.

📒 Files selected for processing (2)
  • src/modules/users/UserInvitesTable.tsx
  • src/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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
src/components/InlineLink.tsx (1)

38-47: Extract shared safeRel logic 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

📥 Commits

Reviewing files that changed from the base of the PR and between ed72744 and 25027ee.

📒 Files selected for processing (10)
  • src/app/(dashboard)/control-center/page.tsx
  • src/components/DropdownMenu.tsx
  • src/components/InlineLink.tsx
  • src/components/SidebarItem.tsx
  • src/components/ui/HelpAndSupportButton.tsx
  • src/modules/onboarding/OnboardingEnd.tsx
  • src/modules/setup-netbird-modal/AndroidTab.tsx
  • src/modules/setup-netbird-modal/DockerTab.tsx
  • src/modules/setup-netbird-modal/IOSTab.tsx
  • src/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

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