From 472115cd9c43fe48d2529260bf3716b3dddd4370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 7 Feb 2022 11:19:14 +0100 Subject: [PATCH] Fix add existing rooms button (#7728) --- src/components/views/rooms/RoomListHeader.tsx | 8 +++++++- src/i18n/strings/en_EN.json | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/RoomListHeader.tsx b/src/components/views/rooms/RoomListHeader.tsx index ac38d0519b..5e238f3849 100644 --- a/src/components/views/rooms/RoomListHeader.tsx +++ b/src/components/views/rooms/RoomListHeader.tsx @@ -32,6 +32,7 @@ import defaultDispatcher from "../../../dispatcher/dispatcher"; import dis from "../../../dispatcher/dispatcher"; import { shouldShowSpaceInvite, + showAddExistingRooms, showCreateNewRoom, showCreateNewSubspace, showSpaceInvite, @@ -198,6 +199,7 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => { } const communityId = CommunityPrototypeStore.instance.getSelectedCommunityId(); + const canAddRooms = activeSpace?.currentState?.maySendStateEvent(EventType.SpaceChild, cli.getUserId()); let contextMenu: JSX.Element; if (mainMenuDisplayed) { @@ -283,9 +285,11 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => { onClick={(e) => { e.preventDefault(); e.stopPropagation(); - showCreateNewRoom(activeSpace); + showAddExistingRooms(activeSpace); closePlusMenu(); }} + disabled={!canAddRooms} + tooltip={!canAddRooms && _t("You do not have permissions to add rooms to this space")} /> { showCreateNewSubspace(activeSpace); closePlusMenu(); }} + disabled={!canAddRooms} + tooltip={!canAddRooms && _t("You do not have permissions to add spaces to this space")} > diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 10cf93fe48..e2c56f1913 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1781,6 +1781,7 @@ "%(count)s results|one": "%(count)s result", "Invite": "Invite", "Add space": "Add space", + "You do not have permissions to add spaces to this space": "You do not have permissions to add spaces to this space", "Join public room": "Join public room", "Currently joining %(count)s rooms|other": "Currently joining %(count)s rooms", "Currently joining %(count)s rooms|one": "Currently joining %(count)s room",