From edc744067fb857715fd4aba99d399050d021ad68 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 7 Nov 2017 18:51:41 +0000 Subject: [PATCH] Add checkbox to GroupAddressPicker for determining visibility of group rooms --- src/GroupAddressPicker.js | 24 ++++++++++++------- src/components/structures/GroupView.js | 2 +- .../views/dialogs/AddressPickerDialog.js | 3 +++ src/i18n/strings/en_EN.json | 2 +- src/stores/GroupStore.js | 6 +++++ 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/GroupAddressPicker.js b/src/GroupAddressPicker.js index 595f0cfe46..c4b3744575 100644 --- a/src/GroupAddressPicker.js +++ b/src/GroupAddressPicker.js @@ -49,20 +49,26 @@ export function showGroupInviteDialog(groupId) { export function showGroupAddRoomDialog(groupId) { return new Promise((resolve, reject) => { + let addRoomsPublicly = false; + const onCheckboxClicked = (e) => { + addRoomsPublicly = e.target.checked; + }; const description =
{ _t("Which rooms would you like to add to this community?") }
-
- { _t( - "Warning: any room you add to a community will be publicly "+ - "visible to anyone who knows the community ID", - ) } -
; + const checkboxContainer = ; + const AddressPickerDialog = sdk.getComponent("dialogs.AddressPickerDialog"); Modal.createTrackedDialog('Add Rooms to Group', '', AddressPickerDialog, { title: _t("Add rooms to the community"), description: description, + extraNode: checkboxContainer, placeholder: _t("Room name or alias"), button: _t("Add to community"), pickerType: 'room', @@ -70,7 +76,7 @@ export function showGroupAddRoomDialog(groupId) { onFinished: (success, addrs) => { if (!success) return; - _onGroupAddRoomFinished(groupId, addrs).then(resolve, reject); + _onGroupAddRoomFinished(groupId, addrs, addRoomsPublicly).then(resolve, reject); }, }); }); @@ -106,13 +112,13 @@ function _onGroupInviteFinished(groupId, addrs) { }); } -function _onGroupAddRoomFinished(groupId, addrs) { +function _onGroupAddRoomFinished(groupId, addrs, addRoomsPublicly) { const matrixClient = MatrixClientPeg.get(); const groupStore = GroupStoreCache.getGroupStore(matrixClient, groupId); const errorList = []; return Promise.all(addrs.map((addr) => { return groupStore - .addRoomToGroup(addr.address) + .addRoomToGroup(addr.address, addRoomsPublicly) .catch(() => { errorList.push(addr.address); }) .then(() => { const roomId = addr.address; diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 795efaec1e..dee433551f 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -575,7 +575,7 @@ export default React.createClass({ _onAcceptInviteClick: function() { this.setState({membershipBusy: true}); - MatrixClientPeg.get().acceptGroupInvite(this.props.groupId).then(() => { + this._groupStore.acceptGroupInvite().then(() => { // don't reset membershipBusy here: wait for the membership change to come down the sync }).catch((e) => { this.setState({membershipBusy: false}); diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 5796e60cc9..8de76ebfa8 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -34,6 +34,8 @@ module.exports = React.createClass({ propTypes: { title: PropTypes.string.isRequired, description: PropTypes.node, + // Extra node inserted after picker input, dropdown and errors + extraNode: PropTypes.node, value: PropTypes.string, placeholder: PropTypes.string, roomId: PropTypes.string, @@ -574,6 +576,7 @@ module.exports = React.createClass({
{ query }
{ error } { addressSelector } + { this.props.extraNode }