Fix add existing rooms button (#7728)

pull/21833/head
Šimon Brandner 2022-02-07 11:19:14 +01:00 committed by GitHub
parent 7f3f186044
commit 472115cd9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -32,6 +32,7 @@ import defaultDispatcher from "../../../dispatcher/dispatcher";
import dis from "../../../dispatcher/dispatcher"; import dis from "../../../dispatcher/dispatcher";
import { import {
shouldShowSpaceInvite, shouldShowSpaceInvite,
showAddExistingRooms,
showCreateNewRoom, showCreateNewRoom,
showCreateNewSubspace, showCreateNewSubspace,
showSpaceInvite, showSpaceInvite,
@ -198,6 +199,7 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
} }
const communityId = CommunityPrototypeStore.instance.getSelectedCommunityId(); const communityId = CommunityPrototypeStore.instance.getSelectedCommunityId();
const canAddRooms = activeSpace?.currentState?.maySendStateEvent(EventType.SpaceChild, cli.getUserId());
let contextMenu: JSX.Element; let contextMenu: JSX.Element;
if (mainMenuDisplayed) { if (mainMenuDisplayed) {
@ -283,9 +285,11 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
showCreateNewRoom(activeSpace); showAddExistingRooms(activeSpace);
closePlusMenu(); closePlusMenu();
}} }}
disabled={!canAddRooms}
tooltip={!canAddRooms && _t("You do not have permissions to add rooms to this space")}
/> />
<IconizedContextMenuOption <IconizedContextMenuOption
label={_t("Add space")} label={_t("Add space")}
@ -296,6 +300,8 @@ const RoomListHeader = ({ spacePanelDisabled, onVisibilityChange }: IProps) => {
showCreateNewSubspace(activeSpace); showCreateNewSubspace(activeSpace);
closePlusMenu(); closePlusMenu();
}} }}
disabled={!canAddRooms}
tooltip={!canAddRooms && _t("You do not have permissions to add spaces to this space")}
> >
<BetaPill /> <BetaPill />
</IconizedContextMenuOption> </IconizedContextMenuOption>

View File

@ -1781,6 +1781,7 @@
"%(count)s results|one": "%(count)s result", "%(count)s results|one": "%(count)s result",
"Invite": "Invite", "Invite": "Invite",
"Add space": "Add space", "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", "Join public room": "Join public room",
"Currently joining %(count)s rooms|other": "Currently joining %(count)s rooms", "Currently joining %(count)s rooms|other": "Currently joining %(count)s rooms",
"Currently joining %(count)s rooms|one": "Currently joining %(count)s room", "Currently joining %(count)s rooms|one": "Currently joining %(count)s room",