Correct eslint offences
This commit is contained in:
parent
c634b3ee65
commit
4932c078ed
|
@ -1,5 +1,4 @@
|
||||||
import buildPluginAdapter from 'admin/adapters/build-plugin';
|
import buildPluginAdapter from 'admin/adapters/build-plugin';
|
||||||
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
|
|
||||||
|
|
||||||
export default buildPluginAdapter('chat').extend({
|
export default buildPluginAdapter('chat').extend({
|
||||||
|
|
||||||
|
|
|
@ -12,25 +12,25 @@ export default Ember.Component.extend({
|
||||||
if (result) {
|
if (result) {
|
||||||
channel.destroyRecord().then(() => {
|
channel.destroyRecord().then(() => {
|
||||||
this.send('refresh');
|
this.send('refresh');
|
||||||
}).catch(popupAjaxError)
|
}).catch(popupAjaxError);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
edit(channel){
|
edit(channel){
|
||||||
this.sendAction('edit', channel)
|
this.sendAction('edit', channel);
|
||||||
},
|
},
|
||||||
|
|
||||||
test(channel){
|
test(channel){
|
||||||
this.sendAction('test', channel)
|
this.sendAction('test', channel);
|
||||||
},
|
},
|
||||||
|
|
||||||
createRule(channel){
|
createRule(channel){
|
||||||
this.sendAction('createRule', channel)
|
this.sendAction('createRule', channel);
|
||||||
},
|
},
|
||||||
|
|
||||||
editRule(rule){
|
editRule(rule){
|
||||||
this.sendAction('editRule', rule, this.get('channel'))
|
this.sendAction('editRule', rule, this.get('channel'));
|
||||||
},
|
},
|
||||||
|
|
||||||
showError(error_key){
|
showError(error_key){
|
||||||
|
|
|
@ -4,31 +4,29 @@ export default Ember.Component.extend({
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
isCategory: function(){
|
isCategory: function(){
|
||||||
return this.get('rule.type') == 'normal'
|
return this.get('rule.type') === 'normal';
|
||||||
}.property('rule.type'),
|
}.property('rule.type'),
|
||||||
|
|
||||||
isMessage: function(){
|
isMessage: function(){
|
||||||
return this.get('rule.type') == 'group_message'
|
return this.get('rule.type') === 'group_message';
|
||||||
}.property('rule.type'),
|
}.property('rule.type'),
|
||||||
|
|
||||||
isMention: function(){
|
isMention: function(){
|
||||||
return this.get('rule.type') == 'group_mention'
|
return this.get('rule.type') === 'group_mention';
|
||||||
}.property('rule.type'),
|
}.property('rule.type'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
edit: function(){
|
edit: function(){
|
||||||
this.sendAction('edit', this.get('rule'))
|
this.sendAction('edit', this.get('rule'));
|
||||||
},
|
},
|
||||||
delete(rule){
|
delete(rule){
|
||||||
rule.destroyRecord().then(() => {
|
rule.destroyRecord().then(() => {
|
||||||
this.send('refresh');
|
this.send('refresh');
|
||||||
}).catch(popupAjaxError)
|
}).catch(popupAjaxError);
|
||||||
},
|
},
|
||||||
refresh: function(){
|
refresh: function(){
|
||||||
this.sendAction('refresh');
|
this.sendAction('refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -1,9 +1,4 @@
|
||||||
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 showModal from 'discourse/lib/show-modal';
|
||||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
|
||||||
|
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
modalShowing: false,
|
modalShowing: false,
|
||||||
|
@ -31,7 +26,7 @@ export default Ember.Controller.extend({
|
||||||
},
|
},
|
||||||
testChannel(channel){
|
testChannel(channel){
|
||||||
this.set('modalShowing', true);
|
this.set('modalShowing', true);
|
||||||
var model = {channel:channel}
|
var model = {channel:channel};
|
||||||
showModal('admin-plugins-chat-test', { model: model, admin: true });
|
showModal('admin-plugins-chat-test', { model: model, admin: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
|
|
||||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||||
import { ajax } from 'discourse/lib/ajax';
|
|
||||||
import { extractError } from 'discourse/lib/ajax-error';
|
import { extractError } from 'discourse/lib/ajax-error';
|
||||||
import InputValidation from 'discourse/models/input-validation';
|
import InputValidation from 'discourse/models/input-validation';
|
||||||
|
|
||||||
|
@ -29,11 +27,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
var regex = new RegExp(regString);
|
var regex = new RegExp(regString);
|
||||||
var val = this.get('model.channel.data.'+parameter.key);
|
var val = this.get('model.channel.data.'+parameter.key);
|
||||||
|
|
||||||
if(val==undefined){
|
if(val===undefined){
|
||||||
val = "";
|
val = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(val == ""){ // Fail silently if field blank
|
if(val === ""){ // Fail silently if field blank
|
||||||
return InputValidation.create({
|
return InputValidation.create({
|
||||||
failed: true,
|
failed: true,
|
||||||
});
|
});
|
||||||
|
@ -56,7 +54,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
},
|
},
|
||||||
|
|
||||||
_paramValidation: function(){
|
_paramValidation: function(){
|
||||||
var response = {}
|
var response = {};
|
||||||
var parameters = this.get('model.provider.channel_parameters');
|
var parameters = this.get('model.provider.channel_parameters');
|
||||||
parameters.forEach(parameter => {
|
parameters.forEach(parameter => {
|
||||||
response[parameter.key] = this.validate(parameter);
|
response[parameter.key] = this.validate(parameter);
|
||||||
|
@ -67,7 +65,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
saveDisabled: function(){
|
saveDisabled: function(){
|
||||||
var validations = this.get('paramValidation');
|
var validations = this.get('paramValidation');
|
||||||
|
|
||||||
if(!validations){ return true }
|
if(!validations){ return true; }
|
||||||
|
|
||||||
var invalid = false;
|
var invalid = false;
|
||||||
|
|
||||||
|
@ -89,11 +87,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function(){
|
save: function(){
|
||||||
if(this.get('saveDisabled')){return};
|
if(this.get('saveDisabled')){return;};
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
this.get('model.channel').save().then(function(result) {
|
this.get('model.channel').save().then(function() {
|
||||||
self.send('closeModal');
|
self.send('closeModal');
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
self.flash(extractError(error), 'error');
|
self.flash(extractError(error), 'error');
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
|
|
||||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||||
import { ajax } from 'discourse/lib/ajax';
|
|
||||||
import { extractError } from 'discourse/lib/ajax-error';
|
import { extractError } from 'discourse/lib/ajax-error';
|
||||||
import InputValidation from 'discourse/models/input-validation';
|
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
|
@ -22,7 +19,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
|
|
||||||
@computed('model.rule.type')
|
@computed('model.rule.type')
|
||||||
showCategory: function(type){
|
showCategory: function(type){
|
||||||
return (type == "normal")
|
return (type === "normal");
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -31,11 +28,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function(){
|
save: function(){
|
||||||
if(this.get('saveDisabled')){return};
|
if(this.get('saveDisabled')){return;};
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
this.get('model.rule').save().then(function(result) {
|
this.get('model.rule').save().then(function() {
|
||||||
self.send('closeModal');
|
self.send('closeModal');
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
self.flash(extractError(error), 'error');
|
self.flash(extractError(error), 'error');
|
||||||
|
|
|
@ -14,15 +14,15 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
|
|
||||||
sendDisabled: function(){
|
sendDisabled: function(){
|
||||||
if(this.get('model').topic_id){
|
if(this.get('model').topic_id){
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
return true
|
return true;
|
||||||
}.property('model.topic_id'),
|
}.property('model.topic_id'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
send: function(){
|
send: function(){
|
||||||
if(this.get('sendDisabled')){return};
|
if(this.get('sendDisabled')){return;};
|
||||||
self = this;
|
self = this;
|
||||||
this.set('loading', true);
|
this.set('loading', true);
|
||||||
ajax("/admin/plugins/chat/test", {
|
ajax("/admin/plugins/chat/test", {
|
||||||
|
@ -30,17 +30,17 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
topic_id: this.get('model.topic_id')
|
topic_id: this.get('model.topic_id')
|
||||||
},
|
},
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
}).then(function (result) {
|
}).then(function () {
|
||||||
self.set('loading', false)
|
self.set('loading', false);
|
||||||
self.flash(I18n.t('chat_integration.test_modal.success'), 'success');
|
self.flash(I18n.t('chat_integration.test_modal.success'), 'success');
|
||||||
}, function(e) {
|
}, function(e) {
|
||||||
self.set('loading', false);
|
self.set('loading', false);
|
||||||
|
|
||||||
var response = e.jqXHR.responseJSON
|
var response = e.jqXHR.responseJSON;
|
||||||
var error_key = 'chat_integration.test_modal.error'
|
var error_key = 'chat_integration.test_modal.error';
|
||||||
|
|
||||||
if(response['error_key']){
|
if(response['error_key']){
|
||||||
error_key = response['error_key']
|
error_key = response['error_key'];
|
||||||
}
|
}
|
||||||
self.flash(I18n.t(error_key), 'error');
|
self.flash(I18n.t(error_key), 'error');
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import RestModel from 'discourse/models/rest';
|
import RestModel from 'discourse/models/rest';
|
||||||
import Category from 'discourse/models/category';
|
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
|
||||||
|
|
||||||
export default RestModel.extend({
|
export default RestModel.extend({
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default RestModel.extend({
|
||||||
|
|
||||||
removeUnneededInfo: function(){
|
removeUnneededInfo: function(){
|
||||||
const type=this.get('type');
|
const type=this.get('type');
|
||||||
if(type=='normal'){
|
if(type==='normal'){
|
||||||
this.set('group_id', null);
|
this.set('group_id', null);
|
||||||
}else{
|
}else{
|
||||||
this.set('category_id', null);
|
this.set('category_id', null);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import AdminPluginsChatProvider from 'discourse/plugins/discourse-chat-integration/admin/routes/admin-plugins-chat-provider'
|
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
afterModel(model, transition) {
|
afterModel(model) {
|
||||||
|
|
||||||
if(model.totalRows > 0){
|
if(model.totalRows > 0){
|
||||||
this.transitionTo('adminPlugins.chat.provider', model.get('firstObject').name);
|
this.transitionTo('adminPlugins.chat.provider', model.get('firstObject').name);
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { ajax } from 'discourse/lib/ajax';
|
|
||||||
import Group from 'discourse/models/group';
|
import Group from 'discourse/models/group';
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
|
|
||||||
model(params, transition) {
|
model(params) {
|
||||||
return Ember.RSVP.hash({
|
return Ember.RSVP.hash({
|
||||||
channels: this.store.findAll('channel', {provider: params.provider}),
|
channels: this.store.findAll('channel', {provider: params.provider}),
|
||||||
provider: this.modelFor("admin-plugins-chat").findBy('id',params.provider),
|
provider: this.modelFor("admin-plugins-chat").findBy('id',params.provider),
|
||||||
|
@ -22,12 +21,12 @@ export default Discourse.Route.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
serialize: function(model, params) {
|
serialize: function(model) {
|
||||||
return { provider: model['provider'].get('id')};
|
return { provider: model['provider'].get('id')};
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
closeModal: function(data){
|
closeModal: function(){
|
||||||
if(this.get('controller.modalShowing')){
|
if(this.get('controller.modalShowing')){
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.set('controller.modalShowing', false);
|
this.set('controller.modalShowing', false);
|
||||||
|
@ -36,7 +35,7 @@ export default Discourse.Route.extend({
|
||||||
return true; // Continue bubbling up, so the modal actually closes
|
return true; // Continue bubbling up, so the modal actually closes
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(data){
|
refresh: function(){
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import AdminPluginsChatProvider from 'discourse/plugins/discourse-chat-integration/admin/routes/admin-plugins-chat-provider'
|
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
model(params, transition) {
|
model() {
|
||||||
return this.store.findAll('provider');
|
return this.store.findAll('provider');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -10,34 +10,34 @@ acceptance("Chat Integration", {
|
||||||
object
|
object
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
server.get('/admin/plugins/chat/providers', () => {
|
server.get('/admin/plugins/chat/providers', () => { // eslint-disable-line no-undef
|
||||||
return response({ providers: [{name: 'dummy', id:'dummy',channel_parameters:[{key:'somekey', regex:"^\\S+$"}]}] });
|
return response({ providers: [{name: 'dummy', id:'dummy',channel_parameters:[{key:'somekey', regex:"^\\S+$"}]}] });
|
||||||
});
|
});
|
||||||
server.get('/admin/plugins/chat/channels', () => {
|
server.get('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef
|
||||||
return response({"channels":[{"id":97,"provider":"dummy","data":{val:"#general"},"rules":[{"id":98,"channel_id":97,"category_id":null,"tags":[],"filter":"watch","error_key":null}]}]});
|
return response({"channels":[{"id":97,"provider":"dummy","data":{val:"#general"},"rules":[{"id":98,"channel_id":97,"category_id":null,"tags":[],"filter":"watch","error_key":null}]}]});
|
||||||
});
|
});
|
||||||
server.post('/admin/plugins/chat/channels', () => {
|
server.post('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef
|
||||||
return response({ });
|
return response({ });
|
||||||
});
|
});
|
||||||
server.put('/admin/plugins/chat/channels/:id', () => {
|
server.put('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef
|
||||||
return response({ });
|
return response({ });
|
||||||
});
|
});
|
||||||
server.delete('/admin/plugins/chat/channels/:id', () => {
|
server.delete('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef
|
||||||
return response({ });
|
return response({ });
|
||||||
});
|
});
|
||||||
server.post('/admin/plugins/chat/rules', () => {
|
server.post('/admin/plugins/chat/rules', () => { // eslint-disable-line no-undef
|
||||||
return response({ });
|
return response({ });
|
||||||
});
|
});
|
||||||
server.put('/admin/plugins/chat/rules/:id', () => {
|
server.put('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef
|
||||||
return response({ });
|
return response({ });
|
||||||
});
|
});
|
||||||
server.delete('/admin/plugins/chat/rules/:id', () => {
|
server.delete('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef
|
||||||
return response({ });
|
return response({ });
|
||||||
});
|
});
|
||||||
server.post('/admin/plugins/chat/test', () => {
|
server.post('/admin/plugins/chat/test', () => { // eslint-disable-line no-undef
|
||||||
return response({ });
|
return response({ });
|
||||||
});
|
});
|
||||||
server.get('/groups/search.json', () => {
|
server.get('/groups/search.json', () => { // eslint-disable-line no-undef
|
||||||
return response([]);
|
return response([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ test("Create channel works", assert => {
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
|
assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
|
||||||
})
|
});
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
click('#save_channel');
|
click('#save_channel');
|
||||||
|
@ -77,7 +77,7 @@ test("Create channel works", assert => {
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
|
assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
|
||||||
})
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -166,6 +166,6 @@ test("Test provider works", assert => {
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(exists('#chat_integration_test_modal'), 'modal doesn\'t close on send');
|
assert.ok(exists('#chat_integration_test_modal'), 'modal doesn\'t close on send');
|
||||||
assert.ok(exists('#modal-alert.alert-success'), 'success message displayed');
|
assert.ok(exists('#modal-alert.alert-success'), 'success message displayed');
|
||||||
})
|
});
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue