i edited the suspend extension as you suggested, but the extension list in the admin panel wont come up at all after installing the extension, and will show when i uninstall the extension.
main.js
import { extend } from 'flarum/extend';
import app from 'flarum/app';
import DiscussionControls from 'flarum/utils/DiscussionControls';
import Button from 'flarum/components/Button';
import Badge from 'flarum/components/Badge';
import Model from 'flarum/Model';
//import User from 'flarum/models/User';
import Discussion from 'flarum/models/Discussion';
import SuspendUserModal from 'flarum/suspend/components/SuspendUserModal';
app.initializers.add('flarum-suspend', () => {
Discussion.prototype.frontpage = Model.attribute('frontpage');
extend(DiscussionControls, 'moderationControls', (items, discussion) => {
//if (!discussion.frontpage()) {
items.add('suspend', Button.component({
children: app.translator.trans('flarum-suspend.forum.user_controls.suspend_button'),
icon: 'fa fa-ban',
onclick: () => app.modal.show(new SuspendUserModal({discussion}))
}));
//}
});
});
SuspendUserModal.js
import Modal from 'flarum/components/Modal';
import Button from 'flarum/components/Button';
export default class SuspendUserModal extends Modal {
init() {
super.init();
let frontpage = this.props.discussion.frontpage();
let status = null;
if (frontpage) {
status = '1';
}else{
status = '0';
}
this.status = m.prop(status);
}
className() {
return 'SuspendUserModal Modal--small';
}
title() {
return app.translator.trans('flarum-suspend.forum.suspend_user.title', {user: this.props.user});
}
content() {
return (
<div className="Modal-body">
<div className="Form">
<div className="Form-group">
<label>Frontpage</label>
<div>
<label className="checkbox">
<input type="radio" name="status" checked={this.status() === '1'} value="1" onclick={m.withAttr('value', this.status)}/>
Add frontpage
</label>
<label className="checkbox">
<input type="radio" name="status" checked={this.status() === '0'} value='0' onclick={m.withAttr('value', this.status)}/>
Remove frontpage
</label>
</div>
</div>
<div className="Form-group">
<Button className="Button Button--primary" loading={this.loading} type="submit">
submit
</Button>
</div>
</div>
</div>
);
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
let frontdate = null;
let frontpage =null;
let d = new Date();
switch (this.status()) {
case '1':
frontdate = [d.getDate(), d.getMonth()+1, d.getFullYear()].join('/');
frontpage = 1;
break;
case '0':
frontdate = null;
frontpage = 0;
break;
default:
// no default
}
this.props.discussion.save({frontpage}).then(
() => this.hide(),
this.loaded.bind(this)
);
}
}