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.
This commit is contained in:
David Baker 2017-09-22 19:27:02 +01:00
parent 86ceef712d
commit af73f1c3bb
2 changed files with 81 additions and 12 deletions

View file

@ -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({
</div>;
},
_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 <div className="mx_GroupView_membershipSection">
@ -677,7 +700,45 @@ export default React.createClass({
if (this.state.summary.user && this.state.summary.user.is_privileged) {
youAreAMemberText = _t("You are an administrator of this group");
}
let publicisedButton;
if (this.state.publicityBusy) {
publicisedButton = <Spinner />;
}
let publicisedSection;
if (this.state.summary.user && this.state.summary.user.is_public) {
if (!this.state.publicityBusy) {
publicisedButton = <AccessibleButton className="mx_GroupView_textButton mx_RoomHeader_textButton"
onClick={this._onPubliciseOffClick}
>
{_t("Make private")}
</AccessibleButton>;
}
publicisedSection = <div className="mx_GroupView_membershipSubSection">
{_t("Your membership of this group is public")}
<div className="mx_GroupView_membership_buttonContainer">
{publicisedButton}
</div>
</div>;
} else {
if (!this.state.publicityBusy) {
publicisedButton = <AccessibleButton className="mx_GroupView_textButton mx_RoomHeader_textButton"
onClick={this._onPubliciseOnClick}
>
{_t("Make public")}
</AccessibleButton>
}
publicisedSection = <div className="mx_GroupView_membershipSubSection">
{_t("Your membership of this group is private")}
<div className="mx_GroupView_membership_buttonContainer">
{publicisedButton}
</div>
</div>;
}
return <div className="mx_GroupView_membershipSection mx_GroupView_membershipSection_joined">
<div className="mx_GroupView_membershipSubSection">
<div className="mx_GroupView_membershipSection_description">
{youAreAMemberText}
</div>
@ -688,6 +749,8 @@ export default React.createClass({
{_t("Leave")}
</AccessibleButton>
</div>
</div>
{publicisedSection}
</div>;
}

View file

@ -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"
}