fix: hide create button when no creation actions are available#40732
fix: hide create button when no creation actions are available#40732DeveloperWide wants to merge 3 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 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)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (2)📚 Learning: 2026-03-27T14:52:56.865ZApplied to files:
📚 Learning: 2026-05-06T12:21:44.083ZApplied to files:
🔇 Additional comments (1)
WalkthroughNavBarItemCreateNew now returns null when the create-menu ChangesCreate Button Visibility Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx (1)
15-18: ⚡ Quick winReturn
nullexplicitly on the empty state path.Line 18 currently falls through with
undefined. Please returnnullexplicitly 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
📒 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
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:
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
After
Issue(s)
Closes #40731
Steps to test or reproduce
Run Rocket.Chat locally.
Create or use a role that does not have permissions to:
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
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