Merge pull request #1559 from matrix-org/luke/fix-block-group-settings-if-non-member

Prevent non-members from opening group settings
This commit is contained in:
Luke Barnard 2017-10-31 11:47:18 +00:00 committed by GitHub
commit a7170ef73c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -460,6 +460,9 @@ export default React.createClass({
summary, summary,
isGroupPublicised: this._groupStore.getGroupPublicity(), isGroupPublicised: this._groupStore.getGroupPublicity(),
isUserPrivileged: this._groupStore.isUserPrivileged(), isUserPrivileged: this._groupStore.isUserPrivileged(),
isUserMember: this._groupStore.getGroupMembers().some(
(m) => m.userId === MatrixClientPeg.get().credentials.userId,
),
error: null, error: null,
}); });
}); });
@ -928,27 +931,28 @@ export default React.createClass({
tabIndex="2" tabIndex="2"
dir="auto" />; dir="auto" />;
} else { } else {
const onGroupHeaderItemClick = this.state.isUserMember ? this._onEditClick : null;
const groupAvatarUrl = summary.profile ? summary.profile.avatar_url : null; const groupAvatarUrl = summary.profile ? summary.profile.avatar_url : null;
const groupName = summary.profile ? summary.profile.name : null; const groupName = summary.profile ? summary.profile.name : null;
avatarNode = <GroupAvatar avatarNode = <GroupAvatar
groupId={this.props.groupId} groupId={this.props.groupId}
groupAvatarUrl={groupAvatarUrl} groupAvatarUrl={groupAvatarUrl}
groupName={groupName} groupName={groupName}
onClick={this._onEditClick} onClick={onGroupHeaderItemClick}
width={48} height={48} width={48} height={48}
/>; />;
if (summary.profile && summary.profile.name) { if (summary.profile && summary.profile.name) {
nameNode = <div onClick={this._onEditClick}> nameNode = <div onClick={onGroupHeaderItemClick}>
<span>{ summary.profile.name }</span> <span>{ summary.profile.name }</span>
<span className="mx_GroupView_header_groupid"> <span className="mx_GroupView_header_groupid">
({ this.props.groupId }) ({ this.props.groupId })
</span> </span>
</div>; </div>;
} else { } else {
nameNode = <span onClick={this._onEditClick}>{ this.props.groupId }</span>; nameNode = <span onClick={onGroupHeaderItemClick}>{ this.props.groupId }</span>;
} }
if (summary.profile && summary.profile.short_description) { if (summary.profile && summary.profile.short_description) {
shortDescNode = <span onClick={this._onEditClick}>{ summary.profile.short_description }</span>; shortDescNode = <span onClick={onGroupHeaderItemClick}>{ summary.profile.short_description }</span>;
} }
} }
if (this.state.editing) { if (this.state.editing) {
@ -989,6 +993,7 @@ export default React.createClass({
const headerClasses = { const headerClasses = {
mx_GroupView_header: true, mx_GroupView_header: true,
mx_GroupView_header_view: !this.state.editing, mx_GroupView_header_view: !this.state.editing,
mx_GroupView_header_isUserMember: this.state.isUserMember,
}; };
return ( return (