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

40 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";
export default Ember.Controller.extend(PenaltyController, {
silenceUntil: null,
silencing: false,
onShow() {
this.resetModal();
this.setProperties({ silenceUntil: null, silencing: false });
},
2018-06-15 23:03:24 +08:00
@computed("silenceUntil", "reason", "silencing")
submitDisabled(silenceUntil, reason, silencing) {
2018-06-15 23:03:24 +08:00
return (
silencing || Ember.isEmpty(silenceUntil) || !reason || reason.length < 1
);
},
actions: {
silence() {
2018-06-15 23:03:24 +08:00
if (this.get("submitDisabled")) {
return;
}
2018-06-15 23:03:24 +08:00
this.set("silencing", true);
this.penalize(() => {
2018-06-15 23:03:24 +08:00
return this.get("user").silence({
silenced_till: this.get("silenceUntil"),
reason: this.get("reason"),
message: this.get("message"),
post_id: this.get("postId"),
2018-06-15 23:03:24 +08:00
post_action: this.get("postAction"),
post_edit: this.get("postEdit")
});
2018-06-15 23:03:24 +08:00
}).finally(() => this.set("silencing", false));
}
}
});