Correct eslint offences

This commit is contained in:
David Taylor 2017-08-02 11:33:50 +01:00
parent c634b3ee65
commit 4932c078ed
13 changed files with 50 additions and 70 deletions

View File

@ -1,5 +1,4 @@
import buildPluginAdapter from 'admin/adapters/build-plugin';
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
export default buildPluginAdapter('chat').extend({

View File

@ -12,25 +12,25 @@ export default Ember.Component.extend({
if (result) {
channel.destroyRecord().then(() => {
this.send('refresh');
}).catch(popupAjaxError)
}).catch(popupAjaxError);
}
});
},
edit(channel){
this.sendAction('edit', channel)
this.sendAction('edit', channel);
},
test(channel){
this.sendAction('test', channel)
this.sendAction('test', channel);
},
createRule(channel){
this.sendAction('createRule', channel)
this.sendAction('createRule', channel);
},
editRule(rule){
this.sendAction('editRule', rule, this.get('channel'))
this.sendAction('editRule', rule, this.get('channel'));
},
showError(error_key){

View File

@ -4,31 +4,29 @@ export default Ember.Component.extend({
tagName: 'tr',
isCategory: function(){
return this.get('rule.type') == 'normal'
return this.get('rule.type') === 'normal';
}.property('rule.type'),
isMessage: function(){
return this.get('rule.type') == 'group_message'
return this.get('rule.type') === 'group_message';
}.property('rule.type'),
isMention: function(){
return this.get('rule.type') == 'group_mention'
return this.get('rule.type') === 'group_mention';
}.property('rule.type'),
actions: {
edit: function(){
this.sendAction('edit', this.get('rule'))
this.sendAction('edit', this.get('rule'));
},
delete(rule){
rule.destroyRecord().then(() => {
this.send('refresh');
}).catch(popupAjaxError)
}).catch(popupAjaxError);
},
refresh: function(){
this.sendAction('refresh');
}
}
});

View File

@ -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 { popupAjaxError } from 'discourse/lib/ajax-error';
export default Ember.Controller.extend({
modalShowing: false,
@ -31,7 +26,7 @@ export default Ember.Controller.extend({
},
testChannel(channel){
this.set('modalShowing', true);
var model = {channel:channel}
var model = {channel:channel};
showModal('admin-plugins-chat-test', { model: model, admin: true });
},

View File

@ -1,6 +1,4 @@
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import { ajax } from 'discourse/lib/ajax';
import { extractError } from 'discourse/lib/ajax-error';
import InputValidation from 'discourse/models/input-validation';
@ -29,11 +27,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
var regex = new RegExp(regString);
var val = this.get('model.channel.data.'+parameter.key);
if(val==undefined){
if(val===undefined){
val = "";
}
if(val == ""){ // Fail silently if field blank
if(val === ""){ // Fail silently if field blank
return InputValidation.create({
failed: true,
});
@ -56,7 +54,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
},
_paramValidation: function(){
var response = {}
var response = {};
var parameters = this.get('model.provider.channel_parameters');
parameters.forEach(parameter => {
response[parameter.key] = this.validate(parameter);
@ -67,7 +65,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
saveDisabled: function(){
var validations = this.get('paramValidation');
if(!validations){ return true }
if(!validations){ return true; }
var invalid = false;
@ -89,11 +87,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
},
save: function(){
if(this.get('saveDisabled')){return};
if(this.get('saveDisabled')){return;};
const self = this;
this.get('model.channel').save().then(function(result) {
this.get('model.channel').save().then(function() {
self.send('closeModal');
}).catch(function(error) {
self.flash(extractError(error), 'error');

View File

@ -1,8 +1,5 @@
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import { ajax } from 'discourse/lib/ajax';
import { extractError } from 'discourse/lib/ajax-error';
import InputValidation from 'discourse/models/input-validation';
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(ModalFunctionality, {
@ -22,7 +19,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
@computed('model.rule.type')
showCategory: function(type){
return (type == "normal")
return (type === "normal");
},
actions: {
@ -31,11 +28,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
},
save: function(){
if(this.get('saveDisabled')){return};
if(this.get('saveDisabled')){return;};
const self = this;
this.get('model.rule').save().then(function(result) {
this.get('model.rule').save().then(function() {
self.send('closeModal');
}).catch(function(error) {
self.flash(extractError(error), 'error');

View File

@ -14,15 +14,15 @@ export default Ember.Controller.extend(ModalFunctionality, {
sendDisabled: function(){
if(this.get('model').topic_id){
return false
return false;
}
return true
return true;
}.property('model.topic_id'),
actions: {
send: function(){
if(this.get('sendDisabled')){return};
if(this.get('sendDisabled')){return;};
self = this;
this.set('loading', true);
ajax("/admin/plugins/chat/test", {
@ -30,17 +30,17 @@ export default Ember.Controller.extend(ModalFunctionality, {
topic_id: this.get('model.topic_id')
},
type: 'POST'
}).then(function (result) {
self.set('loading', false)
}).then(function () {
self.set('loading', false);
self.flash(I18n.t('chat_integration.test_modal.success'), 'success');
}, function(e) {
self.set('loading', false);
var response = e.jqXHR.responseJSON
var error_key = 'chat_integration.test_modal.error'
var response = e.jqXHR.responseJSON;
var error_key = 'chat_integration.test_modal.error';
if(response['error_key']){
error_key = response['error_key']
error_key = response['error_key'];
}
self.flash(I18n.t(error_key), 'error');

View File

@ -1,6 +1,4 @@
import RestModel from 'discourse/models/rest';
import Category from 'discourse/models/category';
import computed from "ember-addons/ember-computed-decorators";
export default RestModel.extend({

View File

@ -25,7 +25,7 @@ export default RestModel.extend({
removeUnneededInfo: function(){
const type=this.get('type');
if(type=='normal'){
if(type==='normal'){
this.set('group_id', null);
}else{
this.set('category_id', null);

View File

@ -1,7 +1,5 @@
import AdminPluginsChatProvider from 'discourse/plugins/discourse-chat-integration/admin/routes/admin-plugins-chat-provider'
export default Discourse.Route.extend({
afterModel(model, transition) {
afterModel(model) {
if(model.totalRows > 0){
this.transitionTo('adminPlugins.chat.provider', model.get('firstObject').name);

View File

@ -1,9 +1,8 @@
import { ajax } from 'discourse/lib/ajax';
import Group from 'discourse/models/group';
export default Discourse.Route.extend({
model(params, transition) {
model(params) {
return Ember.RSVP.hash({
channels: this.store.findAll('channel', {provider: 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')};
},
actions: {
closeModal: function(data){
closeModal: function(){
if(this.get('controller.modalShowing')){
this.refresh();
this.set('controller.modalShowing', false);
@ -36,7 +35,7 @@ export default Discourse.Route.extend({
return true; // Continue bubbling up, so the modal actually closes
},
refresh: function(data){
refresh: function(){
this.refresh();
}

View File

@ -1,7 +1,5 @@
import AdminPluginsChatProvider from 'discourse/plugins/discourse-chat-integration/admin/routes/admin-plugins-chat-provider'
export default Discourse.Route.extend({
model(params, transition) {
model() {
return this.store.findAll('provider');
},

View File

@ -10,34 +10,34 @@ acceptance("Chat Integration", {
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+$"}]}] });
});
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}]}]});
});
server.post('/admin/plugins/chat/channels', () => {
server.post('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef
return response({ });
});
server.put('/admin/plugins/chat/channels/:id', () => {
server.put('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef
return response({ });
});
server.delete('/admin/plugins/chat/channels/:id', () => {
server.delete('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef
return response({ });
});
server.post('/admin/plugins/chat/rules', () => {
server.post('/admin/plugins/chat/rules', () => { // eslint-disable-line no-undef
return response({ });
});
server.put('/admin/plugins/chat/rules/:id', () => {
server.put('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef
return response({ });
});
server.delete('/admin/plugins/chat/rules/:id', () => {
server.delete('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef
return response({ });
});
server.post('/admin/plugins/chat/test', () => {
server.post('/admin/plugins/chat/test', () => { // eslint-disable-line no-undef
return response({ });
});
server.get('/groups/search.json', () => {
server.get('/groups/search.json', () => { // eslint-disable-line no-undef
return response([]);
});
@ -69,7 +69,7 @@ test("Create channel works", assert => {
andThen(() => {
assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
})
});
andThen(() => {
click('#save_channel');
@ -77,7 +77,7 @@ test("Create channel works", assert => {
andThen(() => {
assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
})
});
});
@ -166,6 +166,6 @@ test("Test provider works", assert => {
andThen(() => {
assert.ok(exists('#chat_integration_test_modal'), 'modal doesn\'t close on send');
assert.ok(exists('#modal-alert.alert-success'), 'success message displayed');
})
});
});