@@ -63,6 +63,8 @@ import { BetaPill } from "../beta/BetaCard";
63
63
import PosthogTrackers from "../../../PosthogTrackers" ;
64
64
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload" ;
65
65
import { useWebSearchMetrics } from "../dialogs/SpotlightDialog" ;
66
+ import { shouldShowComponent } from "../../../customisations/helpers/UIComponents" ;
67
+ import { UIComponent } from "../../../settings/UIFeature" ;
66
68
67
69
const contextMenuBelow = ( elementRect : DOMRect ) => {
68
70
// align the context menu's icons with the icon which opened the context menu
@@ -210,6 +212,14 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
210
212
const communityId = CommunityPrototypeStore . instance . getSelectedCommunityId ( ) ;
211
213
const canAddRooms = activeSpace ?. currentState ?. maySendStateEvent ( EventType . SpaceChild , cli . getUserId ( ) ) ;
212
214
215
+ const canCreateRooms = shouldShowComponent ( UIComponent . CreateRooms ) ;
216
+ const canExploreRooms = shouldShowComponent ( UIComponent . ExploreRooms ) ;
217
+
218
+ // If the user can't do anything on the plus menu, don't show it. This aims to target the
219
+ // plus menu shown on the Home tab primarily: the user has options to use the menu for
220
+ // communities and spaces, but is at risk of no options on the Home tab.
221
+ const canShowPlusMenu = canCreateRooms || canExploreRooms || activeSpace || communityId ;
222
+
213
223
let contextMenu : JSX . Element ;
214
224
if ( mainMenuDisplayed ) {
215
225
let ContextMenuComponent ;
@@ -320,12 +330,12 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
320
330
</ IconizedContextMenuOptionList >
321
331
</ IconizedContextMenu > ;
322
332
} else if ( plusMenuDisplayed ) {
323
- contextMenu = < IconizedContextMenu
324
- { ... contextMenuBelow ( plusMenuHandle . current . getBoundingClientRect ( ) ) }
325
- onFinished = { closePlusMenu }
326
- compact
327
- >
328
- < IconizedContextMenuOptionList first >
333
+ let startChatOpt : JSX . Element ;
334
+ let createRoomOpt : JSX . Element ;
335
+ let joinRoomOpt : JSX . Element ;
336
+
337
+ if ( canCreateRooms ) {
338
+ startChatOpt = (
329
339
< IconizedContextMenuOption
330
340
label = { _t ( "Start new chat" ) }
331
341
iconClassName = "mx_RoomListHeader_iconStartChat"
@@ -336,6 +346,8 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
336
346
closePlusMenu ( ) ;
337
347
} }
338
348
/>
349
+ ) ;
350
+ createRoomOpt = (
339
351
< IconizedContextMenuOption
340
352
label = { _t ( "Create new room" ) }
341
353
iconClassName = "mx_RoomListHeader_iconCreateRoom"
@@ -347,6 +359,10 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
347
359
closePlusMenu ( ) ;
348
360
} }
349
361
/>
362
+ ) ;
363
+ }
364
+ if ( canExploreRooms ) {
365
+ joinRoomOpt = (
350
366
< IconizedContextMenuOption
351
367
label = { _t ( "Join public room" ) }
352
368
iconClassName = "mx_RoomListHeader_iconExplore"
@@ -357,6 +373,18 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
357
373
closePlusMenu ( ) ;
358
374
} }
359
375
/>
376
+ ) ;
377
+ }
378
+
379
+ contextMenu = < IconizedContextMenu
380
+ { ...contextMenuBelow ( plusMenuHandle . current . getBoundingClientRect ( ) ) }
381
+ onFinished = { closePlusMenu }
382
+ compact
383
+ >
384
+ < IconizedContextMenuOptionList first >
385
+ { startChatOpt }
386
+ { createRoomOpt }
387
+ { joinRoomOpt }
360
388
</ IconizedContextMenuOptionList >
361
389
</ IconizedContextMenu > ;
362
390
}
@@ -397,13 +425,13 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
397
425
return < div className = "mx_RoomListHeader" >
398
426
{ contextMenuButton }
399
427
{ pendingRoomJoinSpinner }
400
- < ContextMenuTooltipButton
428
+ { canShowPlusMenu && < ContextMenuTooltipButton
401
429
inputRef = { plusMenuHandle }
402
430
onClick = { openPlusMenu }
403
431
isExpanded = { plusMenuDisplayed }
404
432
className = "mx_RoomListHeader_plusButton"
405
433
title = { _t ( "Add" ) }
406
- />
434
+ /> }
407
435
408
436
{ contextMenu }
409
437
</ div > ;
0 commit comments