mirror of
https://github.com/flarum/framework.git
synced 2025-05-23 23:29:57 +08:00
Determine user card editing permissions in one place
This commit is contained in:
@ -184,11 +184,6 @@ export default class PermissionGrid extends Component {
|
|||||||
permission: 'discussion.delete'
|
permission: 'discussion.delete'
|
||||||
});
|
});
|
||||||
|
|
||||||
items.add('suspendUsers', {
|
|
||||||
label: 'Suspend users',
|
|
||||||
permission: 'user.suspend'
|
|
||||||
});
|
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import classList from 'flarum/utils/classList';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The `UserBio` component displays a user's bio, optionally letting the user
|
* 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 {
|
export default class UserBio extends Component {
|
||||||
constructor(...args) {
|
constructor(...args) {
|
||||||
@ -51,7 +51,7 @@ export default class UserBio extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'UserBio ' + classList({
|
<div className={'UserBio ' + classList({
|
||||||
editable: this.isEditable(),
|
editable: this.props.editable,
|
||||||
editing: this.editing
|
editing: this.editing
|
||||||
})}
|
})}
|
||||||
onclick={this.edit.bind(this)}>
|
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 the bio.
|
||||||
*/
|
*/
|
||||||
edit() {
|
edit() {
|
||||||
if (!this.isEditable()) return;
|
if (!this.props.editable) return;
|
||||||
|
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
m.redraw();
|
m.redraw();
|
||||||
|
@ -39,7 +39,7 @@ export default class UserPage extends Component {
|
|||||||
UserCard.component({
|
UserCard.component({
|
||||||
user: this.user,
|
user: this.user,
|
||||||
className: 'Hero UserHero',
|
className: 'Hero UserHero',
|
||||||
editable: this.user.canEdit(),
|
editable: this.user.canEdit() || this.user === app.session.user,
|
||||||
controlsButtonClassName: 'Button'
|
controlsButtonClassName: 'Button'
|
||||||
}),
|
}),
|
||||||
<div className="container">
|
<div className="container">
|
||||||
|
Reference in New Issue
Block a user