Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 472115c

Browse files
Fix add existing rooms button (#7728)
1 parent 7f3f186 commit 472115c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/components/views/rooms/RoomListHeader.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import defaultDispatcher from "../../../dispatcher/dispatcher";
3232
import dis from "../../../dispatcher/dispatcher";
3333
import {
3434
shouldShowSpaceInvite,
35+
showAddExistingRooms,
3536
showCreateNewRoom,
3637
showCreateNewSubspace,
3738
showSpaceInvite,
@@ -198,6 +199,7 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
198199
}
199200

200201
const communityId = CommunityPrototypeStore.instance.getSelectedCommunityId();
202+
const canAddRooms = activeSpace?.currentState?.maySendStateEvent(EventType.SpaceChild, cli.getUserId());
201203

202204
let contextMenu: JSX.Element;
203205
if (mainMenuDisplayed) {
@@ -283,9 +285,11 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
283285
onClick={(e) => {
284286
e.preventDefault();
285287
e.stopPropagation();
286-
showCreateNewRoom(activeSpace);
288+
showAddExistingRooms(activeSpace);
287289
closePlusMenu();
288290
}}
291+
disabled={!canAddRooms}
292+
tooltip={!canAddRooms && _t("You do not have permissions to add rooms to this space")}
289293
/>
290294
<IconizedContextMenuOption
291295
label={_t("Add space")}
@@ -296,6 +300,8 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
296300
showCreateNewSubspace(activeSpace);
297301
closePlusMenu();
298302
}}
303+
disabled={!canAddRooms}
304+
tooltip={!canAddRooms && _t("You do not have permissions to add spaces to this space")}
299305
>
300306
<BetaPill />
301307
</IconizedContextMenuOption>

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,7 @@
17811781
"%(count)s results|one": "%(count)s result",
17821782
"Invite": "Invite",
17831783
"Add space": "Add space",
1784+
"You do not have permissions to add spaces to this space": "You do not have permissions to add spaces to this space",
17841785
"Join public room": "Join public room",
17851786
"Currently joining %(count)s rooms|other": "Currently joining %(count)s rooms",
17861787
"Currently joining %(count)s rooms|one": "Currently joining %(count)s room",

0 commit comments

Comments
 (0)