Skip to content

fix: hide create button when no creation actions are available#40732

Open
DeveloperWide wants to merge 3 commits into
RocketChat:developfrom
DeveloperWide:fix/hide-create-button-without-permissions
Open

fix: hide create button when no creation actions are available#40732
DeveloperWide wants to merge 3 commits into
RocketChat:developfrom
DeveloperWide:fix/hide-create-button-without-permissions

Conversation

@DeveloperWide
Copy link
Copy Markdown

@DeveloperWide DeveloperWide commented May 29, 2026

Proposed changes (including screenshots)

This PR hides the sidebar "Create New" button when a user does not have permission to perform any creation actions.

The button provides access to actions such as:

  • Create channel
  • Create team
  • Create discussion
  • Create direct message

Previously, the button was still rendered in a disabled state when none of these actions were available. This resulted in a non-functional UI element being displayed to restricted users.

With this change, the button is rendered only when at least one creation action is available.

Before

Image

After

Image

Issue(s)

Closes #40731

Steps to test or reproduce

  1. Run Rocket.Chat locally.

  2. Create or use a role that does not have permissions to:

    • Create channels
    • Create teams
    • Create discussions
    • Create direct messages
  3. Log in as that user.

Before this fix

The "Create New" button is visible but disabled.

After this fix

The "Create New" button is not rendered.

Verification

  • Grant any one creation permission.
  • Verify the button becomes visible again.
  • Verify the menu still works as expected.

Further comments

The implementation checks whether any creation menu sections are available before rendering the button. If no actions are available, the component is not rendered.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where the "Create new" sidebar action was shown even when no creation options existed. The menu now only appears when there are available items to create, preventing empty or misleading UI elements and reducing clutter in the sidebar.

Review Change Stack

@DeveloperWide DeveloperWide requested a review from a team as a code owner May 29, 2026 10:15
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 29, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

⚠️ No Changeset found

Latest commit: 802185b

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c33c2b2f-3bd0-4a57-9258-f5a94a9c778e

📥 Commits

Reviewing files that changed from the base of the PR and between 0bb2a12 and 5827894.

📒 Files selected for processing (1)
  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
🧠 Learnings (2)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
🔇 Additional comments (1)
apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx (1)

15-19: LGTM!


Walkthrough

NavBarItemCreateNew now returns null when the create-menu sections array is empty; it only renders GenericMenu (title "Create_new", sections, SidebarV2Action) when sections.length > 0.

Changes

Create Button Visibility Fix

Layer / File(s) Summary
Conditional rendering of Create menu
apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
GenericMenu now renders only when sections.length > 0; the component returns null when no creation sections are available, preventing the "Create_new" sidebar action from appearing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: bug

Suggested reviewers

  • tassoevan
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: hiding the create button when no creation actions are available, which directly matches the code modification in NavBarItemCreateNew.tsx.
Linked Issues check ✅ Passed The PR successfully addresses issue #40731 by implementing the exact solution suggested: checking if menu sections are empty and returning null instead of rendering a disabled button.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the linked issue; only NavBarItemCreateNew.tsx was modified to conditionally render based on available creation actions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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
Contributor

@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)
apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx (1)

15-18: ⚡ Quick win

Return null explicitly on the empty state path.

Line 18 currently falls through with undefined. Please return null explicitly to match navbar patterns and keep the component return contract clear.

Proposed change
 if (sections.length > 0) {
 	return <GenericMenu icon='plus' sections={sections} title={t('Create_new')} is={SidebarV2Action} {...props} />;
 }
+
+return null;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx` around
lines 15 - 18, The component NavBarItemCreateNew currently falls through to
undefined when sections is empty; update the function in NavBarItemCreateNew.tsx
(the branch that checks if (sections.length > 0) and returns <GenericMenu ...
/>) to explicitly return null on the empty-state path so the component always
returns either a React element or null, matching the navbar component return
contract and existing patterns.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx`:
- Around line 15-18: The component NavBarItemCreateNew currently falls through
to undefined when sections is empty; update the function in
NavBarItemCreateNew.tsx (the branch that checks if (sections.length > 0) and
returns <GenericMenu ... />) to explicitly return null on the empty-state path
so the component always returns either a React element or null, matching the
navbar component return contract and existing patterns.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 50b05696-dd1f-485a-b302-5a05ecfa5dfe

📥 Commits

Reviewing files that changed from the base of the PR and between b92bcc7 and 0bb2a12.

📒 Files selected for processing (1)
  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
🧠 Learnings (2)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@coderabbitai coderabbitai Bot removed the type: bug label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create button remains visible when user has no creation permissions

1 participant