discourse/app/assets/javascripts/admin/controllers/modals/admin-suspend-user.js.es6

41 lines
1.1 KiB
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import computed from "ember-addons/ember-computed-decorators";
import PenaltyController from "admin/mixins/penalty-controller";
2014-08-13 07:04:36 +08:00
export default Ember.Controller.extend(PenaltyController, {
suspendUntil: null,
2017-09-15 02:10:39 +08:00
suspending: false,
onShow() {
this.resetModal();
this.setProperties({ suspendUntil: null, suspending: false });
},
2018-06-15 23:03:24 +08:00
@computed("suspendUntil", "reason", "suspending")
2017-09-15 02:10:39 +08:00
submitDisabled(suspendUntil, reason, suspending) {
2018-06-15 23:03:24 +08:00
return (
suspending || Ember.isEmpty(suspendUntil) || !reason || reason.length < 1
);
},
actions: {
suspend() {
2018-06-15 23:03:24 +08:00
if (this.get("submitDisabled")) {
return;
}
2018-06-15 23:03:24 +08:00
this.set("suspending", true);
this.penalize(() => {
2018-06-15 23:03:24 +08:00
return this.get("user").suspend({
suspend_until: this.get("suspendUntil"),
reason: this.get("reason"),
message: this.get("message"),
post_id: this.get("post.id"),
post_action: this.get("postAction"),
post_edit: this.get("postEdit")
});
2018-06-15 23:03:24 +08:00
}).finally(() => this.set("suspending", false));
}
}
});