diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js
index 7c8ef80b80..26f8c4a413 100644
--- a/src/components/structures/GroupView.js
+++ b/src/components/structures/GroupView.js
@@ -458,6 +458,8 @@ export default React.createClass({
}
this.setState({
summary,
+ isGroupPublicised: this._groupStore.getGroupPublicity(),
+ isUserPrivileged: this._groupStore.isUserPrivileged(),
error: null,
});
});
@@ -606,22 +608,15 @@ export default React.createClass({
});
},
- _onPubliciseOffClick: function() {
- this._setPublicity(false);
- },
-
- _onPubliciseOnClick: function() {
- this._setPublicity(true);
- },
-
_onAddRoomsClick: function() {
showGroupAddRoomDialog(this.props.groupId);
},
- _setPublicity: function(publicity) {
+ _onPublicityToggle: function() {
this.setState({
publicityBusy: true,
});
+ const publicity = !this.state.isGroupPublicised;
this._groupStore.setGroupPublicity(publicity).then(() => {
this.setState({
publicityBusy: false,
@@ -745,100 +740,113 @@ export default React.createClass({
;
}
-
return
-
- { _t("%(inviter)s has invited you to join this group", {inviter: group.inviter.userId}) }
-
-
-
- { _t("Accept") }
-
-
- { _t("Decline") }
-
-
-
;
- } else if (group.myMembership === 'join') {
- let youAreAMemberText = _t("You are a member of this group");
- 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 = ;
- }
-
- let publicisedSection;
- if (this.state.summary.user && this.state.summary.user.is_publicised) {
- if (!this.state.publicityBusy) {
- publicisedButton =
- { _t("Unpublish") }
- ;
- }
- publicisedSection =
- { _t("This group is published on your profile") }
-
- { publicisedButton }
-
-
;
- } else {
- if (!this.state.publicityBusy) {
- publicisedButton =
- { _t("Publish") }
- ;
- }
- publicisedSection =
- { _t("This group is not published on your profile") }
-
- { publicisedButton }
-
-
;
- }
-
- return
- { youAreAMemberText }
+ { _t("%(inviter)s has invited you to join this group", {inviter: group.inviter.userId}) }
+ { _t("Accept") }
+
+
+ { _t("Decline") }
+
+
+
+
;
+ } else if (group.myMembership === 'join' && this.state.editing) {
+ const leaveButtonTooltip = this.state.isUserPrivileged ?
+ _t("You are a member of this group") :
+ _t("You are an administrator of this group");
+ const leaveButtonClasses = classnames({
+ "mx_RoomHeader_textButton": true,
+ "mx_GroupView_textButton": true,
+ "mx_GroupView_leaveButton": true,
+ "mx_RoomHeader_textButton_danger": this.state.isUserPrivileged,
+ });
+ return
+
+ { /* Empty div for flex alignment */ }
+
+
- { publicisedSection }
;
}
-
return null;
},
+ _getMemberSettingsSection: function() {
+ return
+
{ _t("Community Member Settings") }
+
+
+
+ { _t("Publish this community on your profile") }
+
+
+
;
+ },
+
+ _getLongDescriptionNode: function() {
+ const summary = this.state.summary;
+ let description = null;
+ if (summary.profile && summary.profile.long_description) {
+ description = sanitizedHtmlNode(summary.profile.long_description);
+ }
+ return this.state.editing && this.state.isUserPrivileged ?
+
+
{ _t("Long Description (HTML)") }
+
+ :
+
+ { description }
+
;
+ },
+
render: function() {
const GroupAvatar = sdk.getComponent("avatars.GroupAvatar");
- const Loader = sdk.getComponent("elements.Spinner");
+ const Spinner = sdk.getComponent("elements.Spinner");
const TintableSvg = sdk.getComponent("elements.TintableSvg");
if (this.state.summary === null && this.state.error === null || this.state.saving) {
- return ;
+ return ;
} else if (this.state.summary) {
const summary = this.state.summary;
let avatarNode;
let nameNode;
let shortDescNode;
- let bodyNodes = [];
+ const bodyNodes = [
+ this._getMembershipSection(),
+ this.state.editing ? this._getMemberSettingsSection() : null,
+ this._getLongDescriptionNode(),
+ this._getRoomsNode(),
+ ];
const rightButtons = [];
const headerClasses = {
mx_GroupView_header: true,
@@ -846,7 +854,7 @@ export default React.createClass({
if (this.state.editing) {
let avatarImage;
if (this.state.uploadingAvatar) {
- avatarImage = ;
+ avatarImage = ;
} else {
const GroupAvatar = sdk.getComponent('avatars.GroupAvatar');
avatarImage =
,
);
- bodyNodes = [
- ,
- this._getRoomsNode(),
- ];
} else {
const groupAvatarUrl = summary.profile ? summary.profile.avatar_url : null;
avatarNode = { summary.profile.short_description };
}
-
- let description = null;
- if (summary.profile && summary.profile.long_description) {
- description = sanitizedHtmlNode(summary.profile.long_description);
- }
- bodyNodes = [
- this._getMembershipSection(),
- { description }
,
- this._getRoomsNode(),
- ];
- if (summary.user && summary.user.is_privileged) {
- rightButtons.push(
-
-
- ,
- );
- }
+ rightButtons.push(
+
+
+ ,
+ );
if (this.props.collapsedRhs) {
rightButtons.push(