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

41 lines
1.0 KiB
JavaScript
Raw Normal View History

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