FEATURE: Support an end date for user silencing

This commit is contained in:
Robin Ward
2017-11-13 13:41:36 -05:00
parent 52480d554a
commit 971e302ff2
33 changed files with 456 additions and 114 deletions

View File

@ -0,0 +1,50 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import computed from 'ember-addons/ember-computed-decorators';
import { popupAjaxError } from 'discourse/lib/ajax-error';
export default Ember.Controller.extend(ModalFunctionality, {
silenceUntil: null,
reason: null,
message: null,
silencing: false,
user: null,
post: null,
successCallback: null,
onShow() {
this.setProperties({
silenceUntil: null,
reason: null,
message: null,
silencing: false,
loadingUser: true,
post: null,
successCallback: null,
});
},
@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.get('user').silence({
silenced_till: this.get('silenceUntil'),
reason: this.get('reason'),
message: this.get('message'),
post_id: this.get('post.id')
}).then(result => {
this.send('closeModal');
let callback = this.get('successCallback');
if (callback) {
callback(result);
}
}).catch(popupAjaxError).finally(() => this.set('silencing', false));
}
}
});