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

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

40 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";
export default Controller.extend(PenaltyController, {
silenceUntil: null,
silencing: false,
onShow() {
this.resetModal();
this.setProperties({ silenceUntil: null, silencing: false });
},
@discourseComputed("silenceUntil", "reason", "silencing")
submitDisabled(silenceUntil, reason, silencing) {
2019-11-02 01:57:22 +08:00
return silencing || isEmpty(silenceUntil) || !reason || reason.length < 1;
},
actions: {
silence() {
if (this.submitDisabled) {
return;
}
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,
});
}).finally(() => this.set("silencing", false));
},
},
});