From af73f1c3bb41735d67b9e194f23f68149d9c08ac Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 22 Sep 2017 19:27:02 +0100 Subject: [PATCH 1/2] Add status & toggle for publicity This doesn't work at the moment because it looks like it's broken in synapse as per https://github.com/matrix-org/sytest/pull/391 But if it did work, the client side code might look something like this. --- src/components/structures/GroupView.js | 85 ++++++++++++++++++++++---- src/i18n/strings/en_EN.json | 8 ++- 2 files changed, 81 insertions(+), 12 deletions(-) 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" } From 1a82f121c09f1fc20230f4a60a10fa3f42b72fae Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 25 Sep 2017 13:17:07 +0100 Subject: [PATCH 2/2] lint --- src/components/structures/GroupView.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index f74e3d60dd..0a8bfaee38 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -671,7 +671,6 @@ export default React.createClass({ if (!group) return null; if (group.myMembership === 'invite') { - if (this.state.membershipBusy) { return
@@ -727,7 +726,7 @@ export default React.createClass({ onClick={this._onPubliciseOnClick} > {_t("Make public")} - + ; } publicisedSection =
{_t("Your membership of this group is private")}