2019-11-07 16:38:28 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-31 13:37:24 -04:00
|
|
|
import { isEmpty } from "@ember/utils";
|
2019-10-23 13:06:54 -04:00
|
|
|
import Controller from "@ember/controller";
|
2018-01-30 16:31:29 -05:00
|
|
|
import PenaltyController from "admin/mixins/penalty-controller";
|
2014-08-12 19:04:36 -04:00
|
|
|
|
2019-10-23 13:06:54 -04:00
|
|
|
export default Controller.extend(PenaltyController, {
|
2017-09-13 16:44:47 -04:00
|
|
|
suspendUntil: null,
|
2017-09-14 14:10:39 -04:00
|
|
|
suspending: false,
|
2013-11-01 10:47:03 -04:00
|
|
|
|
2017-09-13 14:11:33 -04:00
|
|
|
onShow() {
|
2018-01-30 16:31:29 -05:00
|
|
|
this.resetModal();
|
|
|
|
this.setProperties({ suspendUntil: null, suspending: false });
|
2017-09-13 14:11:33 -04:00
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("suspendUntil", "reason", "suspending")
|
2017-09-14 14:10:39 -04:00
|
|
|
submitDisabled(suspendUntil, reason, suspending) {
|
2019-11-01 13:57:22 -04:00
|
|
|
return suspending || isEmpty(suspendUntil) || !reason || reason.length < 1;
|
2017-09-13 14:11:33 -04:00
|
|
|
},
|
2014-02-04 11:03:35 -05:00
|
|
|
|
2013-11-01 10:47:03 -04:00
|
|
|
actions: {
|
2017-09-13 14:11:33 -04:00
|
|
|
suspend() {
|
2019-05-27 04:15:39 -04:00
|
|
|
if (this.submitDisabled) {
|
2017-09-13 14:11:33 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-14 14:10:39 -04:00
|
|
|
this.set("suspending", true);
|
2018-01-30 16:31:29 -05:00
|
|
|
|
|
|
|
this.penalize(() => {
|
2019-05-27 04:15:39 -04:00
|
|
|
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-01-30 16:31:29 -05:00
|
|
|
});
|
|
|
|
}).finally(() => this.set("suspending", false));
|
2013-11-01 10:47:03 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|