Determine user card editing permissions in one place

This commit is contained in:
Toby Zerner 2015-08-05 16:22:05 +09:30
parent 5005e37cfb
commit 3f0089e8bb
3 changed files with 4 additions and 18 deletions

View File

@ -184,11 +184,6 @@ export default class PermissionGrid extends Component {
permission: 'discussion.delete'
});
items.add('suspendUsers', {
label: 'Suspend users',
permission: 'user.suspend'
});
return items;
}

View File

@ -4,7 +4,7 @@ import classList from 'flarum/utils/classList';
/**
* The `UserBio` component displays a user's bio, optionally letting the user
* edit it (if they have permission).
* edit it.
*/
export default class UserBio extends Component {
constructor(...args) {
@ -51,7 +51,7 @@ export default class UserBio extends Component {
return (
<div className={'UserBio ' + classList({
editable: this.isEditable(),
editable: this.props.editable,
editing: this.editing
})}
onclick={this.edit.bind(this)}>
@ -60,20 +60,11 @@ export default class UserBio extends Component {
);
}
/**
* Check whether or not the bio can be edited.
*
* @return {Boolean}
*/
isEditable() {
return this.props.user.canEdit() && this.props.editable;
}
/**
* Edit the bio.
*/
edit() {
if (!this.isEditable()) return;
if (!this.props.editable) return;
this.editing = true;
m.redraw();

View File

@ -39,7 +39,7 @@ export default class UserPage extends Component {
UserCard.component({
user: this.user,
className: 'Hero UserHero',
editable: this.user.canEdit(),
editable: this.user.canEdit() || this.user === app.session.user,
controlsButtonClassName: 'Button'
}),
<div className="container">