mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 00:43:54 +08:00
Determine user card editing permissions in one place
This commit is contained in:
parent
5005e37cfb
commit
3f0089e8bb
|
@ -184,11 +184,6 @@ export default class PermissionGrid extends Component {
|
|||
permission: 'discussion.delete'
|
||||
});
|
||||
|
||||
items.add('suspendUsers', {
|
||||
label: 'Suspend users',
|
||||
permission: 'user.suspend'
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue
Block a user