Iterate space panel context menu
This commit is contained in:
parent
65a7d0621d
commit
11fbd081f1
1 changed files with 25 additions and 7 deletions
|
@ -30,7 +30,12 @@ import IconizedContextMenu, {
|
||||||
import {_t} from "../../../languageHandler";
|
import {_t} from "../../../languageHandler";
|
||||||
import {ContextMenuTooltipButton} from "../../../accessibility/context_menu/ContextMenuTooltipButton";
|
import {ContextMenuTooltipButton} from "../../../accessibility/context_menu/ContextMenuTooltipButton";
|
||||||
import {toRightOf} from "../../structures/ContextMenu";
|
import {toRightOf} from "../../structures/ContextMenu";
|
||||||
import {shouldShowSpaceSettings, showCreateNewRoom, showSpaceSettings} from "../../../utils/space";
|
import {
|
||||||
|
shouldShowSpaceSettings,
|
||||||
|
showAddExistingRooms,
|
||||||
|
showCreateNewRoom,
|
||||||
|
showSpaceSettings,
|
||||||
|
} from "../../../utils/space";
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||||
import {ButtonEvent} from "../elements/AccessibleButton";
|
import {ButtonEvent} from "../elements/AccessibleButton";
|
||||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||||
|
@ -127,7 +132,7 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
||||||
|
|
||||||
if (this.props.space.getJoinRule() === "public") {
|
if (this.props.space.getJoinRule() === "public") {
|
||||||
const modal = Modal.createTrackedDialog("Space Invite", "User Menu", InfoDialog, {
|
const modal = Modal.createTrackedDialog("Space Invite", "User Menu", InfoDialog, {
|
||||||
title: _t("Invite members"),
|
title: _t("Invite to %(spaceName)s", { spaceName: this.props.space.name }),
|
||||||
description: <React.Fragment>
|
description: <React.Fragment>
|
||||||
<span>{ _t("Share your public space") }</span>
|
<span>{ _t("Share your public space") }</span>
|
||||||
<SpacePublicShare space={this.props.space} onFinished={() => modal.close()} />
|
<SpacePublicShare space={this.props.space} onFinished={() => modal.close()} />
|
||||||
|
@ -170,6 +175,14 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
||||||
this.setState({contextMenuPosition: null}); // also close the menu
|
this.setState({contextMenuPosition: null}); // also close the menu
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onAddExistingRoomClick = (ev: ButtonEvent) => {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
|
showAddExistingRooms(this.context, this.props.space);
|
||||||
|
this.setState({contextMenuPosition: null}); // also close the menu
|
||||||
|
};
|
||||||
|
|
||||||
private onMembersClick = (ev: ButtonEvent) => {
|
private onMembersClick = (ev: ButtonEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
@ -236,15 +249,20 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
||||||
</IconizedContextMenuOptionList>;
|
</IconizedContextMenuOptionList>;
|
||||||
}
|
}
|
||||||
|
|
||||||
let newRoomOption;
|
let newRoomSection;
|
||||||
if (this.props.space.currentState.maySendStateEvent(EventType.SpaceChild, userId)) {
|
if (this.props.space.currentState.maySendStateEvent(EventType.SpaceChild, userId)) {
|
||||||
newRoomOption = (
|
newRoomSection = <IconizedContextMenuOptionList first>
|
||||||
<IconizedContextMenuOption
|
<IconizedContextMenuOption
|
||||||
iconClassName="mx_SpacePanel_iconPlus"
|
iconClassName="mx_SpacePanel_iconPlus"
|
||||||
label={_t("New room")}
|
label={_t("Create new room")}
|
||||||
onClick={this.onNewRoomClick}
|
onClick={this.onNewRoomClick}
|
||||||
/>
|
/>
|
||||||
);
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_SpacePanel_iconPlus"
|
||||||
|
label={_t("Add existing room")}
|
||||||
|
onClick={this.onAddExistingRoomClick}
|
||||||
|
/>
|
||||||
|
</IconizedContextMenuOptionList>;
|
||||||
}
|
}
|
||||||
|
|
||||||
contextMenu = <IconizedContextMenu
|
contextMenu = <IconizedContextMenu
|
||||||
|
@ -274,8 +292,8 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
||||||
label={_t("Explore rooms")}
|
label={_t("Explore rooms")}
|
||||||
onClick={this.onExploreRoomsClick}
|
onClick={this.onExploreRoomsClick}
|
||||||
/>
|
/>
|
||||||
{ newRoomOption }
|
|
||||||
</IconizedContextMenuOptionList>
|
</IconizedContextMenuOptionList>
|
||||||
|
{ newRoomSection }
|
||||||
{ leaveSection }
|
{ leaveSection }
|
||||||
</IconizedContextMenu>;
|
</IconizedContextMenu>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue