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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
JavaScript
Raw Normal View History

import Controller from "@ember/controller";
import PenaltyController from "admin/mixins/penalty-controller";
import discourseComputed from "discourse-common/utils/decorators";
import { isEmpty } from "@ember/utils";
2014-08-12 19:04:36 -04:00
export default Controller.extend(PenaltyController, {
suspendUntil: null,
2017-09-14 14:10:39 -04:00
suspending: false,
onShow() {
this.resetModal();
this.setProperties({ suspendUntil: null, suspending: false });
},
@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;
},
actions: {
suspend() {
if (this.submitDisabled) {
return;
}
2017-09-14 14:10:39 -04: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,
});
}).finally(() => this.set("suspending", false));
},
},
});