Skip to content

fix(navbar): hide Create New button when user has no creation permiss…#40927

Open
rish106-hub wants to merge 2 commits into
RocketChat:developfrom
rish106-hub:fix/issue-40731-create-button-hidden-no-permissions
Open

fix(navbar): hide Create New button when user has no creation permiss…#40927
rish106-hub wants to merge 2 commits into
RocketChat:developfrom
rish106-hub:fix/issue-40731-create-button-hidden-no-permissions

Conversation

@rish106-hub

@rish106-hub rish106-hub commented Jun 12, 2026

Copy link
Copy Markdown

…ions

Closes #40731

Proposed changes (including videos or screenshots)

The "Create New" (+) button in the navbar was rendering as a disabled button when the user had no room creation permissions. A disabled-but-visible button is confusing — users with no permissions should not see it at all.

Fix: useCreateNewMenu now also checks createRoomItems.length > 0 before including the section, and NavBarItemCreateNew returns null when sections array is empty.

Issue(s)

Closes #40731

Steps to test or reproduce

  1. Create a user with none of these permissions: create-c, create-p, create-d, start-discussion, start-discussion-other-user
  2. Log in as that user
  3. Verify the + (Create New) button is NOT visible in the sidebar navbar
  4. Grant at least one create permission to the user
  5. Reload — button should appear and work normally

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • The "Create New" navbar button now properly hides when users lack creation permissions or have no items available to create.

@rish106-hub rish106-hub requested a review from a team as a code owner June 12, 2026 05:42
@dionisio-bot

dionisio-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: ae496e5a-2160-4826-b6f6-a45cf579cc97

📥 Commits

Reviewing files that changed from the base of the PR and between a8a8087 and e13facf.

📒 Files selected for processing (3)
  • .changeset/fix-create-button-no-permissions.md
  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
  • apps/meteor/client/navbar/NavBarPagesGroup/hooks/useCreateNewMenu.ts
📜 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/hooks/useCreateNewMenu.ts
  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
🧠 Learnings (7)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/fix-create-button-no-permissions.md
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/navbar/NavBarPagesGroup/hooks/useCreateNewMenu.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/navbar/NavBarPagesGroup/hooks/useCreateNewMenu.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/navbar/NavBarPagesGroup/hooks/useCreateNewMenu.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/navbar/NavBarPagesGroup/hooks/useCreateNewMenu.ts
📚 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/hooks/useCreateNewMenu.ts
  • apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx
📚 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
🔇 Additional comments (3)
apps/meteor/client/navbar/NavBarPagesGroup/hooks/useCreateNewMenu.ts (1)

14-14: LGTM!

apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx (1)

15-17: LGTM!

.changeset/fix-create-button-no-permissions.md (1)

1-5: LGTM!


Walkthrough

This PR fixes a UX issue where the "Create New" navbar button appeared disabled when users lacked creation permissions. The fix tightens the permission check in the menu hook to require both the user's create-room permission and non-empty menu items, and adds a conditional render guard in the component to return null when no sections are available.

Changes

Create Button Permission Fix

Layer / File(s) Summary
Permission check and conditional rendering
apps/meteor/client/navbar/NavBarPagesGroup/hooks/useCreateNewMenu.ts, apps/meteor/client/navbar/NavBarPagesGroup/NavBarItemCreateNew.tsx, .changeset/fix-create-button-no-permissions.md
The useCreateNewMenu hook now requires both showCreate permission and non-empty createRoomItems to compute valid sections. NavBarItemCreateNew adds an early-return guard rendering null when sections are empty. Changeset documents the patch fix.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 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 PR title clearly and concisely describes the main change: hiding the Create New button when users lack creation permissions, which is the primary objective of this pull request.
Linked Issues check ✅ Passed The code changes directly address issue #40731 by checking if createRoomItems are available and returning null when sections are empty, hiding the button when no creation permissions exist.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the Create New button visibility based on user permissions; no unrelated modifications are present in the changeset.
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.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ISSUE-40731: Request failed with status code 401

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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

@changeset-bot

changeset-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4c64bb3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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