mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 23:24:04 +08:00
b58867b6e9
Includes support for flags, reviewable users and queued posts, with REST API backwards compatibility. Co-Authored-By: romanrizzi <romanalejandro@gmail.com> Co-Authored-By: jjaffeux <j.jaffeux@gmail.com>
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
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 });
|
|
},
|
|
|
|
@computed("silenceUntil", "reason", "silencing")
|
|
submitDisabled(silenceUntil, reason, silencing) {
|
|
return (
|
|
silencing || Ember.isEmpty(silenceUntil) || !reason || reason.length < 1
|
|
);
|
|
},
|
|
|
|
actions: {
|
|
silence() {
|
|
if (this.get("submitDisabled")) {
|
|
return;
|
|
}
|
|
|
|
this.set("silencing", true);
|
|
this.penalize(() => {
|
|
return this.get("user").silence({
|
|
silenced_till: this.get("silenceUntil"),
|
|
reason: this.get("reason"),
|
|
message: this.get("message"),
|
|
post_id: this.get("postId"),
|
|
post_action: this.get("postAction"),
|
|
post_edit: this.get("postEdit")
|
|
});
|
|
}).finally(() => this.set("silencing", false));
|
|
}
|
|
}
|
|
});
|