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

42 lines
1.1 KiB
Plaintext
Raw Normal View History

import { isEmpty } from "@ember/utils";
import Controller from "@ember/controller";
2018-06-15 11:03:24 -04:00
import computed from "ember-addons/ember-computed-decorators";
import PenaltyController from "admin/mixins/penalty-controller";
export default Controller.extend(PenaltyController, {
silenceUntil: null,
silencing: false,
onShow() {
this.resetModal();
this.setProperties({ silenceUntil: null, silencing: false });
},
2018-06-15 11:03:24 -04:00
@computed("silenceUntil", "reason", "silencing")
submitDisabled(silenceUntil, reason, silencing) {
2018-06-15 11:03:24 -04:00
return (
silencing || isEmpty(silenceUntil) || !reason || reason.length < 1
2018-06-15 11:03:24 -04:00
);
},
actions: {
silence() {
if (this.submitDisabled) {
2018-06-15 11:03:24 -04:00
return;
}
2018-06-15 11:03:24 -04:00
this.set("silencing", true);
this.penalize(() => {
return this.user.silence({
silenced_till: this.silenceUntil,
reason: this.reason,
message: this.message,
post_id: this.postId,
post_action: this.postAction,
post_edit: this.postEdit
});
2018-06-15 11:03:24 -04:00
}).finally(() => this.set("silencing", false));
}
}
});