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

52 lines
1.3 KiB
Plaintext
Raw Normal View History

2014-08-12 19:04:36 -04:00
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import computed from 'ember-addons/ember-computed-decorators';
import { popupAjaxError } from 'discourse/lib/ajax-error';
2014-08-12 19:04:36 -04:00
export default Ember.Controller.extend(ModalFunctionality, {
suspendUntil: null,
reason: null,
message: null,
2017-09-14 14:10:39 -04:00
suspending: false,
user: null,
post: null,
successCallback: null,
onShow() {
this.setProperties({
suspendUntil: null,
reason: null,
message: null,
2017-09-14 14:10:39 -04:00
suspending: false,
loadingUser: true,
post: null,
successCallback: null,
});
},
2017-09-14 14:10:39 -04:00
@computed('suspendUntil', 'reason', 'suspending')
submitDisabled(suspendUntil, reason, suspending) {
return (suspending || Ember.isEmpty(suspendUntil) || !reason || reason.length < 1);
},
actions: {
suspend() {
if (this.get('submitDisabled')) { return; }
2017-09-14 14:10:39 -04:00
this.set('suspending', true);
this.get('user').suspend({
suspend_until: this.get('suspendUntil'),
reason: this.get('reason'),
2017-09-14 14:10:39 -04:00
message: this.get('message'),
post_id: this.get('post.id')
}).then(result => {
this.send('closeModal');
2017-09-14 14:10:39 -04:00
let callback = this.get('successCallback');
if (callback) {
callback(result);
}
}).catch(popupAjaxError).finally(() => this.set('suspending', false));
}
}
});