mirror of
https://github.com/flarum/core.git
synced 2025-08-08 09:26:34 +02:00
update: forum/utils/UserControls
This commit is contained in:
committed by
Franz Liedke
parent
b9ba5b63f1
commit
5c49b71c02
@@ -22,10 +22,10 @@ export default {
|
||||
const items = new ItemList();
|
||||
|
||||
['user', 'moderation', 'destructive'].forEach((section) => {
|
||||
const controls = this[section + 'Controls'](user, context).toArray();
|
||||
const controls = this[section](user, context).toArray();
|
||||
if (controls.length) {
|
||||
controls.forEach((item) => items.add(item.itemName, item));
|
||||
items.add(section + 'Separator', Separator.component());
|
||||
items.add(section + 'Separator', <Separator />);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ export default {
|
||||
* @return {ItemList}
|
||||
* @protected
|
||||
*/
|
||||
userControls() {
|
||||
user() {
|
||||
return new ItemList();
|
||||
},
|
||||
|
||||
@@ -54,17 +54,15 @@ export default {
|
||||
* @return {ItemList}
|
||||
* @protected
|
||||
*/
|
||||
moderationControls(user) {
|
||||
moderation(user) {
|
||||
const items = new ItemList();
|
||||
|
||||
if (user.canEdit()) {
|
||||
items.add(
|
||||
'edit',
|
||||
Button.component({
|
||||
icon: 'fas fa-pencil-alt',
|
||||
children: app.translator.trans('core.forum.user_controls.edit_button'),
|
||||
onclick: this.editAction.bind(this, user),
|
||||
})
|
||||
<Button icon="fas fa-pencil-alt" onclick={this.editAction.bind(this, user)}>
|
||||
{app.translator.trans('core.forum.user_controls.edit_button')}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,17 +78,15 @@ export default {
|
||||
* @return {ItemList}
|
||||
* @protected
|
||||
*/
|
||||
destructiveControls(user) {
|
||||
destructive(user) {
|
||||
const items = new ItemList();
|
||||
|
||||
if (user.id() !== '1' && user.canDelete()) {
|
||||
items.add(
|
||||
'delete',
|
||||
Button.component({
|
||||
icon: 'fas fa-times',
|
||||
children: app.translator.trans('core.forum.user_controls.delete_button'),
|
||||
onclick: this.deleteAction.bind(this, user),
|
||||
})
|
||||
<Button icon="fas fa-times" onclick={this.deleteAction.bind(this, user)}>
|
||||
{app.translator.trans('core.forum.user_controls.delete_button')}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user