mirror of
https://github.com/discourse/discourse-chat-integration.git
synced 2025-03-09 14:35:34 +00:00
Providers can define their own errors, and these are presented in the user interface. e.g. Slack can define an error that says “That channel doesn’t exist”. Errors in the UI disappear once a message has been sent successfully, or the rule is edited.
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
|
|
import { ajax } from 'discourse/lib/ajax';
|
|
import computed from "ember-addons/ember-computed-decorators";
|
|
import showModal from 'discourse/lib/show-modal';
|
|
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
|
|
|
|
|
export default Ember.Controller.extend({
|
|
modalShowing: false,
|
|
|
|
anyErrors: function(){
|
|
var anyErrors = false;
|
|
this.get('model.rules').forEach(function(rule){
|
|
if(rule.error_key){
|
|
anyErrors = true;
|
|
}
|
|
});
|
|
return anyErrors;
|
|
}.property('model.rules'),
|
|
|
|
actions:{
|
|
create(){
|
|
this.set('modalShowing', true);
|
|
var model = {rule: this.store.createRecord('rule',{provider: this.get('model.provider').id}), provider:this.get('model.provider')};
|
|
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
|
|
},
|
|
edit(rule){
|
|
this.set('modalShowing', true);
|
|
var model = {rule: rule, provider:this.get('model.provider')};
|
|
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
|
|
},
|
|
delete(rule){
|
|
const self = this;
|
|
rule.destroyRecord().then(function() {
|
|
self.send('refresh');
|
|
}).catch(popupAjaxError)
|
|
},
|
|
showError(error_key){
|
|
bootbox.alert(I18n.t(error_key));
|
|
}
|
|
|
|
}
|
|
|
|
}); |