Merge pull request #5147 from matrix-org/travis/communities/proto/create-room
Communities v2 prototype: Associate created rooms with the selected community
This commit is contained in:
commit
8a5dc7edd7
7 changed files with 39 additions and 21 deletions
|
@ -24,6 +24,7 @@ import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||||
import InfoTooltip from "../elements/InfoTooltip";
|
import InfoTooltip from "../elements/InfoTooltip";
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
import {showCommunityRoomInviteDialog} from "../../../RoomInvite";
|
import {showCommunityRoomInviteDialog} from "../../../RoomInvite";
|
||||||
|
import GroupStore from "../../../stores/GroupStore";
|
||||||
|
|
||||||
interface IProps extends IDialogProps {
|
interface IProps extends IDialogProps {
|
||||||
}
|
}
|
||||||
|
@ -92,6 +93,8 @@ export default class CreateCommunityPrototypeDialog extends React.PureComponent<
|
||||||
this.props.onFinished(true);
|
this.props.onFinished(true);
|
||||||
|
|
||||||
if (result.room_id) {
|
if (result.room_id) {
|
||||||
|
// Force the group store to update as it might have missed the general chat
|
||||||
|
await GroupStore.refreshGroupRooms(result.group_id);
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room',
|
action: 'view_room',
|
||||||
room_id: result.room_id,
|
room_id: result.room_id,
|
||||||
|
|
|
@ -83,25 +83,11 @@ export default createReactClass({
|
||||||
localpart: this.state.groupId,
|
localpart: this.state.groupId,
|
||||||
profile: profile,
|
profile: profile,
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (result.room_id) {
|
dis.dispatch({
|
||||||
dis.dispatch({
|
action: 'view_group',
|
||||||
action: 'view_room',
|
group_id: result.group_id,
|
||||||
room_id: result.room_id,
|
group_is_new: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ensure the tag gets selected now that we've created it
|
|
||||||
dis.dispatch({action: 'deselect_tags'}, true);
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'select_tag',
|
|
||||||
tag: result.group_id,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'view_group',
|
|
||||||
group_id: result.group_id,
|
|
||||||
group_is_new: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.props.onFinished(true);
|
this.props.onFinished(true);
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
this.setState({createError: e});
|
this.setState({createError: e});
|
||||||
|
|
|
@ -25,6 +25,8 @@ import { _t } from '../../../languageHandler';
|
||||||
import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
||||||
import {Key} from "../../../Keyboard";
|
import {Key} from "../../../Keyboard";
|
||||||
import {privateShouldBeEncrypted} from "../../../createRoom";
|
import {privateShouldBeEncrypted} from "../../../createRoom";
|
||||||
|
import TagOrderStore from "../../../stores/TagOrderStore";
|
||||||
|
import GroupStore from "../../../stores/GroupStore";
|
||||||
|
|
||||||
export default createReactClass({
|
export default createReactClass({
|
||||||
displayName: 'CreateRoomDialog',
|
displayName: 'CreateRoomDialog',
|
||||||
|
@ -70,6 +72,10 @@ export default createReactClass({
|
||||||
opts.encryption = this.state.isEncrypted;
|
opts.encryption = this.state.isEncrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TagOrderStore.getSelectedPrototypeTag()) {
|
||||||
|
opts.associatedWithCommunity = TagOrderStore.getSelectedPrototypeTag();
|
||||||
|
}
|
||||||
|
|
||||||
return opts;
|
return opts;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -212,7 +218,12 @@ export default createReactClass({
|
||||||
</React.Fragment>;
|
</React.Fragment>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = this.state.isPublic ? _t('Create a public room') : _t('Create a private room');
|
let title = this.state.isPublic ? _t('Create a public room') : _t('Create a private room');
|
||||||
|
if (TagOrderStore.getSelectedPrototypeTag()) {
|
||||||
|
const summary = GroupStore.getSummary(TagOrderStore.getSelectedPrototypeTag());
|
||||||
|
const name = summary?.profile?.name || TagOrderStore.getSelectedPrototypeTag();
|
||||||
|
title = _t("Create a room in %(communityName)s", {communityName: name});
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<BaseDialog className="mx_CreateRoomDialog" onFinished={this.props.onFinished}
|
<BaseDialog className="mx_CreateRoomDialog" onFinished={this.props.onFinished}
|
||||||
title={title}
|
title={title}
|
||||||
|
|
|
@ -45,6 +45,7 @@ import { arrayFastClone, arrayHasDiff } from "../../../utils/arrays";
|
||||||
import { objectShallowClone, objectWithOnly } from "../../../utils/objects";
|
import { objectShallowClone, objectWithOnly } from "../../../utils/objects";
|
||||||
import { IconizedContextMenuOption, IconizedContextMenuOptionList } from "../context_menus/IconizedContextMenu";
|
import { IconizedContextMenuOption, IconizedContextMenuOptionList } from "../context_menus/IconizedContextMenu";
|
||||||
import AccessibleButton from "../elements/AccessibleButton";
|
import AccessibleButton from "../elements/AccessibleButton";
|
||||||
|
import TagOrderStore from "../../../stores/TagOrderStore";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
onKeyDown: (ev: React.KeyboardEvent) => void;
|
onKeyDown: (ev: React.KeyboardEvent) => void;
|
||||||
|
@ -129,7 +130,9 @@ const TAG_AESTHETICS: {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<IconizedContextMenuOption
|
<IconizedContextMenuOption
|
||||||
label={_t("Explore public rooms")}
|
label={TagOrderStore.getSelectedPrototypeTag()
|
||||||
|
? _t("Explore community rooms")
|
||||||
|
: _t("Explore public rooms")}
|
||||||
iconClassName="mx_RoomList_iconExplore"
|
iconClassName="mx_RoomList_iconExplore"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -27,6 +27,7 @@ import * as Rooms from "./Rooms";
|
||||||
import DMRoomMap from "./utils/DMRoomMap";
|
import DMRoomMap from "./utils/DMRoomMap";
|
||||||
import {getAddressType} from "./UserAddress";
|
import {getAddressType} from "./UserAddress";
|
||||||
import { getE2EEWellKnown } from "./utils/WellKnownUtils";
|
import { getE2EEWellKnown } from "./utils/WellKnownUtils";
|
||||||
|
import GroupStore from "./stores/GroupStore";
|
||||||
|
|
||||||
// we define a number of interfaces which take their names from the js-sdk
|
// we define a number of interfaces which take their names from the js-sdk
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
|
@ -79,6 +80,7 @@ interface IOpts {
|
||||||
encryption?: boolean;
|
encryption?: boolean;
|
||||||
inlineErrors?: boolean;
|
inlineErrors?: boolean;
|
||||||
andView?: boolean;
|
andView?: boolean;
|
||||||
|
associatedWithCommunity?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,6 +183,10 @@ export default function createRoom(opts: IOpts): Promise<string | null> {
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
}).then(() => {
|
||||||
|
if (opts.associatedWithCommunity) {
|
||||||
|
return GroupStore.addRoomToGroup(opts.associatedWithCommunity, roomId, false);
|
||||||
|
}
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
// NB createRoom doesn't block on the client seeing the echo that the
|
// NB createRoom doesn't block on the client seeing the echo that the
|
||||||
// room has been created, so we race here with the client knowing that
|
// room has been created, so we race here with the client knowing that
|
||||||
|
|
|
@ -1121,6 +1121,7 @@
|
||||||
"Rooms": "Rooms",
|
"Rooms": "Rooms",
|
||||||
"Add room": "Add room",
|
"Add room": "Add room",
|
||||||
"Create new room": "Create new room",
|
"Create new room": "Create new room",
|
||||||
|
"Explore community rooms": "Explore community rooms",
|
||||||
"Explore public rooms": "Explore public rooms",
|
"Explore public rooms": "Explore public rooms",
|
||||||
"Low priority": "Low priority",
|
"Low priority": "Low priority",
|
||||||
"System Alerts": "System Alerts",
|
"System Alerts": "System Alerts",
|
||||||
|
@ -1642,6 +1643,7 @@
|
||||||
"Enable end-to-end encryption": "Enable end-to-end encryption",
|
"Enable end-to-end encryption": "Enable end-to-end encryption",
|
||||||
"Create a public room": "Create a public room",
|
"Create a public room": "Create a public room",
|
||||||
"Create a private room": "Create a private room",
|
"Create a private room": "Create a private room",
|
||||||
|
"Create a room in %(communityName)s": "Create a room in %(communityName)s",
|
||||||
"Name": "Name",
|
"Name": "Name",
|
||||||
"Topic (optional)": "Topic (optional)",
|
"Topic (optional)": "Topic (optional)",
|
||||||
"Make this room public": "Make this room public",
|
"Make this room public": "Make this room public",
|
||||||
|
|
|
@ -285,6 +285,13 @@ class TagOrderStore extends Store {
|
||||||
getSelectedTags() {
|
getSelectedTags() {
|
||||||
return this._state.selectedTags;
|
return this._state.selectedTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSelectedPrototypeTag() {
|
||||||
|
if (SettingsStore.getValue("feature_communities_v2_prototypes")) {
|
||||||
|
return this.getSelectedTags()[0];
|
||||||
|
}
|
||||||
|
return null; // no selection as far as this function is concerned
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.singletonTagOrderStore === undefined) {
|
if (global.singletonTagOrderStore === undefined) {
|
||||||
|
|
Loading…
Reference in a new issue