From 6ae4b3e966c95b0edc2b8f0d89ab8f2887b7b28a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 20 Sep 2019 17:46:14 +0200 Subject: [PATCH] add room alias field to dialog --- .../views/dialogs/CreateRoomDialog.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js index b462230c24..501e6b6f80 100644 --- a/src/components/views/dialogs/CreateRoomDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -21,6 +21,7 @@ import sdk from '../../../index'; import SdkConfig from '../../../SdkConfig'; import withValidation from '../elements/Validation'; import { _t } from '../../../languageHandler'; +import MatrixClientPeg from '../../../MatrixClientPeg'; export default createReactClass({ displayName: 'CreateRoomDialog', @@ -34,6 +35,7 @@ export default createReactClass({ isPublic: false, name: "", topic: "", + alias: "", detailsOpen: false, noFederate: config.default_federate === false, nameIsValid: false, @@ -48,6 +50,10 @@ export default createReactClass({ createOpts.preset = "public_chat"; // to prevent createRoom from enabling guest access createOpts['initial_state'] = []; + const {alias} = this.state; + const localPart = alias.substr(1, alias.indexOf(":") - 1); + createOpts['room_alias_name'] = localPart; + } if (this.state.topic) { createOpts.topic = this.state.topic; } @@ -85,6 +91,9 @@ export default createReactClass({ this.setState({isPublic}); }, + onAliasChange(alias) { + this.setState({alias}); + }, onDetailsToggled(ev) { this.setState({detailsOpen: ev.target.open}); @@ -119,10 +128,19 @@ export default createReactClass({ const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); const Field = sdk.getComponent('views.elements.Field'); const LabelledToggleSwitch = sdk.getComponent('views.elements.LabelledToggleSwitch'); + const RoomAliasField = sdk.getComponent('views.elements.RoomAliasField'); + let privateLabel; let publicLabel; + let aliasField; if (this.state.isPublic) { publicLabel = (

{_t("Set a room alias to easily share your room with other people.")}

); + const domain = MatrixClientPeg.get().getDomain(); + aliasField = ( +
+ this._aliasFieldRef = ref} onChange={this.onAliasChange} domain={domain} /> +
+ ); } else { privateLabel = (

{_t("This room is private, and can only be joined by invitation.")}

); } @@ -139,6 +157,7 @@ export default createReactClass({ { privateLabel } { publicLabel } + { aliasField }
{ this.state.detailsOpen ? _t('Hide advanced') : _t('Show advanced') }