From f42cdf6a4c55bc07e893844604ec0820d3a2f533 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 29 Mar 2018 16:57:07 +0100 Subject: [PATCH 1/3] Add radio button for setting group is_joinable which dictates whether the group can be joined without invitation. --- src/components/structures/GroupView.js | 54 ++++++++++++++++++++++++-- src/i18n/strings/en_EN.json | 2 + 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 2b5b3d5353..d1f5de0b95 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -545,6 +545,9 @@ export default React.createClass({ this.setState({ editing: true, profileForm: Object.assign({}, this.state.summary.profile), + joinableForm: { + isJoinable: this.state.summary.profile.is_joinable, + }, }); dis.dispatch({ action: 'panel_disable', @@ -607,11 +610,15 @@ export default React.createClass({ }).done(); }, + _onJoinableChange: function(ev) { + this.setState({ + joinableForm: { isJoinable: ev.target.value === "true" }, + }); + }, + _onSaveClick: function() { this.setState({saving: true}); - const savePromise = this.state.isUserPrivileged ? - this._matrixClient.setGroupProfile(this.props.groupId, this.state.profileForm) : - Promise.resolve(); + const savePromise = this.state.isUserPrivileged ? this._saveGroup() : Promise.resolve(); savePromise.then((result) => { this.setState({ saving: false, @@ -642,6 +649,11 @@ export default React.createClass({ }).done(); }, + _saveGroup: async function() { + await this._matrixClient.setGroupProfile(this.props.groupId, this.state.profileForm); + await this._matrixClient.setGroupJoinable(this.props.groupId, this.state.joinableForm.isJoinable); + }, + _onAcceptInviteClick: function() { this.setState({membershipBusy: true}); this._groupStore.acceptGroupInvite().then(() => { @@ -715,6 +727,7 @@ export default React.createClass({ return
{ header } { changeDelayWarning } + { this._getJoinableNode() } { this._getLongDescriptionNode() } { this._getRoomsNode() }
; @@ -925,6 +938,41 @@ export default React.createClass({ return null; }, + _getJoinableNode: function() { + return this.state.editing ?
+

+ { _t('Who can join this community?') } + { this.state.groupJoinableLoading ? + :
+ } +

+
+ +
+
+ +
+
: null; + }, + _getLongDescriptionNode: function() { const summary = this.state.summary; let description = null; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 2d3ef836e0..6be80bbf4f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -776,6 +776,8 @@ "%(inviter)s has invited you to join this community": "%(inviter)s has invited you to join this community", "You are an administrator of this community": "You are an administrator of this community", "You are a member of this community": "You are a member of this community", + "Who can join this community?": "Who can join this community?", + "Everyone": "Everyone", "Your community hasn't got a Long Description, a HTML page to show to community members.
Click here to open settings and give it one!": "Your community hasn't got a Long Description, a HTML page to show to community members.
Click here to open settings and give it one!", "Long Description (HTML)": "Long Description (HTML)", "Description": "Description", From 2bc8d6d3a41f31e9c485621331379a48b14283f6 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 29 Mar 2018 17:25:06 +0100 Subject: [PATCH 2/3] Use less confusing values on radio buttons --- src/components/structures/GroupView.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index d1f5de0b95..0be9ffb77a 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -399,6 +399,9 @@ FeaturedRoom.contextTypes = GroupContext; RoleUserList.contextTypes = GroupContext; FeaturedUser.contextTypes = GroupContext; +const GROUP_JOINABLE = "GROUP_JOINABLE"; +const GROUP_NOT_JOINABLE = "GROUP_NOT_JOINABLE"; + export default React.createClass({ displayName: 'GroupView', @@ -612,7 +615,7 @@ export default React.createClass({ _onJoinableChange: function(ev) { this.setState({ - joinableForm: { isJoinable: ev.target.value === "true" }, + joinableForm: { isJoinable: ev.target.value === GROUP_JOINABLE }, }); }, @@ -949,7 +952,7 @@ export default React.createClass({