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();
|
const items = new ItemList();
|
||||||
|
|
||||||
['user', 'moderation', 'destructive'].forEach((section) => {
|
['user', 'moderation', 'destructive'].forEach((section) => {
|
||||||
const controls = this[section + 'Controls'](user, context).toArray();
|
const controls = this[section](user, context).toArray();
|
||||||
if (controls.length) {
|
if (controls.length) {
|
||||||
controls.forEach((item) => items.add(item.itemName, item));
|
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}
|
* @return {ItemList}
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
userControls() {
|
user() {
|
||||||
return new ItemList();
|
return new ItemList();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -54,17 +54,15 @@ export default {
|
|||||||
* @return {ItemList}
|
* @return {ItemList}
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
moderationControls(user) {
|
moderation(user) {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
if (user.canEdit()) {
|
if (user.canEdit()) {
|
||||||
items.add(
|
items.add(
|
||||||
'edit',
|
'edit',
|
||||||
Button.component({
|
<Button icon="fas fa-pencil-alt" onclick={this.editAction.bind(this, user)}>
|
||||||
icon: 'fas fa-pencil-alt',
|
{app.translator.trans('core.forum.user_controls.edit_button')}
|
||||||
children: app.translator.trans('core.forum.user_controls.edit_button'),
|
</Button>
|
||||||
onclick: this.editAction.bind(this, user),
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,17 +78,15 @@ export default {
|
|||||||
* @return {ItemList}
|
* @return {ItemList}
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
destructiveControls(user) {
|
destructive(user) {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
if (user.id() !== '1' && user.canDelete()) {
|
if (user.id() !== '1' && user.canDelete()) {
|
||||||
items.add(
|
items.add(
|
||||||
'delete',
|
'delete',
|
||||||
Button.component({
|
<Button icon="fas fa-times" onclick={this.deleteAction.bind(this, user)}>
|
||||||
icon: 'fas fa-times',
|
{app.translator.trans('core.forum.user_controls.delete_button')}
|
||||||
children: app.translator.trans('core.forum.user_controls.delete_button'),
|
</Button>
|
||||||
onclick: this.deleteAction.bind(this, user),
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user