diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 4f61bc4647..f74e3d60dd 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -379,6 +379,7 @@ export default React.createClass({ saving: false, uploadingAvatar: false, membershipBusy: false, + publicityBusy: false, }; }, @@ -560,7 +561,28 @@ export default React.createClass({ }); }, - _getFeaturedRoomsNode() { + _onPubliciseOffClick: function() { + this._setPublicity(false); + }, + + _onPubliciseOnClick: function() { + this._setPublicity(true); + }, + + _setPublicity: function(publicity) { + this.setState({ + publicityBusy: true, + }); + MatrixClientPeg.get().setGroupPublicity(this.props.groupId, publicity).then(() => { + this._loadGroupFromServer(this.props.groupId); + }).then(() => { + this.setState({ + publicityBusy: false, + }); + }); + }, + + _getFeaturedRoomsNode: function() { const summary = this.state.summary; const defaultCategoryRooms = []; @@ -601,7 +623,7 @@ export default React.createClass({ ; }, - _getFeaturedUsersNode() { + _getFeaturedUsersNode: function() { const summary = this.state.summary; const noRoleUsers = []; @@ -643,11 +665,12 @@ export default React.createClass({ }, _getMembershipSection: function() { + const Spinner = sdk.getComponent("elements.Spinner"); + const group = MatrixClientPeg.get().getGroup(this.props.groupId); if (!group) return null; if (group.myMembership === 'invite') { - const Spinner = sdk.getComponent("elements.Spinner"); if (this.state.membershipBusy) { return
@@ -677,17 +700,57 @@ export default React.createClass({ if (this.state.summary.user && this.state.summary.user.is_privileged) { youAreAMemberText = _t("You are an administrator of this group"); } - return
-
- {youAreAMemberText} -
-
- ; + } + + let publicisedSection; + if (this.state.summary.user && this.state.summary.user.is_public) { + if (!this.state.publicityBusy) { + publicisedButton = + {_t("Make private")} + ; + } + publicisedSection =
+ {_t("Your membership of this group is public")} +
+ {publicisedButton} +
+
; + } else { + if (!this.state.publicityBusy) { + publicisedButton = - {_t("Leave")} + {_t("Make public")} + } + publicisedSection =
+ {_t("Your membership of this group is private")} +
+ {publicisedButton} +
+
; + } + + return
+
+
+ {youAreAMemberText} +
+
+ + {_t("Leave")} + +
+ {publicisedSection}
; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index a0945d7f50..1a775299ea 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -879,5 +879,11 @@ "Failed to remove the room from the summary of %(groupId)s": "Failed to remove the room from the summary of %(groupId)s", "The room '%(roomName)' could not be removed from the summary.": "The room '%(roomName)' could not be removed from the summary.", "Failed to remove a user from the summary of %(groupId)s": "Failed to remove a user from the summary of %(groupId)s", - "The user '%(displayName)s' could not be removed from the summary.": "The user '%(displayName)s' could not be removed from the summary." + "The user '%(displayName)s' could not be removed from the summary.": "The user '%(displayName)s' could not be removed from the summary.", + "Failed to add the following rooms to the summary of %(groupId)s:": "Failed to add the following rooms to the summary of %(groupId)s:", + "The room '%(roomName)s' could not be removed from the summary.": "The room '%(roomName)s' could not be removed from the summary.", + "Your membership of this group is public": "Your membership of this group is public", + "Your membership of this group is private": "Your membership of this group is private", + "Make private": "Make private", + "Make public": "Make public" }