Fix jshint errors after conversion to JS

This commit is contained in:
Piotr Sarnacki 2015-12-29 11:58:58 +01:00
parent fafaf65043
commit e60b0a0224
53 changed files with 140 additions and 122 deletions

View File

@ -5,7 +5,14 @@
"-Promise", "-Promise",
"jQuery", "jQuery",
"Visibility", "Visibility",
"$" "$",
"Travis",
"_cio",
"_gaq",
"Log",
"moment",
"Pusher",
"md5"
], ],
"browser": true, "browser": true,
"boss": true, "boss": true,

View File

@ -1,8 +1,8 @@
import DS from 'ember-data'; import DS from 'ember-data';
import config from 'travis/config/environment'; import config from 'travis/config/environment';
var Adapter; import Ember from 'ember';
Adapter = DS.ActiveModelAdapter.extend({ export default DS.ActiveModelAdapter.extend({
auth: Ember.inject.service(), auth: Ember.inject.service(),
host: config.apiEndpoint, host: config.apiEndpoint,
coalesceFindRequests: true, coalesceFindRequests: true,
@ -11,11 +11,13 @@ Adapter = DS.ActiveModelAdapter.extend({
var base, hash, token; var base, hash, token;
hash = this._super(...arguments); hash = this._super(...arguments);
hash.headers || (hash.headers = {}); hash.headers = hash.headers || {};
hash.headers['accept'] = 'application/json; version=2'; hash.headers['accept'] = 'application/json; version=2';
if (token = this.get('auth').token()) { if (token = this.get('auth').token()) {
(base = hash.headers)['Authorization'] || (base['Authorization'] = "token " + token); if(!hash.headers['Authorization']) {
hash.headers['Authorization'] = "token " + token;
}
} }
return hash; return hash;
@ -37,5 +39,3 @@ Adapter = DS.ActiveModelAdapter.extend({
return this._super(...arguments); return this._super(...arguments);
} }
}); });
export default Adapter;

View File

@ -32,12 +32,12 @@ var App = Ember.Application.extend(Ember.Evented, {
$('body').toggleClass('maximized'); $('body').toggleClass('maximized');
element = $('<span></span>'); element = $('<span></span>');
$('#top .profile').append(element); $('#top .profile').append(element);
Em.run.later((function() { Ember.run.later((function() {
return element.remove(); return element.remove();
}), 10); }), 10);
element = $('<span></span>'); element = $('<span></span>');
$('#repo').append(element); $('#repo').append(element);
return Em.run.later((function() { return Ember.run.later((function() {
return element.remove(); return element.remove();
}), 10); }), 10);
}, },

View File

@ -1,4 +1,4 @@
var AddSshKeyComponent; import Ember from 'ember';
export default Ember.Component.extend({ export default Ember.Component.extend({
classNames: ['form--sshkey'], classNames: ['form--sshkey'],
@ -7,17 +7,18 @@ export default Ember.Component.extend({
isSaving: false, isSaving: false,
didInsertElement() { didInsertElement() {
id = this.get('repo.id'); var id = this.get('repo.id');
model = this.get('store').recordForId('ssh_key', id); var model = this.get('store').recordForId('ssh_key', id);
if (model) { if (model) {
this.get('store').dematerializeRecord(model._internalModel); this.get('store').dematerializeRecord(model._internalModel);
typeMap = this.get('store').typeMapFor(model.constructor); var typeMap = this.get('store').typeMapFor(model.constructor);
idToRecord = typeMap.idToRecord; var idToRecord = typeMap.idToRecord;
delete idToRecord[id]; delete idToRecord[id];
} }
model = this.get('store').createRecord('ssh_key', {
id: id model = this.get('store').createRecord('ssh_key', { id: id });
});
return this.set('model', model); return this.set('model', model);
}, },
@ -42,8 +43,8 @@ export default Ember.Component.extend({
}.observes('value'), }.observes('value'),
addErrorsFromResponse(errArr) { addErrorsFromResponse(errArr) {
var error; var error = errArr[0].detail;
error = errArr[0].detail;
if (error.code === 'not_a_private_key') { if (error.code === 'not_a_private_key') {
return this.set('valueError', 'This key is not a private key.'); return this.set('valueError', 'This key is not a private key.');
} else if (error.code === 'key_with_a_passphrase') { } else if (error.code === 'key_with_a_passphrase') {
@ -54,6 +55,7 @@ export default Ember.Component.extend({
actions: { actions: {
save() { save() {
var ssh_key; var ssh_key;
this.set('valueError', false); this.set('valueError', false);
if (this.get('isSaving')) { if (this.get('isSaving')) {
return; return;
@ -68,7 +70,7 @@ export default Ember.Component.extend({
this.set('isSaving', false); this.set('isSaving', false);
this.reset(); this.reset();
return this.sendAction('sshKeyAdded', ssh_key); return this.sendAction('sshKeyAdded', ssh_key);
}, () => { }, (error) => {
this.set('isSaving', false); this.set('isSaving', false);
if (error.errors) { if (error.errors) {
return this.addErrorsFromResponse(error.errors); return this.addErrorsFromResponse(error.errors);

View File

@ -1,6 +1,6 @@
import Ember from 'ember'; import Ember from 'ember';
import { colorForState } from 'travis/utils/helpers'; import { colorForState } from 'travis/utils/helpers';
import { languageConfigKeys } from 'travis/utils/keys-map';; import { languageConfigKeys } from 'travis/utils/keys-map';
export default Ember.Component.extend({ export default Ember.Component.extend({
tagName: 'li', tagName: 'li',

View File

@ -9,12 +9,12 @@ Log.DEBUG = false;
Log.LIMIT = 10000; Log.LIMIT = 10000;
Log.Scroll = function(options) { Log.Scroll = function(options) {
options || (options = {}); options = options || {};
this.beforeScroll = options.beforeScroll; this.beforeScroll = options.beforeScroll;
return this; return this;
}; };
Log.Scroll.prototype = $.extend(new Log.Listener, { Log.Scroll.prototype = $.extend(new Log.Listener(), {
insert: function(log, data, pos) { insert: function(log, data, pos) {
if (this.numbers) { if (this.numbers) {
this.tryScroll(); this.tryScroll();
@ -39,7 +39,7 @@ Log.Limit = function(max_lines, limitedLogCallback) {
return this; return this;
}; };
Log.Limit.prototype = Log.extend(new Log.Listener, { Log.Limit.prototype = Log.extend(new Log.Listener(), {
count: 0, count: 0,
insert: function(log, node, pos) { insert: function(log, node, pos) {
if (node.type === 'paragraph' && !node.hidden) { if (node.type === 'paragraph' && !node.hidden) {

View File

@ -1,4 +1,4 @@
var Controller; import Ember from 'ember';
export default Ember.Controller.extend({ export default Ember.Controller.extend({
sync() { sync() {
@ -8,6 +8,7 @@ export default Ember.Controller.extend({
model: Ember.computed.alias('auth.currentUser'), model: Ember.computed.alias('auth.currentUser'),
syncingDidChange: function() { syncingDidChange: function() {
var user;
if ((user = this.get('model')) && user.get('isSyncing') && !user.get('syncedAt')) { if ((user = this.get('model')) && user.get('isSyncing') && !user.get('syncedAt')) {
return Ember.run.scheduleOnce('routerTransitions', this, function() { return Ember.run.scheduleOnce('routerTransitions', this, function() {
return this.container.lookup('router:main').send('renderFirstSync'); return this.container.lookup('router:main').send('renderFirstSync');

View File

@ -52,7 +52,7 @@ export default Ember.Controller.extend({
} else { } else {
seenBroadcasts = []; seenBroadcasts = [];
} }
$.ajax(apiEndpoint + "/v3/broadcasts", options).then(() => { $.ajax(apiEndpoint + "/v3/broadcasts", options).then((response) => {
var receivedBroadcasts; var receivedBroadcasts;
if (response.broadcasts.length) { if (response.broadcasts.length) {
receivedBroadcasts = response.broadcasts.filter(function(broadcast) { receivedBroadcasts = response.broadcasts.filter(function(broadcast) {

View File

@ -1,7 +1,6 @@
import Ember from 'ember'; import Ember from 'ember';
var TextField;
TextField = Ember.TextField.extend({ var TextField = Ember.TextField.extend({
keyUp(event) { keyUp(event) {
return this.sendAction('action', this.get('_value'), event); return this.sendAction('action', this.get('_value'), event);
}, },
@ -18,4 +17,4 @@ export default function(params, hash, options, env) {
delete hash.on; delete hash.on;
hash.onEvent = onEvent || 'enter'; hash.onEvent = onEvent || 'enter';
return env.helpers.view.helperFunction.call(this, [TextField], hash, options, env); return env.helpers.view.helperFunction.call(this, [TextField], hash, options, env);
}; }

View File

@ -1,4 +1,5 @@
import { safe, formatCommit as formatCommitHelper } from 'travis/utils/helpers'; import { safe, formatCommit as formatCommitHelper } from 'travis/utils/helpers';
import Ember from 'ember';
export default Ember.Helper.helper(function(params) { export default Ember.Helper.helper(function(params) {
var commit; var commit;

View File

@ -2,4 +2,4 @@ import { safe, formatConfig as formatConfigHelper } from 'travis/utils/helpers';
export default function(config, options) { export default function(config, options) {
return safe(formatConfigHelper(config)); return safe(formatConfigHelper(config));
}; }

View File

@ -1,5 +1,6 @@
import { formatCommit, safe } from 'travis/utils/helpers'; import { formatCommit, safe } from 'travis/utils/helpers';
import { githubCommit as githubCommitUrl } from 'travis/utils/urls'; import { githubCommit as githubCommitUrl } from 'travis/utils/urls';
import Ember from 'ember';
export default Ember.Helper.helper(function(params) { export default Ember.Helper.helper(function(params) {
var commitSha, sha, slug, url; var commitSha, sha, slug, url;

View File

@ -1,4 +1,5 @@
// Generated by CoffeeScript 1.10.0 import Ember from 'ember';
var StylesheetsManagerInitializer, initialize, stylesheetsManager; var StylesheetsManagerInitializer, initialize, stylesheetsManager;
stylesheetsManager = Ember.Object.create({ stylesheetsManager = Ember.Object.create({

View File

@ -1,4 +1,5 @@
import { githubCommit, githubPullRequest } from 'travis/utils/urls'; import { githubCommit, githubPullRequest } from 'travis/utils/urls';
import Ember from 'ember';
export default Ember.Mixin.create({ export default Ember.Mixin.create({
urlGithubCommit: function() { urlGithubCommit: function() {

View File

@ -51,7 +51,7 @@ export default Ember.Mixin.create({
if (!Ember.isArray(pollModels)) { if (!Ember.isArray(pollModels)) {
pollModels = [pollModels]; pollModels = [pollModels];
} }
pollModels.forEach(() => { pollModels.forEach( (property) => {
this.pollModel(property); this.pollModel(property);
this.addObserver(property, this, 'pollModelDidChange'); this.addObserver(property, this, 'pollModelDidChange');
return Ember.addBeforeObserver(this, property, this, 'pollModelWillChange'); return Ember.addBeforeObserver(this, property, this, 'pollModelWillChange');
@ -68,7 +68,7 @@ export default Ember.Mixin.create({
if (!Ember.isArray(pollModels)) { if (!Ember.isArray(pollModels)) {
pollModels = [pollModels]; pollModels = [pollModels];
} }
pollModels.forEach(() => { pollModels.forEach( (property) => {
this.stopPollingModel(property); this.stopPollingModel(property);
this.removeObserver(property, this, 'pollModelDidChange'); this.removeObserver(property, this, 'pollModelDidChange');
return Ember.removeBeforeObserver(this, property, this, 'pollModelWillChange'); return Ember.removeBeforeObserver(this, property, this, 'pollModelWillChange');

View File

@ -1,4 +1,5 @@
import Ember from 'ember'; import Ember from 'ember';
import DS from 'ember-data';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
export default Model.extend({ export default Model.extend({

View File

@ -1,5 +1,6 @@
import Ember from 'ember'; import Ember from 'ember';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
import DS from 'ember-data';
export default Model.extend({ export default Model.extend({
name: DS.attr('string'), name: DS.attr('string'),

View File

@ -1,9 +1,10 @@
import Ember from 'ember'; import Ember from 'ember';
import DS from 'ember-data';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; var indexOf = [].indexOf;
export default Model.extend({ var Broadcast = Model.extend({
message: DS.attr(), message: DS.attr(),
toObject() { toObject() {
@ -36,3 +37,5 @@ Broadcast.reopenClass({
return Ember.A(seenBroadcasts || []); return Ember.A(seenBroadcasts || []);
}.property() }.property()
}); });
export default Broadcast;

View File

@ -3,6 +3,7 @@ import configKeysMap from 'travis/utils/keys-map';
import Ember from 'ember'; import Ember from 'ember';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
import DurationCalculations from 'travis/utils/duration-calculations'; import DurationCalculations from 'travis/utils/duration-calculations';
import DS from 'ember-data';
export default Model.extend(DurationCalculations, { export default Model.extend(DurationCalculations, {
ajax: Ember.inject.service(), ajax: Ember.inject.service(),

View File

@ -2,6 +2,7 @@ import Ember from 'ember';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
import Build from 'travis/models/build'; import Build from 'travis/models/build';
import { gravatarImage } from 'travis/utils/urls'; import { gravatarImage } from 'travis/utils/urls';
import DS from 'ember-data';
export default Model.extend({ export default Model.extend({
sha: DS.attr(), sha: DS.attr(),

View File

@ -1,5 +1,6 @@
import Ember from 'ember'; import Ember from 'ember';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
import DS from 'ember-data';
export default Model.extend({ export default Model.extend({
name: DS.attr(), name: DS.attr(),

View File

@ -1,6 +1,7 @@
import Ember from 'ember'; import Ember from 'ember';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
import config from 'travis/config/environment'; import config from 'travis/config/environment';
import DS from 'ember-data';
export default Model.extend({ export default Model.extend({
name: DS.attr(), name: DS.attr(),

View File

@ -4,6 +4,7 @@ import Ember from 'ember';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
import Log from 'travis/models/log'; import Log from 'travis/models/log';
import DurationCalculations from 'travis/utils/duration-calculations'; import DurationCalculations from 'travis/utils/duration-calculations';
import DS from 'ember-data';
export default Model.extend(DurationCalculations, { export default Model.extend(DurationCalculations, {
ajax: Ember.inject.service(), ajax: Ember.inject.service(),

View File

@ -12,7 +12,7 @@ var Request = Ember.Object.extend({
return this.get('ajax').ajax("/jobs/" + this.id + "/log?cors_hax=true", 'GET', { return this.get('ajax').ajax("/jobs/" + this.id + "/log?cors_hax=true", 'GET', {
dataType: 'text', dataType: 'text',
headers: this.HEADERS, headers: this.HEADERS,
success: () => { success: (body, status, xhr) => {
return Ember.run(this, function() { return Ember.run(this, function() {
return this.handle(body, status, xhr); return this.handle(body, status, xhr);
}); });
@ -51,7 +51,7 @@ var Request = Ember.Object.extend({
} }
}); });
var Log = Ember.Object.extend({ var LogModel = Ember.Object.extend({
version: 0, version: 0,
isLoaded: false, isLoaded: false,
length: 0, length: 0,
@ -180,4 +180,4 @@ var Log = Ember.Object.extend({
} }
}); });
export default Log; export default LogModel;

View File

@ -3,6 +3,9 @@ import Model from 'travis/models/model';
import { durationFrom as durationFromHelper } from 'travis/utils/helpers'; import { durationFrom as durationFromHelper } from 'travis/utils/helpers';
import Build from 'travis/models/build'; import Build from 'travis/models/build';
import Config from 'travis/config/environment'; import Config from 'travis/config/environment';
import DS from 'ember-data';
import Ember from 'ember';
var Repo; var Repo;
if (Config.useV3API) { if (Config.useV3API) {
@ -153,7 +156,7 @@ Repo.reopen({
stats: function() { stats: function() {
if (this.get('slug')) { if (this.get('slug')) {
return this.get('_stats') || $.get("https://api.github.com/repos/" + this.get('slug'), () => { return this.get('_stats') || $.get("https://api.github.com/repos/" + this.get('slug'), (data) => {
this.set('_stats', data); this.set('_stats', data);
return this.notifyPropertyChange('stats'); return this.notifyPropertyChange('stats');
}) && {}; }) && {};

View File

@ -1,5 +1,6 @@
import Ember from 'ember'; import Ember from 'ember';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
import DS from 'ember-data';
export default Model.extend({ export default Model.extend({
created_at: DS.attr(), created_at: DS.attr(),

View File

@ -1,4 +1,5 @@
import Ember from 'ember'; import Ember from 'ember';
import DS from 'ember-data';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
export default Model.extend({ export default Model.extend({

View File

@ -1,6 +1,7 @@
import Ember from 'ember'; import Ember from 'ember';
import Model from 'travis/models/model'; import Model from 'travis/models/model';
import config from 'travis/config/environment'; import config from 'travis/config/environment';
import DS from 'ember-data';
export default Model.extend({ export default Model.extend({
ajax: Ember.inject.service(), ajax: Ember.inject.service(),
@ -42,11 +43,9 @@ export default Model.extend({
permissions = Ember.ArrayProxy.create({ permissions = Ember.ArrayProxy.create({
content: [] content: []
}); });
this.get('_rawPermissions').then((function(_this) { this.get('_rawPermissions').then((data) => {
return function(data) { return permissions.set('content', data.permissions);
return permissions.set('content', data.permissions); });
};
})(this));
return permissions; return permissions;
}.property(), }.property(),
@ -55,7 +54,7 @@ export default Model.extend({
permissions = Ember.ArrayProxy.create({ permissions = Ember.ArrayProxy.create({
content: [] content: []
}); });
this.get('_rawPermissions').then(() => { this.get('_rawPermissions').then((data) => {
return permissions.set('content', data.admin); return permissions.set('content', data.admin);
}); });
return permissions; return permissions;
@ -66,7 +65,7 @@ export default Model.extend({
permissions = Ember.ArrayProxy.create({ permissions = Ember.ArrayProxy.create({
content: [] content: []
}); });
this.get('_rawPermissions').then(() => { this.get('_rawPermissions').then((data) => {
return permissions.set('content', data.pull); return permissions.set('content', data.pull);
}); });
return permissions; return permissions;
@ -77,14 +76,14 @@ export default Model.extend({
permissions = Ember.ArrayProxy.create({ permissions = Ember.ArrayProxy.create({
content: [] content: []
}); });
this.get('_rawPermissions').then(() => { this.get('_rawPermissions').then((data) => {
return permissions.set('content', data.push); return permissions.set('content', data.push);
}); });
return permissions; return permissions;
}.property(), }.property(),
pushPermissionsPromise: function() { pushPermissionsPromise: function() {
return this.get('_rawPermissions').then(() => { return this.get('_rawPermissions').then((data) => {
return data.pull; return data.pull;
}); });
}.property(), }.property(),
@ -110,7 +109,7 @@ export default Model.extend({
}, },
poll() { poll() {
return this.get('ajax').get('/users', () => { return this.get('ajax').get('/users', (data) => {
var self; var self;
if (data.user.is_syncing) { if (data.user.is_syncing) {
self = this; self = this;

View File

@ -22,13 +22,5 @@ export default TravisRoute.extend({
outlet: 'left', outlet: 'left',
into: 'profile' into: 'profile'
}); });
},
organizations() {
return model.filterBy('type', 'organization');
},
user() {
return model.filterBy('type', 'user')[0];
} }
}); });

View File

@ -24,7 +24,7 @@ export default TravisRoute.extend(BuildFaviconMixin, {
this.get('stylesheetsManager').disable('dashboard'); this.get('stylesheetsManager').disable('dashboard');
if (!config.pro) { if (!config.pro) {
repos = this.get('store').peekAll('repo'); repos = this.get('store').peekAll('repo');
repos.forEach(() => { repos.forEach((repo) => {
return this.subscribeToRepo(repo); return this.subscribeToRepo(repo);
}); });
return repos.addArrayObserver(this, { return repos.addArrayObserver(this, {
@ -39,7 +39,7 @@ export default TravisRoute.extend(BuildFaviconMixin, {
reposDidChange(array, start, removedCount, addedCount) { reposDidChange(array, start, removedCount, addedCount) {
var addedRepos; var addedRepos;
addedRepos = array.slice(start, start + addedCount); addedRepos = array.slice(start, start + addedCount);
return addedRepos.forEach(() => { return addedRepos.forEach((repo) => {
return this.subscribeToRepo(repo); return this.subscribeToRepo(repo);
}); });
}, },

View File

@ -1,4 +1,5 @@
import SimpleLayoutRoute from 'travis/routes/simple-layout'; import SimpleLayoutRoute from 'travis/routes/simple-layout';
import Ember from 'ember';
export default SimpleLayoutRoute.extend({ export default SimpleLayoutRoute.extend({
activate() { activate() {

View File

@ -1,6 +1,7 @@
import BasicRoute from 'travis/routes/basic'; import BasicRoute from 'travis/routes/basic';
import config from 'travis/config/environment'; import config from 'travis/config/environment';
import limit from 'travis/utils/computed-limit'; import limit from 'travis/utils/computed-limit';
import Ember from 'ember';
export default BasicRoute.extend({ export default BasicRoute.extend({
init: function() { init: function() {
@ -23,7 +24,7 @@ export default BasicRoute.extend({
}, },
loadMoreRepos() { loadMoreRepos() {
return this.store.findAll('build').then(() => { return this.store.findAll('build').then( (builds) => {
var repoIds, repos; var repoIds, repos;
repoIds = builds.mapBy('data.repo').uniq(); repoIds = builds.mapBy('data.repo').uniq();
repos = this.get('repos.repos'); repos = this.get('repos.repos');

View File

@ -25,7 +25,7 @@ export default TravisRoute.extend({
buildController = this.controllerFor('build'); buildController = this.controllerFor('build');
model.get('repo'); model.get('repo');
if (buildPromise = model.get('build')) { if (buildPromise = model.get('build')) {
buildPromise.then(() => { buildPromise.then( (build) => {
build = this.store.recordForId('build', build.get('id')); build = this.store.recordForId('build', build.get('id'));
return buildController.set('build', build); return buildController.set('build', build);
}); });

View File

@ -26,7 +26,10 @@ export default TravisRoute.extend({
serialize(repo) { serialize(repo) {
var name, owner, ref, slug; var name, owner, ref, slug;
slug = repo.get ? repo.get('slug') : repo.slug; slug = repo.get ? repo.get('slug') : repo.slug;
ref = slug.split('/'), owner = ref[0], name = ref[1]; ref = slug.split('/');
owner = ref[0];
name = ref[1];
return { return {
owner: owner, owner: owner,
name: name name: name

View File

@ -1,5 +1,6 @@
import TravisRoute from 'travis/routes/basic'; import TravisRoute from 'travis/routes/basic';
import config from 'travis/config/environment'; import config from 'travis/config/environment';
import Ember from 'ember';
export default TravisRoute.extend({ export default TravisRoute.extend({
ajax: Ember.inject.service(), ajax: Ember.inject.service(),
@ -36,7 +37,7 @@ export default TravisRoute.extend({
fetchSshKey() { fetchSshKey() {
var repo; var repo;
repo = this.modelFor('repo'); repo = this.modelFor('repo');
return this.get('ajax').get("/repos/" + (repo.get('id')) + "/key", () => { return this.get('ajax').get("/repos/" + (repo.get('id')) + "/key", (data) => {
return Ember.Object.create({ return Ember.Object.create({
fingerprint: data.fingerprint fingerprint: data.fingerprint
}); });

View File

@ -1,4 +1,4 @@
import Ember from 'ember';; import Ember from 'ember';
import config from 'travis/config/environment'; import config from 'travis/config/environment';
var default_options; var default_options;
@ -61,8 +61,10 @@ export default Ember.Service.extend({
options = options || {}; options = options || {};
token = Ember.get(this, 'auth').token(); token = Ember.get(this, 'auth').token();
if (token && (this.needsAuth(method, url) || options.forceAuth)) { if (token && (this.needsAuth(method, url) || options.forceAuth)) {
options.headers || (options.headers = {}); options.headers = options.headers || {};
(base = options.headers)['Authorization'] || (base['Authorization'] = "token " + token); if(!options.headers['Authorization']) {
options.headers['Authorization'] = "token " + token;
}
} }
options.url = url = "" + endpoint + url; options.url = url = "" + endpoint + url;
options.type = method; options.type = method;
@ -97,30 +99,7 @@ export default Ember.Service.extend({
}; };
options = $.extend(options, default_options); options = $.extend(options, default_options);
if (typeof testMode !== "undefined" && testMode !== null) {
console.log('Running ajax with', options.url);
return new Ember.RSVP.Promise(function(resolve, reject) {
var oldError, oldSuccess;
oldSuccess = options.success;
options.success = function(json, status, xhr) {
Ember.run(this, function() {
return oldSuccess.call(this, json, status, xhr);
});
return Ember.run(null, resolve, json);
};
oldError = options.error;
options.error = function(jqXHR) {
if (jqXHR) {
jqXHR.then = null;
}
return Ember.run(this, function() {
oldError.call(this, jqXHR);
return reject(jqXHR);
});
};
return $.ajax(options);
});
}
if (options.data && (method === "GET" || method === "HEAD")) { if (options.data && (method === "GET" || method === "HEAD")) {
params = jQuery.param(options.data); params = jQuery.param(options.data);
delimeter = url.indexOf('?') === -1 ? '?' : '&'; delimeter = url.indexOf('?') === -1 ? '?' : '&';
@ -158,7 +137,6 @@ export default Ember.Service.extend({
if (xhr.readyState === 4) { if (xhr.readyState === 4) {
contentType = xhr.getResponseHeader('Content-Type'); contentType = xhr.getResponseHeader('Content-Type');
data = (function() { data = (function() {
var error1;
if (contentType && contentType.match(/application\/json/)) { if (contentType && contentType.match(/application\/json/)) {
try { try {
return jQuery.parseJSON(xhr.responseText); return jQuery.parseJSON(xhr.responseText);

View File

@ -1,4 +1,5 @@
import config from 'travis/config/environment'; import config from 'travis/config/environment';
import Ember from 'ember';
export default Ember.Service.extend({ export default Ember.Service.extend({
store: Ember.inject.service(), store: Ember.inject.service(),
@ -9,7 +10,7 @@ export default Ember.Service.extend({
receivingEnd: location.protocol + "//" + location.host, receivingEnd: location.protocol + "//" + location.host,
init: function() { init: function() {
return window.addEventListener('message', () => { return window.addEventListener('message', (e) => {
return this.receiveMessage(e); return this.receiveMessage(e);
}); });
}, },
@ -52,9 +53,13 @@ export default Ember.Service.extend({
}, },
autoSignIn(data) { autoSignIn(data) {
data || (data = this.userDataFrom(this.get('sessionStorage')) || this.userDataFrom(this.get('storage'))); if(!data) {
data = this.userDataFrom(this.get('sessionStorage')) ||
this.userDataFrom(this.get('storage'));
}
if (data) { if (data) {
return this.setData(data); this.setData(data);
} }
}, },
@ -200,7 +205,7 @@ export default Ember.Service.extend({
}, },
sendToApp(name) { sendToApp(name) {
var error, error1, router; var error, router;
// TODO: this is an ugly solution, we need to do one of 2 things: // TODO: this is an ugly solution, we need to do one of 2 things:
// * find a way to check if we can already send an event to remove try/catch // * find a way to check if we can already send an event to remove try/catch
@ -214,7 +219,7 @@ export default Ember.Service.extend({
return router.send(name); return router.send(name);
} catch (error1) { } catch (error1) {
error = error1; error = error1;
if (!(error.message = ~/Can't trigger action/)) { if (!(error.message.match(/Can't trigger action/))) {
throw error; throw error;
} }
} }

View File

@ -28,6 +28,10 @@ export default Ember.Service.extend({
loadFlashes(msgs) { loadFlashes(msgs) {
var i, len, msg, results, type; var i, len, msg, results, type;
var callback = function() {
return this.get('flashes.content').removeObject(msg);
};
results = []; results = [];
for (i = 0, len = msgs.length; i < len; i++) { for (i = 0, len = msgs.length; i < len; i++) {
msg = msgs[i]; msg = msgs[i];
@ -37,9 +41,7 @@ export default Ember.Service.extend({
message: msg[type] message: msg[type]
}; };
this.get('flashes').unshiftObject(msg); this.get('flashes').unshiftObject(msg);
results.push(Ember.run.later(this, (function() { results.push(Ember.run.later(this, callback, 15000));
return this.get('flashes.content').removeObject(msg);
}), 15000));
} }
return results; return results;
}, },

View File

@ -61,7 +61,7 @@ export default Ember.Service.extend({
return model.reload(); return model.reload();
}); });
return this.get('sources').forEach( () => { return this.get('sources').forEach( (source) => {
if (Ember.get(source, 'isDestroyed')) { if (Ember.get(source, 'isDestroyed')) {
return this.get('sources').removeObject(source); return this.get('sources').removeObject(source);
} else { } else {

View File

@ -4,7 +4,7 @@ import Storage from 'travis/utils/hash-storage';
export default StorageService.extend({ export default StorageService.extend({
init: function() { init: function() {
var err, error, storage; var err, storage;
storage = null; storage = null;
try { try {
// firefox will not throw error on access for sessionStorage var, // firefox will not throw error on access for sessionStorage var,

View File

@ -3,7 +3,7 @@ import Storage from 'travis/utils/hash-storage';
export default Ember.Service.extend({ export default Ember.Service.extend({
init: function() { init: function() {
var err, error, storage; var err, storage;
storage = null; storage = null;
try { try {
storage = window.localStorage || (function() { storage = window.localStorage || (function() {

View File

@ -1,5 +1,6 @@
import DS from 'ember-data'; import DS from 'ember-data';
import Config from 'travis/config/environment'; import Config from 'travis/config/environment';
import Ember from 'ember';
export default DS.Store.extend({ export default DS.Store.extend({
auth: Ember.inject.service(), auth: Ember.inject.service(),
@ -21,7 +22,9 @@ export default DS.Store.extend({
canHandleEvent(event, data) { canHandleEvent(event, data) {
var callback, name, ref, ref1, type; var callback, name, ref, ref1, type;
ref = event.split(':'), name = ref[0], type = ref[1]; ref = event.split(':');
name = ref[0];
type = ref[1];
ref1 = this.get('pusherEventHandlerGuards'); ref1 = this.get('pusherEventHandlerGuards');
for (name in ref1) { for (name in ref1) {
callback = ref1[name]; callback = ref1[name];
@ -34,7 +37,10 @@ export default DS.Store.extend({
receivePusherEvent(event, data) { receivePusherEvent(event, data) {
var build, commit, job, name, ref, ref1, ref2, type; var build, commit, job, name, ref, ref1, ref2, type;
ref = event.split(':'), name = ref[0], type = ref[1]; ref = event.split(':');
name = ref[0];
type = ref[1];
if (!this.canHandleEvent(event, data)) { if (!this.canHandleEvent(event, data)) {
return; return;
} }

View File

@ -1,3 +1,5 @@
import Ember from 'ember';
var configKeys, configKeysMap, languageConfigKeys; var configKeys, configKeysMap, languageConfigKeys;
languageConfigKeys = { languageConfigKeys = {

View File

@ -57,7 +57,7 @@ export default (function() {
LinesSelector.prototype.highlightLines = function(tries) { LinesSelector.prototype.highlightLines = function(tries) {
var elements, lines; var elements, lines;
tries || (tries = 0); tries = tries || 0;
this.removeAllHighlights(); this.removeAllHighlights();
if (lines = this.getSelectedLines()) { if (lines = this.getSelectedLines()) {
elements = this.element.find('p:visible').slice(lines.first - 1, lines.last); elements = this.element.find('p:visible').slice(lines.first - 1, lines.last);

View File

@ -1,4 +1,5 @@
import ENV from 'travis/config/environment'; import ENV from 'travis/config/environment';
import Ember from 'ember';
var TravisPusher = function(config, ajaxService) { var TravisPusher = function(config, ajaxService) {
this.init(config, ajaxService); this.init(config, ajaxService);
@ -165,7 +166,7 @@ if (ENV.pro) {
Pusher.authorizers.bulk_ajax = function(socketId, _callback) { Pusher.authorizers.bulk_ajax = function(socketId, _callback) {
var channels, name, names; var channels, name, names;
channels = Travis.pusher.pusher.channels; channels = Travis.pusher.pusher.channels;
channels.callbacks || (channels.callbacks = []); channels.callbacks = channels.callbacks || [];
name = this.channel.name; name = this.channel.name;
names = Object.keys(channels.channels); names = Object.keys(channels.channels);
channels.callbacks.push(function(auths) { channels.callbacks.push(function(auths) {

View File

@ -6,12 +6,10 @@ export default (function() {
this.tail_selector = tail_selector; this.tail_selector = tail_selector;
this.log_selector = log_selector; this.log_selector = log_selector;
this.position = this.window.scrollTop(); this.position = this.window.scrollTop();
this.window.scroll((function(_this) { this.window.scroll(() => {
return function() { return Ember.run.throttle(this, this.onScroll, [], 200, false);
return Ember.run.throttle(_this, _this.onScroll, [], 200, false); });
}; return this;
})(this));
this;
} }
Tailing.prototype.options = { Tailing.prototype.options = {

View File

@ -12,12 +12,10 @@ export default (function() {
this.element_selector = element_selector; this.element_selector = element_selector;
this.container_selector = container_selector; this.container_selector = container_selector;
this.position = this.window.scrollTop(); this.position = this.window.scrollTop();
this.window.scroll((function(_this) { this.window.scroll(() => {
return function() { return Ember.run.throttle(this, this.onScroll, [], 200, false);
return Ember.run.throttle(_this, _this.onScroll, [], 200, false); });
}; return this;
})(this));
this;
} }
ToTop.prototype.element = function() { ToTop.prototype.element = function() {

View File

@ -1,4 +1,5 @@
import BasicView from 'travis/views/basic'; import BasicView from 'travis/views/basic';
import Ember from 'ember';
export default BasicView.extend({ export default BasicView.extend({
popup: Ember.inject.service(), popup: Ember.inject.service(),

View File

@ -18,7 +18,7 @@ export default Ember.View.extend({
}.property('tab'), }.property('tab'),
classBranches: function() { classBranches: function() {
this.get('tab') === 'branches' ? 'active' : null; return this.get('tab') === 'branches' ? 'active' : null;
}.property('tab'), }.property('tab'),
classBuild: function() { classBuild: function() {

View File

@ -3,6 +3,7 @@ import StatusImagesView from 'travis/views/status-images';
import BasicView from 'travis/views/basic'; import BasicView from 'travis/views/basic';
import config from 'travis/config/environment'; import config from 'travis/config/environment';
import Polling from 'travis/mixins/polling'; import Polling from 'travis/mixins/polling';
import Ember from 'ember';
export default BasicView.extend(Polling, { export default BasicView.extend(Polling, {
popup: Ember.inject.service(), popup: Ember.inject.service(),

View File

@ -46,7 +46,8 @@
"currentPath", "currentPath",
"currentRouteName", "currentRouteName",
"jQuery", "jQuery",
"Visibility" "Visibility",
"Travis"
], ],
"node": false, "node": false,
"browser": false, "browser": false,

View File

@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.10.0
import { test, moduleForComponent } from 'ember-qunit'; import { test, moduleForComponent } from 'ember-qunit';
import Ember from 'ember';
moduleForComponent('build-repo-actions', 'BuildRepoActionsComponent', {}); moduleForComponent('build-repo-actions', 'BuildRepoActionsComponent', {});
test('it shows cancel button if canCancel is true', function() { test('it shows cancel button if canCancel is true', function() {

View File

@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.10.0
import { test, moduleForComponent } from 'ember-qunit'; import { test, moduleForComponent } from 'ember-qunit';
import Ember from 'ember';
moduleForComponent('jobs-item', 'JobsItemComponent', { moduleForComponent('jobs-item', 'JobsItemComponent', {
needs: ['helper:format-duration', 'helper:pretty-date', 'component:status-icon'] needs: ['helper:format-duration', 'helper:pretty-date', 'component:status-icon']
}); });