Merge pull request #1191 from matrix-org/t3chguy/room-settings-unban-no-pl
only show unban button in RoomSettings if user has sufficient PL to do so
This commit is contained in:
commit
2aa5a3a09c
1 changed files with 12 additions and 6 deletions
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue