Add customisation point to disable space creation (#7766)

* mock matchMedia in jest setup

Signed-off-by: Kerry Archibald <kerrya@element.io>

* use UIComponent.CreateSpaces in space panel

Signed-off-by: Kerry Archibald <kerrya@element.io>

* lint

Signed-off-by: Kerry Archibald <kerrya@element.io>

* hide add space in spacecontextmenu

Signed-off-by: Kerry Archibald <kerrya@element.io>

* use UIComponent customistations in space oom view add space button

Signed-off-by: Kerry Archibald <kerrya@element.io>

* copyright

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-02-09 17:21:40 +01:00 committed by GitHub
parent 6e8edbb418
commit 818fddd72c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 890 additions and 48 deletions

View file

@ -363,6 +363,8 @@ const SpacePreview = ({ space, onJoinButtonClicked, onRejectButtonClicked }: ISp
const SpaceLandingAddButton = ({ space }) => {
const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu();
const canCreateRoom = shouldShowComponent(UIComponent.CreateRooms);
const canCreateSpace = shouldShowComponent(UIComponent.CreateSpaces);
let contextMenu;
if (menuDisplayed) {
@ -376,7 +378,7 @@ const SpaceLandingAddButton = ({ space }) => {
compact
>
<IconizedContextMenuOptionList first>
<IconizedContextMenuOption
{ canCreateRoom && <IconizedContextMenuOption
label={_t("Create new room")}
iconClassName="mx_RoomList_iconPlus"
onClick={async (e) => {
@ -388,7 +390,7 @@ const SpaceLandingAddButton = ({ space }) => {
defaultDispatcher.fire(Action.UpdateSpaceHierarchy);
}
}}
/>
/> }
<IconizedContextMenuOption
label={_t("Add existing room")}
iconClassName="mx_RoomList_iconAddExistingRoom"
@ -399,18 +401,20 @@ const SpaceLandingAddButton = ({ space }) => {
showAddExistingRooms(space);
}}
/>
<IconizedContextMenuOption
label={_t("Add space")}
iconClassName="mx_RoomList_iconPlus"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
closeMenu();
showCreateNewSubspace(space);
}}
>
<BetaPill />
</IconizedContextMenuOption>
{ canCreateSpace &&
<IconizedContextMenuOption
label={_t("Add space")}
iconClassName="mx_RoomList_iconPlus"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
closeMenu();
showCreateNewSubspace(space);
}}
>
<BetaPill />
</IconizedContextMenuOption>
}
</IconizedContextMenuOptionList>
</IconizedContextMenu>;
}
@ -449,10 +453,11 @@ const SpaceLanding = ({ space }: { space: Room }) => {
);
}
const canAddRooms = myMembership === "join" && space.currentState.maySendStateEvent(EventType.SpaceChild, userId);
const hasAddRoomPermissions = myMembership === "join" &&
space.currentState.maySendStateEvent(EventType.SpaceChild, userId);
let addRoomButton;
if (canAddRooms) {
if (hasAddRoomPermissions) {
addRoomButton = <SpaceLandingAddButton space={space} />;
}