only show unban button in RoomSettings if user has sufficient PL to do so

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-07-06 12:51:55 +01:00
parent b8dacd3bb1
commit c6d9ec42a2
No known key found for this signature in database
GPG key ID: 0435A1D4BBD34D64

View file

@ -39,6 +39,7 @@ function parseIntWithDefault(val, def) {
const BannedUser = React.createClass({ const BannedUser = React.createClass({
propTypes: { propTypes: {
canUnban: React.PropTypes.bool,
member: React.PropTypes.object.isRequired, // js-sdk RoomMember member: React.PropTypes.object.isRequired, // js-sdk RoomMember
reason: React.PropTypes.string, reason: React.PropTypes.string,
}, },
@ -67,13 +68,17 @@ const BannedUser = React.createClass({
}, },
render: function() { render: function() {
let unbanButton;
if (this.props.canUnban) {
unbanButton = <AccessibleButton className="mx_RoomSettings_unbanButton" onClick={this._onUnbanClick}>
{ _t('Unban') }
</AccessibleButton>;
}
return ( return (
<li> <li>
<AccessibleButton className="mx_RoomSettings_unbanButton" { unbanButton }
onClick={this._onUnbanClick}
>
{ _t('Unban') }
</AccessibleButton>
<strong>{this.props.member.name}</strong> {this.props.member.userId} <strong>{this.props.member.name}</strong> {this.props.member.userId}
{this.props.reason ? " " +_t('Reason') + ": " + this.props.reason : ""} {this.props.reason ? " " +_t('Reason') + ": " + this.props.reason : ""}
</li> </li>
@ -667,6 +672,7 @@ module.exports = React.createClass({
const banned = this.props.room.getMembersWithMembership("ban"); const banned = this.props.room.getMembersWithMembership("ban");
let bannedUsersSection; let bannedUsersSection;
if (banned.length) { if (banned.length) {
const canBanUsers = current_user_level >= ban_level;
bannedUsersSection = bannedUsersSection =
<div> <div>
<h3>{ _t('Banned users') }</h3> <h3>{ _t('Banned users') }</h3>
@ -674,7 +680,7 @@ module.exports = React.createClass({
{banned.map(function(member) { {banned.map(function(member) {
const banEvent = member.events.member.getContent(); const banEvent = member.events.member.getContent();
return ( return (
<BannedUser key={member.userId} member={member} reason={banEvent.reason} /> <BannedUser key={member.userId} canUnban={canBanUsers} member={member} reason={banEvent.reason} />
); );
})} })}
</ul> </ul>