mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: eslint deprecations
This commit is contained in:
parent
946e34f65c
commit
b0541500b4
23 changed files with 59 additions and 70 deletions
|
@ -1,12 +1,3 @@
|
||||||
/**
|
|
||||||
This controller supports the interface for granting and revoking badges from
|
|
||||||
individual users.
|
|
||||||
|
|
||||||
@class AdminUserBadgesController
|
|
||||||
@extends Ember.ArrayController
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
export default Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
needs: ["adminUser"],
|
needs: ["adminUser"],
|
||||||
user: Em.computed.alias('controllers.adminUser'),
|
user: Em.computed.alias('controllers.adminUser'),
|
||||||
|
@ -14,12 +5,12 @@ export default Ember.ArrayController.extend({
|
||||||
sortAscending: false,
|
sortAscending: false,
|
||||||
|
|
||||||
groupedBadges: function(){
|
groupedBadges: function(){
|
||||||
const badges = this.get('model');
|
const allBadges = this.get('model');
|
||||||
|
|
||||||
var grouped = _.groupBy(badges, badge => badge.badge_id);
|
var grouped = _.groupBy(allBadges, badge => badge.badge_id);
|
||||||
|
|
||||||
var expanded = [];
|
var expanded = [];
|
||||||
const expandedBadges = badges.get('expandedBadges');
|
const expandedBadges = allBadges.get('expandedBadges');
|
||||||
|
|
||||||
_(grouped).each(function(badges){
|
_(grouped).each(function(badges){
|
||||||
var lastGranted = badges[0].granted_at;
|
var lastGranted = badges[0].granted_at;
|
||||||
|
|
|
@ -8,8 +8,8 @@ export default Ember.Component.extend({
|
||||||
const filterMode = this.get('filterMode'),
|
const filterMode = this.get('filterMode'),
|
||||||
navItems = this.get('navItems');
|
navItems = this.get('navItems');
|
||||||
|
|
||||||
var item = navItems.find(function(item){
|
var item = navItems.find(function(i){
|
||||||
return item.get('filterMode').indexOf(filterMode) === 0;
|
return i.get('filterMode').indexOf(filterMode) === 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
return item || navItems[0];
|
return item || navItems[0];
|
||||||
|
|
|
@ -45,8 +45,8 @@ export default Ember.Component.extend({
|
||||||
this.rerender();
|
this.rerender();
|
||||||
});
|
});
|
||||||
|
|
||||||
on('th.sortable', function(e){
|
on('th.sortable', function(e2){
|
||||||
this.sendAction('changeSort', e.data('sort-order'));
|
this.sendAction('changeSort', e2.data('sort-order'));
|
||||||
this.rerender();
|
this.rerender();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ Em.Handlebars.helper('bound-avatar', function(user, size, uploadId) {
|
||||||
/*
|
/*
|
||||||
* Used when we only have a template
|
* Used when we only have a template
|
||||||
*/
|
*/
|
||||||
Em.Handlebars.helper('bound-avatar-template', function(avatarTemplate, size) {
|
Em.Handlebars.helper('bound-avatar-template', function(at, size) {
|
||||||
return new safe(Discourse.Utilities.avatarImg({ size: size, avatarTemplate: avatarTemplate }));
|
return new safe(Discourse.Utilities.avatarImg({ size: size, avatarTemplate: at }));
|
||||||
});
|
});
|
||||||
|
|
||||||
registerUnbound('raw-date', function(dt) {
|
registerUnbound('raw-date', function(dt) {
|
||||||
|
|
|
@ -12,8 +12,8 @@ export default {
|
||||||
const messageBus = container.lookup('message-bus:main');
|
const messageBus = container.lookup('message-bus:main');
|
||||||
if (!messageBus) { return; }
|
if (!messageBus) { return; }
|
||||||
|
|
||||||
messageBus.subscribe("/site/banner", function (banner) {
|
messageBus.subscribe("/site/banner", function (ban) {
|
||||||
site.set("banner", Em.Object.create(banner));
|
site.set("banner", Em.Object.create(ban));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@ var dummy = document.createElement("div"),
|
||||||
ms: "MSTransitionEnd"
|
ms: "MSTransitionEnd"
|
||||||
};
|
};
|
||||||
|
|
||||||
var transitionEnd = function() {
|
var transitionEnd = (function() {
|
||||||
var retValue;
|
var retValue;
|
||||||
retValue = "transitionend";
|
retValue = "transitionend";
|
||||||
Object.keys(eventNameHash).some(function(vendor) {
|
Object.keys(eventNameHash).some(function(vendor) {
|
||||||
|
@ -22,7 +22,7 @@ var transitionEnd = function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return retValue;
|
return retValue;
|
||||||
}();
|
})();
|
||||||
|
|
||||||
export default function (element, callback) {
|
export default function (element, callback) {
|
||||||
return $(element).on(transitionEnd, callback);
|
return $(element).on(transitionEnd, callback);
|
||||||
|
|
|
@ -290,7 +290,7 @@ export default function(options) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(this).on('keydown.autocomplete', function(e) {
|
$(this).on('keydown.autocomplete', function(e) {
|
||||||
var c, caretPosition, i, initial, next, prev, prevIsGood, stopFound, term, total, userToComplete;
|
var c, caretPosition, i, initial, prev, prevIsGood, stopFound, term, total, userToComplete;
|
||||||
|
|
||||||
if(e.ctrlKey || e.altKey || e.metaKey){
|
if(e.ctrlKey || e.altKey || e.metaKey){
|
||||||
return true;
|
return true;
|
||||||
|
@ -322,7 +322,6 @@ export default function(options) {
|
||||||
if (e.which === keys.shift) return;
|
if (e.which === keys.shift) return;
|
||||||
if ((completeStart === null) && e.which === keys.backSpace && options.key) {
|
if ((completeStart === null) && e.which === keys.backSpace && options.key) {
|
||||||
c = Discourse.Utilities.caretPosition(me[0]);
|
c = Discourse.Utilities.caretPosition(me[0]);
|
||||||
next = me[0].value[c];
|
|
||||||
c -= 1;
|
c -= 1;
|
||||||
initial = c;
|
initial = c;
|
||||||
prevIsGood = true;
|
prevIsGood = true;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*eslint no-bitwise:0 */
|
||||||
let _splitAvatars;
|
let _splitAvatars;
|
||||||
|
|
||||||
function defaultAvatar(username) {
|
function defaultAvatar(username) {
|
||||||
|
|
|
@ -186,8 +186,8 @@ var bindEvents = function(page,offset){
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.emoji-modal .toolbar a').click(function(){
|
$('.emoji-modal .toolbar a').click(function(){
|
||||||
var page = parseInt($(this).data('group-id'));
|
var p = parseInt($(this).data('group-id'));
|
||||||
render(page,0);
|
render(p, 0);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -234,12 +234,12 @@ const PostStream = RestModel.extend({
|
||||||
this.set('gaps', this.get('gaps') || {before: {}, after: {}});
|
this.set('gaps', this.get('gaps') || {before: {}, after: {}});
|
||||||
const before = this.get('gaps.before');
|
const before = this.get('gaps.before');
|
||||||
|
|
||||||
const post = posts.find(function(post){
|
const post = posts.find(function(p){
|
||||||
return post.get('post_number') > to;
|
return p.get('post_number') > to;
|
||||||
});
|
});
|
||||||
|
|
||||||
before[post.get('id')] = remove.map(function(post){
|
before[post.get('id')] = remove.map(function(p){
|
||||||
return post.get('id');
|
return p.get('id');
|
||||||
});
|
});
|
||||||
post.set('hasGap', true);
|
post.set('hasGap', true);
|
||||||
|
|
||||||
|
@ -491,8 +491,8 @@ const PostStream = RestModel.extend({
|
||||||
|
|
||||||
// we need to zip this into the stream
|
// we need to zip this into the stream
|
||||||
let index = 0;
|
let index = 0;
|
||||||
stream.forEach(function(postId){
|
stream.forEach(function(pid){
|
||||||
if(postId < p.id){
|
if (pid < p.id){
|
||||||
index+= 1;
|
index+= 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||||
import ActionSummary from 'discourse/models/action-summary';
|
import ActionSummary from 'discourse/models/action-summary';
|
||||||
import { url, fmt, propertyEqual } from 'discourse/lib/computed';
|
import { url, fmt, propertyEqual } from 'discourse/lib/computed';
|
||||||
import Quote from 'discourse/lib/quote';
|
import Quote from 'discourse/lib/quote';
|
||||||
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
const Post = RestModel.extend({
|
const Post = RestModel.extend({
|
||||||
|
|
||||||
|
@ -54,10 +55,10 @@ const Post = RestModel.extend({
|
||||||
}.property('post_number', 'topic_id', 'topic.slug'),
|
}.property('post_number', 'topic_id', 'topic.slug'),
|
||||||
|
|
||||||
// Don't drop the /1
|
// Don't drop the /1
|
||||||
urlWithNumber: function() {
|
@computed('post_number', 'url')
|
||||||
const url = this.get('url');
|
urlWithNumber(postNumber, postUrl) {
|
||||||
return (this.get('post_number') === 1) ? url + "/1" : url;
|
return postNumber === 1 ? postUrl + "/1" : postUrl;
|
||||||
}.property('post_number', 'url'),
|
},
|
||||||
|
|
||||||
usernameUrl: url('username', '/users/%@'),
|
usernameUrl: url('username', '/users/%@'),
|
||||||
|
|
||||||
|
|
|
@ -54,18 +54,18 @@ export default RestModel.extend({
|
||||||
findItems() {
|
findItems() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
let url = this.get('baseUrl');
|
let findUrl = this.get('baseUrl');
|
||||||
if (this.get('filterParam')) {
|
if (this.get('filterParam')) {
|
||||||
url += "&filter=" + this.get('filterParam');
|
findUrl += "&filter=" + this.get('filterParam');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't load the same stream twice. We're probably at the end.
|
// Don't load the same stream twice. We're probably at the end.
|
||||||
const lastLoadedUrl = this.get('lastLoadedUrl');
|
const lastLoadedUrl = this.get('lastLoadedUrl');
|
||||||
if (lastLoadedUrl === url) { return Ember.RSVP.resolve(); }
|
if (lastLoadedUrl === findUrl) { return Ember.RSVP.resolve(); }
|
||||||
|
|
||||||
if (this.get('loading')) { return Ember.RSVP.resolve(); }
|
if (this.get('loading')) { return Ember.RSVP.resolve(); }
|
||||||
this.set('loading', true);
|
this.set('loading', true);
|
||||||
return Discourse.ajax(url, {cache: 'false'}).then( function(result) {
|
return Discourse.ajax(findUrl, {cache: 'false'}).then( function(result) {
|
||||||
if (result && result.user_actions) {
|
if (result && result.user_actions) {
|
||||||
const copy = Em.A();
|
const copy = Em.A();
|
||||||
result.user_actions.forEach(function(action) {
|
result.user_actions.forEach(function(action) {
|
||||||
|
@ -81,7 +81,7 @@ export default RestModel.extend({
|
||||||
}
|
}
|
||||||
}).finally(function() {
|
}).finally(function() {
|
||||||
self.set('loading', false);
|
self.set('loading', false);
|
||||||
self.set('lastLoadedUrl', url);
|
self.set('lastLoadedUrl', findUrl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import UserStream from 'discourse/models/user-stream';
|
||||||
import UserPostsStream from 'discourse/models/user-posts-stream';
|
import UserPostsStream from 'discourse/models/user-posts-stream';
|
||||||
import Singleton from 'discourse/mixins/singleton';
|
import Singleton from 'discourse/mixins/singleton';
|
||||||
import { longDate } from 'discourse/lib/formatter';
|
import { longDate } from 'discourse/lib/formatter';
|
||||||
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
const User = RestModel.extend({
|
const User = RestModel.extend({
|
||||||
|
|
||||||
|
@ -53,17 +54,11 @@ const User = RestModel.extend({
|
||||||
return this.get('username');
|
return this.get('username');
|
||||||
}.property('username', 'name'),
|
}.property('username', 'name'),
|
||||||
|
|
||||||
/**
|
@computed('profile_background')
|
||||||
This user's profile background(in CSS).
|
profileBackground(bgUrl) {
|
||||||
|
if (Em.isEmpty(bgUrl) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
|
||||||
@property profileBackground
|
return ('background-image: url(' + Discourse.getURLWithCDN(bgUrl) + ')').htmlSafe();
|
||||||
@type {String}
|
},
|
||||||
**/
|
|
||||||
profileBackground: function() {
|
|
||||||
var url = this.get('profile_background');
|
|
||||||
if (Em.isEmpty(url) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
|
|
||||||
return ('background-image: url(' + Discourse.getURLWithCDN(url) + ')').htmlSafe();
|
|
||||||
}.property('profile_background'),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Path to this user.
|
Path to this user.
|
||||||
|
@ -206,10 +201,10 @@ const User = RestModel.extend({
|
||||||
return Discourse.ajax("/users/" + this.get('username_lower'), {
|
return Discourse.ajax("/users/" + this.get('username_lower'), {
|
||||||
data: data,
|
data: data,
|
||||||
type: 'PUT'
|
type: 'PUT'
|
||||||
}).then(function(data) {
|
}).then(function(result) {
|
||||||
self.set('bio_excerpt',data.user.bio_excerpt);
|
self.set('bio_excerpt', result.user.bio_excerpt);
|
||||||
|
|
||||||
var userProps = self.getProperties('enable_quoting', 'external_links_in_new_tab', 'dynamic_favicon');
|
const userProps = self.getProperties('enable_quoting', 'external_links_in_new_tab', 'dynamic_favicon');
|
||||||
Discourse.User.current().setProperties(userProps);
|
Discourse.User.current().setProperties(userProps);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.set('isSaving', false);
|
this.set('isSaving', false);
|
||||||
|
|
|
@ -86,9 +86,9 @@ export default function(filter, extras) {
|
||||||
ScreenTrack.current().stop();
|
ScreenTrack.current().stop();
|
||||||
|
|
||||||
const findOpts = filterQueryParams(transition.queryParams),
|
const findOpts = filterQueryParams(transition.queryParams),
|
||||||
extras = { cached: this.isPoppedState(transition) };
|
findExtras = { cached: this.isPoppedState(transition) };
|
||||||
|
|
||||||
return findTopicList(this.store, filter, findOpts, extras);
|
return findTopicList(this.store, filter, findOpts, findExtras);
|
||||||
},
|
},
|
||||||
|
|
||||||
titleToken() {
|
titleToken() {
|
||||||
|
|
|
@ -13,7 +13,7 @@ const DiscourseRoute = Ember.Route.extend({
|
||||||
params = this.controller.getProperties(Object.keys(this.queryParams));
|
params = this.controller.getProperties(Object.keys(this.queryParams));
|
||||||
|
|
||||||
model.set('loading', true);
|
model.set('loading', true);
|
||||||
this.model(params).then(model => this.setupController(controller, model));
|
this.model(params).then(m => this.setupController(controller, m));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default Discourse.Route.extend({
|
||||||
willTransition(transition) {
|
willTransition(transition) {
|
||||||
// will reset the indexStream when transitioning to routes that aren't "indexStream"
|
// will reset the indexStream when transitioning to routes that aren't "indexStream"
|
||||||
// otherwise the "header" will jump
|
// otherwise the "header" will jump
|
||||||
const isIndexStream = ~INDEX_STREAM_ROUTES.indexOf(transition.targetName);
|
const isIndexStream = INDEX_STREAM_ROUTES.indexOf(transition.targetName) !== -1;
|
||||||
this.controllerFor('user').set('indexStream', isIndexStream);
|
this.controllerFor('user').set('indexStream', isIndexStream);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*eslint no-bitwise:0 */
|
||||||
import CloakedView from 'discourse/views/cloaked';
|
import CloakedView from 'discourse/views/cloaked';
|
||||||
|
|
||||||
const CloakedCollectionView = Ember.CollectionView.extend({
|
const CloakedCollectionView = Ember.CollectionView.extend({
|
||||||
|
|
|
@ -217,7 +217,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
|
||||||
initEditor() {
|
initEditor() {
|
||||||
// not quite right, need a callback to pass in, meaning this gets called once,
|
// not quite right, need a callback to pass in, meaning this gets called once,
|
||||||
// but if you start replying to another topic it will get the avatars wrong
|
// but if you start replying to another topic it will get the avatars wrong
|
||||||
let $wmdInput, editor;
|
let $wmdInput;
|
||||||
const self = this;
|
const self = this;
|
||||||
this.wmdInput = $wmdInput = this.$('.wmd-input');
|
this.wmdInput = $wmdInput = this.$('.wmd-input');
|
||||||
if ($wmdInput.length === 0 || $wmdInput.data('init') === true) return;
|
if ($wmdInput.length === 0 || $wmdInput.data('init') === true) return;
|
||||||
|
@ -243,7 +243,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.editor = editor = Discourse.Markdown.createEditor({
|
this.editor = Discourse.Markdown.createEditor({
|
||||||
containerElement: this.element,
|
containerElement: this.element,
|
||||||
lookupAvatarByPostNumber(postNumber, topicId) {
|
lookupAvatarByPostNumber(postNumber, topicId) {
|
||||||
const posts = self.get('controller.controllers.topic.model.postStream.posts');
|
const posts = self.get('controller.controllers.topic.model.postStream.posts');
|
||||||
|
|
|
@ -55,7 +55,6 @@ export default Ember.View.extend({
|
||||||
$li.removeClass('active');
|
$li.removeClass('active');
|
||||||
$html.data('hide-dropdown', null);
|
$html.data('hide-dropdown', null);
|
||||||
|
|
||||||
const controller = self.get('controller');
|
|
||||||
if (controller && !controller.isDestroyed){
|
if (controller && !controller.isDestroyed){
|
||||||
controller.set('visibleDropdown', null);
|
controller.set('visibleDropdown', null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,8 +256,8 @@ const PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||||
|
|
||||||
// Unless it's a full quote, allow click to expand
|
// Unless it's a full quote, allow click to expand
|
||||||
if (!($aside.data('full') || $title.data('has-quote-controls'))) {
|
if (!($aside.data('full') || $title.data('has-quote-controls'))) {
|
||||||
$title.on('click', function(e) {
|
$title.on('click', function(e2) {
|
||||||
if ($(e.target).is('a')) return true;
|
if ($(e2.target).is('a')) return true;
|
||||||
self._toggleQuote($aside);
|
self._toggleQuote($aside);
|
||||||
});
|
});
|
||||||
$title.data('has-quote-controls', true);
|
$title.data('has-quote-controls', true);
|
||||||
|
|
|
@ -34,8 +34,10 @@ task 'docker:test' do
|
||||||
@good &&= run_or_fail("bundle exec rspec")
|
@good &&= run_or_fail("bundle exec rspec")
|
||||||
end
|
end
|
||||||
unless ENV["RUBY_ONLY"]
|
unless ENV["RUBY_ONLY"]
|
||||||
|
@good &&= run_or_fail("eslint app/assets/javascripts")
|
||||||
@good &&= run_or_fail("eslint --ext \".es6\" app/assets/javascripts")
|
@good &&= run_or_fail("eslint --ext \".es6\" app/assets/javascripts")
|
||||||
@good &&= run_or_fail("eslint --ext \".es6\" test/javascripts")
|
@good &&= run_or_fail("eslint --ext \".es6\" test/javascripts")
|
||||||
|
@good &&= run_or_fail("eslint test/javascripts")
|
||||||
@good &&= run_or_fail("bundle exec rake qunit:test")
|
@good &&= run_or_fail("bundle exec rake qunit:test")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,8 @@ _.each(clickBindings, function(selector, binding) {
|
||||||
ok(true, selector + " was clicked");
|
ok(true, selector + " was clicked");
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(bindings, function(binding) {
|
_.each(bindings, function(b) {
|
||||||
testMouseTrap.trigger(binding);
|
testMouseTrap.trigger(b);
|
||||||
}, this);
|
}, this);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,10 +37,10 @@ test('passwordValidation', function() {
|
||||||
equal(controller.get('passwordValidation.reason'), I18n.t('user.password.ok'), 'Password is valid');
|
equal(controller.get('passwordValidation.reason'), I18n.t('user.password.ok'), 'Password is valid');
|
||||||
|
|
||||||
var testInvalidPassword = function(password, expectedReason) {
|
var testInvalidPassword = function(password, expectedReason) {
|
||||||
var controller = subject();
|
var c = subject();
|
||||||
controller.set('accountPassword', password);
|
c.set('accountPassword', password);
|
||||||
equal(controller.get('passwordValidation.failed'), true, 'password should be invalid: ' + password);
|
equal(c.get('passwordValidation.failed'), true, 'password should be invalid: ' + password);
|
||||||
equal(controller.get('passwordValidation.reason'), expectedReason, 'password validation reason: ' + password + ', ' + expectedReason);
|
equal(c.get('passwordValidation.reason'), expectedReason, 'password validation reason: ' + password + ', ' + expectedReason);
|
||||||
};
|
};
|
||||||
|
|
||||||
testInvalidPassword('', undefined);
|
testInvalidPassword('', undefined);
|
||||||
|
|
Loading…
Reference in a new issue