Convert project to JavaScript

This commit is contained in:
Piotr Sarnacki 2015-12-22 12:04:27 +01:00
parent e27a19101d
commit fafaf65043
517 changed files with 9115 additions and 8131 deletions

View File

@ -4,7 +4,8 @@
"window", "window",
"-Promise", "-Promise",
"jQuery", "jQuery",
"Visibility" "Visibility",
"$"
], ],
"browser": true, "browser": true,
"boss": true, "boss": true,

View File

@ -1,30 +0,0 @@
`import DS from 'ember-data'`
`import config from 'travis/config/environment'`
Adapter = DS.ActiveModelAdapter.extend
auth: Ember.inject.service()
host: config.apiEndpoint
coalesceFindRequests: true
ajaxOptions: (url, type, options) ->
hash = @_super(url, type, options)
hash.headers ||= {}
hash.headers['accept'] = 'application/json; version=2'
if token = @get('auth').token()
hash.headers['Authorization'] ||= "token #{token}"
hash
findMany: (store, type, ids) ->
@ajax(@buildURL(type.modelName), 'GET', data: { ids: ids })
handleResponse: (status, headers, payload) ->
if status > 299
console.log "[ERROR] API responded with an error (#{status}): #{JSON.stringify(payload)}"
return @_super.apply(this, arguments)
`export default Adapter`

View File

@ -0,0 +1,41 @@
import DS from 'ember-data';
import config from 'travis/config/environment';
var Adapter;
Adapter = DS.ActiveModelAdapter.extend({
auth: Ember.inject.service(),
host: config.apiEndpoint,
coalesceFindRequests: true,
ajaxOptions(url, type, options) {
var base, hash, token;
hash = this._super(...arguments);
hash.headers || (hash.headers = {});
hash.headers['accept'] = 'application/json; version=2';
if (token = this.get('auth').token()) {
(base = hash.headers)['Authorization'] || (base['Authorization'] = "token " + token);
}
return hash;
},
findMany(store, type, ids) {
return this.ajax(this.buildURL(type.modelName), 'GET', {
data: {
ids: ids
}
});
},
handleResponse(status, headers, payload) {
if (status > 299) {
console.log("[ERROR] API responded with an error (" + status + "): " + (JSON.stringify(payload)));
}
return this._super(...arguments);
}
});
export default Adapter;

View File

@ -1,26 +0,0 @@
`import Ember from 'ember'`
`import ApplicationAdapter from 'travis/adapters/application'`
Adapter = ApplicationAdapter.extend
namespace: 'settings'
buildURL: (type, id, record) ->
url = @_super.apply this, arguments
if record && (repoId = Ember.get(record, 'repo.id'))
delimiter = if url.indexOf('?') != -1 then '&' else '?'
url = "#{url}#{delimiter}repository_id=#{repoId}"
url
updateRecord: (store, type, record) ->
data = {};
serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record);
id = Ember.get(record, 'id');
this.ajax(this.buildURL(type.typeKey, id, record), "PATCH", { data: data })
`export default Adapter`

27
app/adapters/env-var.js Normal file
View File

@ -0,0 +1,27 @@
import Ember from 'ember';
import ApplicationAdapter from 'travis/adapters/application';
export default ApplicationAdapter.extend({
namespace: 'settings',
buildURL(type, id, record) {
var delimiter, repoId, url;
url = this._super.apply(this, arguments);
if (record && (repoId = Ember.get(record, 'repo.id'))) {
delimiter = url.indexOf('?') !== -1 ? '&' : '?';
url = "" + url + delimiter + "repository_id=" + repoId;
}
return url;
},
updateRecord(store, type, record) {
var data, id, serializer;
data = {};
serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record);
id = Ember.get(record, 'id');
return this.ajax(this.buildURL(type.typeKey, id, record), "PATCH", {
data: data
});
}
});

View File

@ -1,24 +0,0 @@
`import Ember from 'ember'`
`import ApplicationAdapter from 'travis/adapters/application'`
Adapter = ApplicationAdapter.extend
namespace: 'settings'
find: (store, type, id, record) ->
@ajax(this.urlPrefix() + '/ssh_key/' + id, 'GET')
deleteRecord: (store, type, record) ->
id = Ember.get(record, 'id')
@ajax(this.urlPrefix() + '/ssh_key/' + id, "DELETE");
createRecord: (store, type, record) ->
data = {};
serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record, { includeId: true });
id = Ember.get(record, 'id')
this.ajax(this.urlPrefix() + '/ssh_key/' + id, "PATCH", { data: data })
`export default Adapter`

29
app/adapters/ssh-key.js Normal file
View File

@ -0,0 +1,29 @@
import Ember from 'ember';
import ApplicationAdapter from 'travis/adapters/application';
export default ApplicationAdapter.extend({
namespace: 'settings',
find(store, type, id, record) {
return this.ajax(this.urlPrefix() + '/ssh_key/' + id, 'GET');
},
deleteRecord(store, type, record) {
var id;
id = Ember.get(record, 'id');
return this.ajax(this.urlPrefix() + '/ssh_key/' + id, "DELETE");
},
createRecord(store, type, record) {
var data, id, serializer;
data = {};
serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record, {
includeId: true
});
id = Ember.get(record, 'id');
return this.ajax(this.urlPrefix() + '/ssh_key/' + id, "PATCH", {
data: data
});
}
});

View File

@ -1,111 +0,0 @@
`import Ember from 'ember'`
`import Resolver from 'ember/resolver'`
`import loadInitializers from 'ember/load-initializers'`
`import config from './config/environment'`
Ember.MODEL_FACTORY_INJECTIONS = true
Ember.LinkView.reopen(
attributeBindings: ['alt']
);
App = Ember.Application.extend(Ember.Evented,
LOG_TRANSITIONS: true
LOG_TRANSITIONS_INTERNAL: true
LOG_ACTIVE_GENERATION: true
LOG_MODULE_RESOLVER: true
LOG_VIEW_LOOKUPS: true
#LOG_RESOLVER: true
modulePrefix: config.modulePrefix
podModulePrefix: config.podModulePrefix
Resolver: Resolver
lookup: ->
@__container__.lookup.apply @__container__, arguments
flash: (options) ->
Travis.lookup('controller:flash').loadFlashes([options])
toggleSidebar: ->
$('body').toggleClass('maximized')
# TODO gotta force redraws here :/
element = $('<span></span>')
$('#top .profile').append(element)
Em.run.later (-> element.remove()), 10
element = $('<span></span>')
$('#repo').append(element)
Em.run.later (-> element.remove()), 10
ready: ->
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
@on 'user:signed_in', (user) ->
Travis.onUserUpdate(user)
@on 'user:refreshed', (user) ->
Travis.onUserUpdate(user)
@on 'user:synced', (user) ->
Travis.onUserUpdate(user)
@on 'user:signed_out', () ->
if config.userlike
Travis.removeUserlike()
currentDate: ->
new Date()
onUserUpdate: (user) ->
if config.pro
@identifyCustomer(user)
if config.userlike
@setupUserlike(user)
@subscribePusher(user)
subscribePusher: (user) ->
return unless user.channels
channels = user.channels
if config.pro
channels = channels.map (channel) ->
if channel.match /^private-/
channel
else
"private-#{channel}"
Travis.pusher.subscribeAll(channels)
setupUserlike: (user) ->
btn = document.getElementById('userlikeCustomTab')
btn.classList.add("logged-in")
userlikeData = window.userlikeData = {}
userlikeData.user = {}
userlikeData.user.name= user.login;
userlikeData.user.email = user.email;
unless document.getElementById('userlike-script')
s = document.createElement('script')
s.id = 'userlike-script'
s.src = '//userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/0327dbb23382ccbbb91b445b76e8a91d4b37d90ef9f2faf84e11177847ff7bb9.js'
document.body.appendChild(s)
removeUserlike: () ->
btn = document.getElementById('userlikeCustomTab')
btn.classList.remove("logged-in")
identifyCustomer: (user) ->
if _cio && _cio.identify
_cio.identify
id: user.id
email: user.email
name: user.name
created_at: (Date.parse(user.created_at) / 1000) || null
login: user.login
)
loadInitializers(App, config.modulePrefix)
`export default App`

134
app/app.js Normal file
View File

@ -0,0 +1,134 @@
import Ember from 'ember';
import Resolver from 'ember/resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';
Ember.MODEL_FACTORY_INJECTIONS = true;
Ember.LinkView.reopen({
attributeBindings: ['alt']
});
var App = Ember.Application.extend(Ember.Evented, {
LOG_TRANSITIONS: true,
LOG_TRANSITIONS_INTERNAL: true,
LOG_ACTIVE_GENERATION: true,
LOG_MODULE_RESOLVER: true,
LOG_VIEW_LOOKUPS: true,
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver: Resolver,
lookup() {
return this.__container__.lookup.apply(this.__container__, arguments);
},
flash(options) {
return Travis.lookup('controller:flash').loadFlashes([options]);
},
toggleSidebar() {
var element;
$('body').toggleClass('maximized');
element = $('<span></span>');
$('#top .profile').append(element);
Em.run.later((function() {
return element.remove();
}), 10);
element = $('<span></span>');
$('#repo').append(element);
return Em.run.later((function() {
return element.remove();
}), 10);
},
ready() {
if (location.hash.slice(0, 2) === '#!') {
location.href = location.href.replace('#!/', '');
}
this.on('user:signed_in', function(user) {
return Travis.onUserUpdate(user);
});
this.on('user:refreshed', function(user) {
return Travis.onUserUpdate(user);
});
this.on('user:synced', function(user) {
return Travis.onUserUpdate(user);
});
return this.on('user:signed_out', function() {
if (config.userlike) {
return Travis.removeUserlike();
}
});
},
currentDate() {
return new Date();
},
onUserUpdate(user) {
if (config.pro) {
this.identifyCustomer(user);
}
if (config.userlike) {
this.setupUserlike(user);
}
return this.subscribePusher(user);
},
subscribePusher(user) {
var channels;
if (!user.channels) {
return;
}
channels = user.channels;
if (config.pro) {
channels = channels.map(function(channel) {
if (channel.match(/^private-/)) {
return channel;
} else {
return "private-" + channel;
}
});
}
return Travis.pusher.subscribeAll(channels);
},
setupUserlike(user) {
var btn, s, userlikeData;
btn = document.getElementById('userlikeCustomTab');
btn.classList.add("logged-in");
userlikeData = window.userlikeData = {};
userlikeData.user = {};
userlikeData.user.name = user.login;
userlikeData.user.email = user.email;
if (!document.getElementById('userlike-script')) {
s = document.createElement('script');
s.id = 'userlike-script';
s.src = '//userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/0327dbb23382ccbbb91b445b76e8a91d4b37d90ef9f2faf84e11177847ff7bb9.js';
return document.body.appendChild(s);
}
},
removeUserlike() {
var btn;
btn = document.getElementById('userlikeCustomTab');
return btn.classList.remove("logged-in");
},
identifyCustomer(user) {
if (_cio && _cio.identify) {
return _cio.identify({
id: user.id,
email: user.email,
name: user.name,
created_at: (Date.parse(user.created_at) / 1000) || null,
login: user.login
});
}
}
});
loadInitializers(App, config.modulePrefix);
export default App;

View File

@ -1,46 +0,0 @@
`import Ember from 'ember'`
AddEnvVarComponent = Ember.Component.extend
classNames: ['form--envvar']
classNameBindings: ['nameIsBlank:form-error']
store: Ember.inject.service()
isValid: () ->
if Ember.isBlank(@get('name'))
this.set('nameIsBlank', true)
false
else
true
reset: ->
@setProperties(name: null, value: null, public: null)
actions:
save: ->
return if @get('isSaving')
@set('isSaving', true)
if @isValid()
env_var = @get('store').createRecord('env_var',
name: @get('name')
value: @get('value')
public: @get('public')
repo: @get('repo')
)
self = this
env_var.save().then =>
@set('isSaving', false)
@reset()
, =>
@set('isSaving', false)
else
@set('isSaving', false)
nameChanged: ->
this.set('nameIsBlank', false)
`export default AddEnvVarComponent`

View File

@ -0,0 +1,55 @@
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['form--envvar'],
classNameBindings: ['nameIsBlank:form-error'],
store: Ember.inject.service(),
isValid() {
if (Ember.isBlank(this.get('name'))) {
this.set('nameIsBlank', true);
return false;
} else {
return true;
}
},
reset() {
return this.setProperties({
name: null,
value: null,
"public": null
});
},
actions: {
save() {
var env_var, self;
if (this.get('isSaving')) {
return;
}
this.set('isSaving', true);
if (this.isValid()) {
env_var = this.get('store').createRecord('env_var', {
name: this.get('name'),
value: this.get('value'),
"public": this.get('public'),
repo: this.get('repo')
});
self = this;
return env_var.save().then(() => {
this.set('isSaving', false);
return this.reset();
}, () => {
return this.set('isSaving', false);
});
} else {
return this.set('isSaving', false);
}
},
nameChanged() {
return this.set('nameIsBlank', false);
}
}
});

View File

@ -1,73 +0,0 @@
# `import Ember from 'ember'`
AddSshKeyComponent = Ember.Component.extend
classNames: ['form--sshkey']
classNameBindings: ['valueError:form-error']
store: Ember.inject.service()
isSaving: false
didInsertElement: () ->
id = @get('repo.id')
model = @get('store').recordForId('ssh_key', id)
# TODO: this can be removed in favor of simply unloading record
# once https://github.com/emberjs/data/pull/2867
# and https://github.com/emberjs/data/pull/2870 are merged
if model
@get('store').dematerializeRecord(model._internalModel)
typeMap = @get('store').typeMapFor(model.constructor)
idToRecord = typeMap.idToRecord
delete idToRecord[id]
model = @get('store').createRecord('ssh_key', id: id)
@set('model', model)
isValid: () ->
if Ember.isBlank(@get('value'))
this.set('valueError', 'Value can\'t be blank.')
false
else
true
reset: ->
@setProperties(description: null, value: null)
valueChanged: (->
this.set('valueError', false)
).observes('value')
addErrorsFromResponse: (errArr) ->
error = errArr[0].detail
if error.code == 'not_a_private_key'
this.set('valueError', 'This key is not a private key.')
else if error.code == 'key_with_a_passphrase'
this.set('valueError', 'The key can\'t have a passphrase.')
actions:
save: ->
this.set('valueError', false)
return if @get('isSaving')
@set('isSaving', true)
if @isValid()
ssh_key = @get('model').setProperties(
description: @get('description')
value: @get('value')
)
ssh_key.save().then =>
@set('isSaving', false)
@reset()
@sendAction('sshKeyAdded', ssh_key)
, (error) =>
@set('isSaving', false)
if error.errors
@addErrorsFromResponse(error.errors)
else
@set('isSaving', false)
`export default AddSshKeyComponent`

View File

@ -0,0 +1,82 @@
var AddSshKeyComponent;
export default Ember.Component.extend({
classNames: ['form--sshkey'],
classNameBindings: ['valueError:form-error'],
store: Ember.inject.service(),
isSaving: false,
didInsertElement() {
id = this.get('repo.id');
model = this.get('store').recordForId('ssh_key', id);
if (model) {
this.get('store').dematerializeRecord(model._internalModel);
typeMap = this.get('store').typeMapFor(model.constructor);
idToRecord = typeMap.idToRecord;
delete idToRecord[id];
}
model = this.get('store').createRecord('ssh_key', {
id: id
});
return this.set('model', model);
},
isValid() {
if (Ember.isBlank(this.get('value'))) {
this.set('valueError', 'Value can\'t be blank.');
return false;
} else {
return true;
}
},
reset() {
return this.setProperties({
description: null,
value: null
});
},
valueChanged: function() {
return this.set('valueError', false);
}.observes('value'),
addErrorsFromResponse(errArr) {
var error;
error = errArr[0].detail;
if (error.code === 'not_a_private_key') {
return this.set('valueError', 'This key is not a private key.');
} else if (error.code === 'key_with_a_passphrase') {
return this.set('valueError', 'The key can\'t have a passphrase.');
}
},
actions: {
save() {
var ssh_key;
this.set('valueError', false);
if (this.get('isSaving')) {
return;
}
this.set('isSaving', true);
if (this.isValid()) {
ssh_key = this.get('model').setProperties({
description: this.get('description'),
value: this.get('value')
});
return ssh_key.save().then(() => {
this.set('isSaving', false);
this.reset();
return this.sendAction('sshKeyAdded', ssh_key);
}, () => {
this.set('isSaving', false);
if (error.errors) {
return this.addErrorsFromResponse(error.errors);
}
});
} else {
return this.set('isSaving', false);
}
}
}
});

View File

@ -1,90 +0,0 @@
`import Ember from 'ember'`
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
`import TravisRoute from 'travis/routes/basic'`
`import config from 'travis/config/environment'`
BranchRowComponent = Ember.Component.extend
routing: Ember.inject.service('-routing')
tagName: 'li'
classNameBindings: ['build.last_build.state']
classNames: ['branch-row', 'row-li']
isLoading: false
isTriggering: false
hasTriggered: false
urlGithubCommit: (->
githubCommitUrl(@get('build.repository.slug'), @get('build.last_build.commit.sha'))
).property('build.last_build')
getLast5Builds: (->
lastBuilds = Ember.ArrayProxy.create(
content: [{}, {}, {}, {}, {}]
isLoading: true,
count: 0
)
if !@get('build.last_build')
lastBuilds.set('isLoading', false)
else
apiEndpoint = config.apiEndpoint
repoId = @get('build.repository.id')
branchName = @get('build.name')
options = {}
if @get('auth.signedIn')
options.headers = { Authorization: "token #{@auth.token()}" }
$.ajax("#{apiEndpoint}/v3/repo/#{repoId}/builds?branch.name=#{branchName}&limit=5&build.event_type=push,api", options).then (response) ->
array = response.builds.map( (build) ->
Ember.Object.create(build)
)
if array.length < 5
for i in [1..5 - array.length] by 1
array.push({})
lastBuilds.set('count', response['@pagination'].count)
lastBuilds.set('content', array)
lastBuilds.set('isLoading', false)
lastBuilds
).property()
canTrigger: (->
if !@get('auth.signedIn')
false
else
permissions = @get('auth.currentUser.permissions')
if permissions.contains parseInt(@get('build.repository.id'))
true
else
false
).property()
triggerBuild: (->
apiEndpoint = config.apiEndpoint
repoId = @get('build.repository.id')
options = {
type: 'POST',
body: {
request: {
branch: @get('build.name')
}
}
}
if @get('auth.signedIn')
options.headers = { Authorization: "token #{@auth.token()}" }
$.ajax("#{apiEndpoint}/v3/repo/#{repoId}/requests", options).then (response) =>
@set('isTriggering', false)
@set('hasTriggered', true)
)
actions:
tiggerBuild: (branch) ->
@set('isTriggering', true)
@triggerBuild()
viewAllBuilds: (branch) ->
@get('routing').transitionTo('builds')
`export default BranchRowComponent`

View File

@ -0,0 +1,103 @@
import Ember from 'ember';
import { githubCommit as githubCommitUrl } from 'travis/utils/urls';
import TravisRoute from 'travis/routes/basic';
import config from 'travis/config/environment';
export default Ember.Component.extend({
routing: Ember.inject.service('-routing'),
tagName: 'li',
classNameBindings: ['build.last_build.state'],
classNames: ['branch-row', 'row-li'],
isLoading: false,
isTriggering: false,
hasTriggered: false,
urlGithubCommit: function() {
return githubCommitUrl(this.get('build.repository.slug'), this.get('build.last_build.commit.sha'));
}.property('build.last_build'),
getLast5Builds: function() {
var apiEndpoint, branchName, lastBuilds, options, repoId;
lastBuilds = Ember.ArrayProxy.create({
content: [{}, {}, {}, {}, {}],
isLoading: true,
count: 0
});
if (!this.get('build.last_build')) {
lastBuilds.set('isLoading', false);
} else {
apiEndpoint = config.apiEndpoint;
repoId = this.get('build.repository.id');
branchName = this.get('build.name');
options = {};
if (this.get('auth.signedIn')) {
options.headers = {
Authorization: "token " + (this.auth.token())
};
}
$.ajax(apiEndpoint + "/v3/repo/" + repoId + "/builds?branch.name=" + branchName + "&limit=5&build.event_type=push,api", options).then(function(response) {
var array, i, j, ref;
array = response.builds.map(function(build) {
return Ember.Object.create(build);
});
if (array.length < 5) {
for (i = j = 1, ref = 5 - array.length; j <= ref; i = j += 1) {
array.push({});
}
}
lastBuilds.set('count', response['@pagination'].count);
lastBuilds.set('content', array);
return lastBuilds.set('isLoading', false);
});
}
return lastBuilds;
}.property(),
canTrigger: function() {
var permissions;
if (!this.get('auth.signedIn')) {
return false;
} else {
permissions = this.get('auth.currentUser.permissions');
if (permissions.contains(parseInt(this.get('build.repository.id')))) {
return true;
} else {
return false;
}
}
}.property(),
triggerBuild: function() {
var apiEndpoint, options, repoId;
apiEndpoint = config.apiEndpoint;
repoId = this.get('build.repository.id');
options = {
type: 'POST',
body: {
request: {
branch: this.get('build.name')
}
}
};
if (this.get('auth.signedIn')) {
options.headers = {
Authorization: "token " + (this.auth.token())
};
}
return $.ajax(apiEndpoint + "/v3/repo/" + repoId + "/requests", options).then(() => {
this.set('isTriggering', false);
return this.set('hasTriggered', true);
});
},
actions: {
tiggerBuild(branch) {
this.set('isTriggering', true);
return this.triggerBuild();
},
viewAllBuilds(branch) {
return this.get('routing').transitionTo('builds');
}
}
});

View File

@ -1,24 +0,0 @@
`import Ember from 'ember'`
BroadcastTowerComponent = Ember.Component.extend
classNames: ['broadcast']
isOpen: false
timeoutId: ''
actions:
toggleBroadcasts:() ->
@toggleProperty('isOpen')
@sendAction('toggleBroadcasts')
if @get('isOpen') == true
@set('timeoutId', setTimeout =>
@toggleProperty('isOpen')
@sendAction('toggleBroadcasts')
, 10000
)
else
clearTimeout(@get('timeoutId'))
`export default BroadcastTowerComponent`

View File

@ -0,0 +1,21 @@
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['broadcast'],
isOpen: false,
timeoutId: '',
actions: {
toggleBroadcasts() {
this.toggleProperty('isOpen');
this.sendAction('toggleBroadcasts');
if (this.get('isOpen') === true) {
return this.set('timeoutId', setTimeout(() => {
this.toggleProperty('isOpen');
return this.sendAction('toggleBroadcasts');
}, 10000));
} else {
return clearTimeout(this.get('timeoutId'));
}
}
}
});

View File

@ -1,24 +0,0 @@
`import Ember from 'ember'`
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
`import { durationFrom, safe } from 'travis/utils/helpers'`
`import { githubCommit } from 'travis/utils/urls'`
BuildHeaderComponent = Ember.Component.extend
tagName: 'section'
classNames: ['build-header']
classNameBindings: ['item.state']
isJob: (->
if @get('item.build') then true else false
).property('item')
urlGithubCommit: (->
githubCommit(@get('repo.slug'), @get('commit.sha'))
).property('item')
elapsedTime: (->
durationFrom(@get('item.startedAt'), @get('item.finishedAt'))
).property('item.startedAt', 'item.finishedAt', 'item.duration')
`export default BuildHeaderComponent`

View File

@ -0,0 +1,27 @@
import Ember from 'ember';
import { gravatarImage } from 'travis/utils/urls';
import GithubUrlPropertievs from 'travis/mixins/github-url-properties';
import { durationFrom, safe } from 'travis/utils/helpers';
import { githubCommit } from 'travis/utils/urls';
export default Ember.Component.extend({
tagName: 'section',
classNames: ['build-header'],
classNameBindings: ['item.state'],
isJob: function() {
if (this.get('item.build')) {
return true;
} else {
return false;
}
}.property('item'),
urlGithubCommit: function() {
return githubCommit(this.get('repo.slug'), this.get('commit.sha'));
}.property('item'),
elapsedTime: function() {
return durationFrom(this.get('item.startedAt'), this.get('item.finishedAt'));
}.property('item.startedAt', 'item.finishedAt', 'item.duration')
});

View File

@ -1,9 +0,0 @@
`import Ember from 'ember'`
`import RepoActionsItemComponentMixin from 'travis/utils/repo-actions-item-component-mixin'`
BuildRepoActionsComponent = Ember.Component.extend(RepoActionsItemComponentMixin,
item: Ember.computed.alias('build')
type: 'build'
)
`export default BuildRepoActionsComponent`

View File

@ -0,0 +1,7 @@
import Ember from 'ember';
import RepoActionsItemComponentMixin from 'travis/utils/repo-actions-item-component-mixin';
export default Ember.Component.extend(RepoActionsItemComponentMixin, {
item: Ember.computed.alias('build'),
type: 'build'
});

View File

@ -1,14 +0,0 @@
`import Ember from 'ember'`
BuildTileComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['build.state']
attributeBindings: ['title'],
title: (->
num = @get('build.number')
"##{num}"
).property('build')
`export default BuildTileComponent`

View File

@ -0,0 +1,13 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['build.state'],
attributeBindings: ['title'],
title: function() {
var num;
num = this.get('build.number');
return "#" + num;
}.property('build')
});

View File

@ -1,13 +0,0 @@
`import Ember from 'ember'`
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
BuildsItemComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['build.state']
classNames: ['row-li', 'pr-row']
urlGithubCommit: (->
githubCommitUrl(@get('build.repo.slug'), @get('build.commit.sha'))
).property('build.commit.sha')
`export default BuildsItemComponent`

View File

@ -0,0 +1,12 @@
import Ember from 'ember';
import { githubCommit as githubCommitUrl } from 'travis/utils/urls';
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['build.state'],
classNames: ['row-li', 'pr-row'],
urlGithubCommit: function() {
return githubCommitUrl(this.get('build.repo.slug'), this.get('build.commit.sha'));
}.property('build.commit.sha')
});

View File

@ -1,27 +0,0 @@
`import Ember from 'ember'`
CachesItemComponent = Ember.Component.extend
ajax: Ember.inject.service()
tagName: 'li'
classNames: ['cache-item']
classNameBindings: ['cache.type']
isDeleting: false
actions:
delete: ->
return if @get('isDeleting')
if confirm('Are you sure?')
@set('isDeleting', true)
data = { branch: @get('cache.branch') }
deletingDone = => @set('isDeleting', false)
repo = @get('repo')
@get('ajax').ajax("/repos/#{repo.get('id')}/caches", "DELETE", data: data).then(deletingDone, deletingDone).then =>
@get('caches').removeObject(@get('cache'))
`export default CachesItemComponent`

View File

@ -0,0 +1,33 @@
import Ember from 'ember';
export default Ember.Component.extend({
ajax: Ember.inject.service(),
tagName: 'li',
classNames: ['cache-item'],
classNameBindings: ['cache.type'],
isDeleting: false,
actions: {
"delete": function() {
var data, deletingDone, repo;
if (this.get('isDeleting')) {
return;
}
if (confirm('Are you sure?')) {
this.set('isDeleting', true);
data = {
branch: this.get('cache.branch')
};
deletingDone = () => {
return this.set('isDeleting', false);
};
repo = this.get('repo');
return this.get('ajax').ajax("/repos/" + (repo.get('id')) + "/caches", "DELETE", {
data: data
}).then(deletingDone, deletingDone).then(() => {
return this.get('caches').removeObject(this.get('cache'));
});
}
}
}
});

View File

@ -1,10 +0,0 @@
`import Ember from 'ember'`
Component = Ember.Component.extend(
actions:
close: ->
$('.popup').removeClass('display')
return false
)
`export default Component`

View File

@ -0,0 +1,10 @@
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
close() {
$('.popup').removeClass('display');
return false;
}
}
});

View File

@ -1,55 +0,0 @@
`import Ember from 'ember'`
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
`import config from 'travis/config/environment'`
DashboardRowComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['repo.default_branch.last_build.state']
classNames: ['dashboard-row', 'row-li']
isLoading: false
isTriggering: false
hasTriggered: false
urlGithubCommit: (->
githubCommitUrl(@get('repo.slug'), @get('repo.default_branch.last_build.commit.sha'))
).property('repo')
# canTrigger: (->
# if !@get('auth.signedIn')
# false
# else
# permissions = @get('auth.currentUser.permissions')
# if permissions.contains parseInt(@get('build.repository.id'))
# true
# else
# false
# ).property()
# triggerBuild: (->
# apiEndpoint = config.apiEndpoint
# repoId = @get('build.repository.id')
# options = {
# type: 'POST',
# body: {
# request: {
# branch: @get('build.name')
# }
# }
# }
# if @get('auth.signedIn')
# options.headers = { Authorization: "token #{@auth.token()}" }
# $.ajax("#{apiEndpoint}/v3/repo/#{repoId}/requests", options).then (response) =>
# @set('isTriggering', false)
# @set('hasTriggered', true)
# )
actions:
tiggerBuild: (branch) ->
@set('isTriggering', true)
@triggerBuild()
# viewAllBuilds: (branch) ->
# @get('routing').transitionTo('builds')
`export default DashboardRowComponent`

View File

@ -0,0 +1,23 @@
import Ember from 'ember';
import { githubCommit as githubCommitUrl } from 'travis/utils/urls';
import config from 'travis/config/environment';
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['repo.default_branch.last_build.state'],
classNames: ['dashboard-row', 'row-li'],
isLoading: false,
isTriggering: false,
hasTriggered: false,
urlGithubCommit: function() {
return githubCommitUrl(this.get('repo.slug'), this.get('repo.default_branch.last_build.commit.sha'));
}.property('repo'),
actions: {
tiggerBuild(branch) {
this.set('isTriggering', true);
return this.triggerBuild();
}
}
});

View File

@ -1,29 +0,0 @@
`import Ember from 'ember'`
EnvVarComponent = Ember.Component.extend
classNames: ['settings-envvar']
classNameBindings: ['envVar.public:is-public']
isDeleting: false
validates:
name: ['presence']
actionType: 'Save'
showValueField: Ember.computed.alias('public')
value: ( (key, value) ->
if @get('envVar.public')
@get('envVar.value')
else
'••••••••••••••••'
).property('envVar.value', 'envVar.public')
actions:
delete: ->
return if @get('isDeleting')
@set('isDeleting', true)
@get('envVar').destroyRecord()
`export default EnvVarComponent`

28
app/components/env-var.js Normal file
View File

@ -0,0 +1,28 @@
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['settings-envvar'],
classNameBindings: ['envVar.public:is-public'],
isDeleting: false,
validates: { name: ['presence'] },
actionType: 'Save',
showValueField: Ember.computed.alias('public'),
value: function(key, value) {
if (this.get('envVar.public')) {
return this.get('envVar.value');
} else {
return '••••••••••••••••';
}
}.property('envVar.value', 'envVar.public'),
actions: {
"delete": function() {
if (this.get('isDeleting')) {
return;
}
this.set('isDeleting', true);
return this.get('envVar').destroyRecord();
}
}
});

View File

@ -1,8 +0,0 @@
`import Ember from 'ember'`
EyeIconComponent = Ember.Component.extend
tagName: 'span'
classNames: ['icon-eye']
`export default EyeIconComponent`

View File

@ -0,0 +1,6 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'span',
classNames: ['icon-eye']
});

View File

@ -1,15 +0,0 @@
`import Ember from 'ember'`
FlashDisplayComponent = Ember.Component.extend
flashes: Ember.inject.service()
classNames: ['flash']
tagName: 'ul'
messagesBinding: 'flashes.messages'
actions:
closeMessage: (msg) ->
@get('flashes').close(msg)
`export default FlashDisplayComponent`

View File

@ -0,0 +1,14 @@
import Ember from 'ember';
export default Ember.Component.extend({
flashes: Ember.inject.service(),
classNames: ['flash'],
tagName: 'ul',
messagesBinding: 'flashes.messages',
actions: {
closeMessage(msg) {
return this.get('flashes').close(msg);
}
}
});

View File

@ -1,15 +0,0 @@
`import Ember from 'ember'`
FlashItemComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['type']
type: (->
@get('flash.type') || 'broadcast'
).property('flash.type')
actions:
close: ->
this.attrs.close(@get('flash'))
`export default FlashItemComponent`

View File

@ -0,0 +1,16 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['type'],
type: function() {
return this.get('flash.type') || 'broadcast';
}.property('flash.type'),
actions: {
close() {
return this.attrs.close(this.get('flash'));
}
}
});

View File

@ -1,18 +0,0 @@
`import Ember from 'ember'`
HookSwitchComponent = Ember.Component.extend
tagName: 'a'
classNames: ['switch--icon']
classNameBindings: ['active']
activeBinding: "hook.active"
click: ->
@sendAction('onToggle')
hook = @get('hook')
hook.toggle().then( (->), =>
@toggleProperty('hook.active')
@sendAction('onToggleError', hook)
)
`export default HookSwitchComponent`

View File

@ -0,0 +1,17 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'a',
classNames: ['switch--icon'],
classNameBindings: ['active'],
activeBinding: "hook.active",
click() {
var hook;
this.sendAction('onToggle');
hook = this.get('hook');
return hook.toggle().then((function() {}), () => {
this.toggleProperty('hook.active');
return this.sendAction('onToggleError', hook);
});
}
});

View File

@ -1,21 +0,0 @@
`import Ember from 'ember'`
`import config from 'travis/config/environment'`
HooksListItemComponent = Ember.Component.extend
tagName: 'li'
classNames: ['row']
classNameBindings: ['hook.active:active']
githubOrgsOauthAccessSettingsUrl: config.githubOrgsOauthAccessSettingsUrl
actions:
handleToggleError: ->
@set("showError", true)
close: ->
@send('resetErrors')
resetErrors: ->
@set("showError", false)
`export default HooksListItemComponent`

View File

@ -0,0 +1,23 @@
import Ember from 'ember';
import config from 'travis/config/environment';
export default Ember.Component.extend({
tagName: 'li',
classNames: ['row'],
classNameBindings: ['hook.active:active'],
githubOrgsOauthAccessSettingsUrl: config.githubOrgsOauthAccessSettingsUrl,
actions: {
handleToggleError() {
return this.set("showError", true);
},
close() {
return this.send('resetErrors');
},
resetErrors() {
return this.set("showError", false);
}
}
});

View File

@ -1,30 +0,0 @@
`import Ember from 'ember'`
JobLogComponent = Ember.Component.extend
logBinding: 'job.log'
didInsertElement: ->
@setupLog()
logDidChange: (->
@setupLog()
).observes('log')
logWillChange: (->
@teardownLog()
).observesBefore('log')
willDestroyElement: ->
@teardownLog()
teardownLog: ->
job = @get('job')
job.unsubscribe() if job
setupLog: ->
job = @get('job')
if job
job.get('log').fetch()
job.subscribe()
`export default JobLogComponent`

38
app/components/job-log.js Normal file
View File

@ -0,0 +1,38 @@
import Ember from 'ember';
export default Ember.Component.extend({
logBinding: 'job.log',
didInsertElement() {
return this.setupLog();
},
logDidChange: function() {
return this.setupLog();
}.observes('log'),
logWillChange: function() {
return this.teardownLog();
}.observesBefore('log'),
willDestroyElement() {
return this.teardownLog();
},
teardownLog() {
var job;
job = this.get('job');
if (job) {
return job.unsubscribe();
}
},
setupLog() {
var job;
job = this.get('job');
if (job) {
job.get('log').fetch();
return job.subscribe();
}
}
});

View File

@ -1,9 +0,0 @@
`import Ember from 'ember'`
`import RepoActionsItemComponentMixin from 'travis/utils/repo-actions-item-component-mixin'`
JobRepoActionsComponent = Ember.Component.extend(RepoActionsItemComponentMixin,
item: Ember.computed.alias('job')
type: 'job'
)
`export default JobRepoActionsComponent`

View File

@ -0,0 +1,7 @@
import Ember from 'ember';
import RepoActionsItemComponentMixin from 'travis/utils/repo-actions-item-component-mixin';
export default Ember.Component.extend(RepoActionsItemComponentMixin, {
item: Ember.computed.alias('job'),
type: 'job'
});

View File

@ -1,32 +0,0 @@
`import Ember from 'ember'`
`import { colorForState } from 'travis/utils/helpers'`
`import { languageConfigKeys } from 'travis/utils/keys-map';`
JobsItemComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['job.state']
classNames: ['jobs-item']
languages: (->
output = []
if config = @get('job.config')
for key, languageName of languageConfigKeys
if version = config[key]
output.push(languageName + ': ' + version)
gemfile = @get('job.config.gemfile')
if gemfile && @get('job.config.env')
output.push "Gemfile: #{gemfile}"
output.join(' ')
).property('job.config')
environment: (->
if env = @get('job.config.env')
env
else if gemfile = @get('job.config.gemfile')
"Gemfile: #{gemfile}"
).property('job.config.env', 'job.config.gemfile')
`export default JobsItemComponent`

View File

@ -0,0 +1,36 @@
import Ember from 'ember';
import { colorForState } from 'travis/utils/helpers';
import { languageConfigKeys } from 'travis/utils/keys-map';;
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['job.state'],
classNames: ['jobs-item'],
languages: function() {
var config, gemfile, key, languageName, output, version;
output = [];
if (config = this.get('job.config')) {
for (key in languageConfigKeys) {
languageName = languageConfigKeys[key];
if (version = config[key]) {
output.push(languageName + ': ' + version);
}
}
gemfile = this.get('job.config.gemfile');
if (gemfile && this.get('job.config.env')) {
output.push("Gemfile: " + gemfile);
}
}
return output.join(' ');
}.property('job.config'),
environment: function() {
var env, gemfile;
if (env = this.get('job.config.env')) {
return env;
} else if (gemfile = this.get('job.config.gemfile')) {
return "Gemfile: " + gemfile;
}
}.property('job.config.env', 'job.config.gemfile')
});

View File

@ -1,15 +0,0 @@
`import Ember from 'ember'`
JobsListComponent = Ember.Component.extend
tagName: 'section'
classNames: ['jobs']
jobTableId: Ember.computed(->
if @get('required')
'jobs'
else
'allowed_failure_jobs'
)
`export default JobsListComponent`

View File

@ -0,0 +1,13 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'section',
classNames: ['jobs'],
jobTableId: Ember.computed(function() {
if (this.get('required')) {
return 'jobs';
} else {
return 'allowed_failure_jobs';
}
})
});

View File

@ -1,12 +0,0 @@
`import Ember from 'ember'`
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
`import TravisRoute from 'travis/routes/basic'`
`import config from 'travis/config/environment'`
LandingRowComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['repo.lastBuildState']
classNames: ['landing-row', 'row-li']
`export default LandingRowComponent`

View File

@ -0,0 +1,10 @@
import Ember from 'ember';
import { githubCommit as githubCommitUrl } from 'travis/utils/urls';
import TravisRoute from 'travis/routes/basic';
import config from 'travis/config/environment';
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['repo.lastBuildState'],
classNames: ['landing-row', 'row-li']
});

View File

@ -1,40 +0,0 @@
`import Ember from 'ember'`
LimitConcurrentBuildsComponent = Ember.Component.extend
classNames: ['limit-concurrent-builds']
description: (->
description = "Limit concurrent jobs"
if @get('enabled')
description += " "
description
).property('enabled')
limitChanged: ->
repo = @get('repo')
limit = parseInt(@get('value'))
if limit
@set('isSaving', true)
savingFinished = =>
@set('isSaving', false)
repo.saveSettings(maximum_number_of_builds: limit).
then(savingFinished, savingFinished)
actions:
toggle: ->
unless @get('enabled')
return if @get('value') == 0
return if @get('isSaving')
@set('isSaving', true)
savingFinished = =>
@set('isSaving', false)
@get('repo').saveSettings(maximum_number_of_builds: 0).then(savingFinished, savingFinished)
@set('value', 0)
limitChanged: ->
Ember.run.debounce(this, 'limitChanged', 1000)
`export default LimitConcurrentBuildsComponent`

View File

@ -0,0 +1,55 @@
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['limit-concurrent-builds'],
description: function() {
var description;
description = "Limit concurrent jobs";
if (this.get('enabled')) {
description += " ";
}
return description;
}.property('enabled'),
limitChanged() {
var limit, repo, savingFinished;
repo = this.get('repo');
limit = parseInt(this.get('value'));
if (limit) {
this.set('isSaving', true);
savingFinished = () => {
return this.set('isSaving', false);
};
return repo.saveSettings({
maximum_number_of_builds: limit
}).then(savingFinished, savingFinished);
}
},
actions: {
toggle() {
var savingFinished;
if (!this.get('enabled')) {
if (this.get('value') === 0) {
return;
}
if (this.get('isSaving')) {
return;
}
this.set('isSaving', true);
savingFinished = () => {
return this.set('isSaving', false);
};
this.get('repo').saveSettings({
maximum_number_of_builds: 0
}).then(savingFinished, savingFinished);
return this.set('value', 0);
}
},
limitChanged() {
return Ember.run.debounce(this, 'limitChanged', 1000);
}
}
});

View File

@ -1,8 +0,0 @@
`import Ember from 'ember'`
LoadingIndicatorComponent = Ember.Component.extend
tagName: 'div'
classNameBindings: ['center:loading-container', 'inline:inline-block', 'height:icon-height']
center: false
`export default LoadingIndicatorComponent`

View File

@ -0,0 +1,7 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'div',
classNameBindings: ['center:loading-container', 'inline:inline-block', 'height:icon-height'],
center: false
});

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) {
@ -90,8 +90,8 @@ export default Ember.Component.extend({
if ((ref = this.lineSelector) != null) { if ((ref = this.lineSelector) != null) {
ref.willDestroy(); ref.willDestroy();
} }
if (logElement = this.$('#log')[0]) { if (logElement = this.$('#log')) {
logElement.innerHTML = ''; return logElement.empty();
} }
} }
}, },
@ -99,8 +99,8 @@ export default Ember.Component.extend({
createEngine(log) { createEngine(log) {
var logElement; var logElement;
if (log || (log = this.get('log'))) { if (log || (log = this.get('log'))) {
if (logElement = this.$('#log')[0]) { if (logElement = this.$('#log')) {
logElement.innerHTML = ''; logElement.empty();
} }
log.onClear(() => { log.onClear(() => {
this.teardownLog(); this.teardownLog();
@ -212,7 +212,7 @@ export default Ember.Component.extend({
toggleTailing() { toggleTailing() {
Travis.tailing.toggle(); Travis.tailing.toggle();
this.engine.autoCloseFold = !Travis.tailing.isActive(); this.engine.autoCloseFold = !Travis.tailing.isActive();
return false; return event.preventDefault();
}, },
removeLogPopup() { removeLogPopup() {

View File

@ -1,19 +0,0 @@
`import Ember from 'ember'`
`import config from 'travis/config/environment'`
NoBuildsComponent = Ember.Component.extend
actions:
triggerBuild: () ->
@set('isLoading', true)
apiEndpoint = config.apiEndpoint
$.ajax(apiEndpoint + "/v3/repo/#{@get('repo.repo.id')}/requests", {
headers: {
Authorization: 'token ' + @get('repo.auth')
},
type: "POST"
}).then( =>
@set('isLoading', false)
# @transitionToRoute('repo')
);
`export default NoBuildsComponent`

View File

@ -0,0 +1,20 @@
import Ember from 'ember';
import config from 'travis/config/environment';
export default Ember.Component.extend({
actions: {
triggerBuild() {
var apiEndpoint;
this.set('isLoading', true);
apiEndpoint = config.apiEndpoint;
return $.ajax(apiEndpoint + ("/v3/repo/" + (this.get('repo.repo.id')) + "/requests"), {
headers: {
Authorization: 'token ' + this.get('repo.auth')
},
type: "POST"
}).then(() => {
return this.set('isLoading', false);
});
}
}
});

View File

@ -1,5 +0,0 @@
`import Ember from 'ember'`
NoReposComponent = Ember.Component.extend()
`export default NoReposComponent`

View File

@ -0,0 +1,3 @@
import Ember from 'ember';
export default Ember.Component.extend();

View File

@ -1,5 +0,0 @@
`import Ember from 'ember'`
NotActiveComponent = Ember.Component.extend()
`export default NotActiveComponent`

View File

@ -0,0 +1,3 @@
import Ember from 'ember';
export default Ember.Component.extend();

View File

@ -1,28 +0,0 @@
`import Ember from 'ember'`
OrgItemComponent = Ember.Component.extend
classNames: ['media', 'account']
tagName: 'li'
classNameBindings: ['type', 'selected']
typeBinding: 'account.type'
selectedBinding: 'account.selected'
tokenIsVisible: false
name: (->
@get('account.name') || @get('account.login')
).property('account')
avatarUrl: (->
@get('account.avatarUrl') || false
).property('account')
isUser: (->
@get('account.type') == 'user'
).property('account')
actions:
tokenVisibility: () ->
@toggleProperty('tokenIsVisible')
`export default OrgItemComponent`

View File

@ -0,0 +1,28 @@
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['media', 'account'],
tagName: 'li',
classNameBindings: ['type', 'selected'],
typeBinding: 'account.type',
selectedBinding: 'account.selected',
tokenIsVisible: false,
name: function() {
return this.get('account.name') || this.get('account.login');
}.property('account'),
avatarUrl: function() {
return this.get('account.avatarUrl') || false;
}.property('account'),
isUser: function() {
return this.get('account.type') === 'user';
}.property('account'),
actions: {
tokenVisibility() {
return this.toggleProperty('tokenIsVisible');
}
}
});

View File

@ -1,13 +0,0 @@
`import Ember from 'ember'`
Component = Ember.Component.extend
actions:
toggleOrgFilter: () ->
@toggleProperty('showFilter')
false
select: (org) ->
@toggleProperty('showFilter')
@sendAction('action', org)
`export default Component`

View File

@ -0,0 +1,15 @@
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
toggleOrgFilter() {
this.toggleProperty('showFilter');
return false;
},
select(org) {
this.toggleProperty('showFilter');
return this.sendAction('action', org);
}
}
});

View File

@ -1,29 +0,0 @@
`import Ember from 'ember'`
OwnerRepoTileComponent = Ember.Component.extend
tagName: 'li'
classNames: ['owner-tile', 'row-li']
classNameBindings: ['repo.default_branch.last_build.state']
ownerName: (->
@get('repo.slug').split(/\//)[0]
).property('repo.slug')
repoName: (->
@get('repo.slug').split(/\//)[1]
).property('repo.slug')
isAnimating: (->
state = @get('repo.default_branch.last_build.state')
animationStates = ['received', 'queued', 'started', 'booting']
unless animationStates.indexOf(state) == -1
true
).property('repo.default_branch.last_build.state')
`export default OwnerRepoTileComponent`

View File

@ -0,0 +1,24 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'li',
classNames: ['owner-tile', 'row-li'],
classNameBindings: ['repo.default_branch.last_build.state'],
ownerName: function() {
return this.get('repo.slug').split(/\//)[0];
}.property('repo.slug'),
repoName: function() {
return this.get('repo.slug').split(/\//)[1];
}.property('repo.slug'),
isAnimating: function() {
var animationStates, state;
state = this.get('repo.default_branch.last_build.state');
animationStates = ['received', 'queued', 'started', 'booting'];
if (animationStates.indexOf(state) !== -1) {
return true;
}
}.property('repo.default_branch.last_build.state')
});

View File

@ -1,6 +0,0 @@
`import Ember from 'ember'`
`import SyncButton from 'travis/components/sync-button'`
Component = SyncButton.extend()
`export default Component`

View File

@ -0,0 +1,4 @@
import Ember from 'ember';
import SyncButton from 'travis/components/sync-button';
export default SyncButton.extend();

View File

@ -1,16 +0,0 @@
`import Ember from 'ember'`
`import config from 'travis/config/environment'`
QueuedJobsComponent = Ember.Component.extend
store: Ember.inject.service()
init: ->
@_super.apply this, arguments
if !Ember.testing
Visibility.every config.intervals.updateTimes, @updateTimes.bind(this)
updateTimes: ->
if jobs = @get('jobs')
jobs.forEach (job) -> job.updateTimes()
`export default QueuedJobsComponent`

View File

@ -0,0 +1,21 @@
import Ember from 'ember';
import config from 'travis/config/environment';
export default Ember.Component.extend({
store: Ember.inject.service(),
init() {
this._super.apply(this, arguments);
if (!Ember.testing) {
return Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},
updateTimes() {
var jobs;
if (jobs = this.get('jobs')) {
return jobs.forEach(function(job) {
return job.updateTimes();
});
}
}
});

View File

@ -1,23 +0,0 @@
`import Ember from 'ember'`
Component = Ember.Component.extend(
actions:
close: ->
$('.popup').removeClass('display')
return false
removeLog: ->
$('.popup').removeClass('display')
job = @get('job')
job.removeLog().then ->
Travis.flash(success: 'Log has been successfully removed.')
, (xhr) ->
if xhr.status == 409
Travis.flash(error: 'Log can\'t be removed')
else if xhr.status == 401
Travis.flash(error: 'You don\'t have sufficient access to remove the log')
else
Travis.flash(error: 'An error occured when removing the log')
)
`export default Component`

View File

@ -0,0 +1,27 @@
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
close() {
$('.popup').removeClass('display');
return false;
},
removeLog() {
var job = this.get('job');
$('.popup').removeClass('display');
return job.removeLog().then(function() {
return Travis.flash({ success: 'Log has been successfully removed.' });
}, function(xhr) {
if (xhr.status === 409) {
return Travis.flash({ error: 'Log can\'t be removed' });
} else if (xhr.status === 401) {
return Travis.flash({ error: 'You don\'t have sufficient access to remove the log' });
} else {
return Travis.flash({ error: 'An error occured when removing the log' });
}
});
}
}
});

View File

@ -1,15 +0,0 @@
`import Ember from 'ember'`
RepoActionsComponent = Ember.Component.extend(
displayCodeClimate: (->
@get('repo.githubLanguage') == 'Ruby'
).property('repo.githubLanguage')
actions:
codeClimatePopup: ->
$('.popup').removeClass('display')
$('#code-climate').addClass('display')
return false
)
`export default RepoActionsComponent`

View File

@ -0,0 +1,15 @@
import Ember from 'ember';
export default Ember.Component.extend({
displayCodeClimate: function() {
return this.get('repo.githubLanguage') === 'Ruby';
}.property('repo.githubLanguage'),
actions: {
codeClimatePopup() {
$('.popup').removeClass('display');
$('#code-climate').addClass('display');
return false;
}
}
});

View File

@ -1,55 +0,0 @@
`import Ember from 'ember'`
RepoShowTabsComponent = Ember.Component.extend
tagName: 'nav'
classNames: ['tabnav']
ariaRole: 'tablist'
# hrm. how to parametrize bind-attr?
classCurrent: (->
'active' if @get('tab') == 'current'
).property('tab')
classBuilds: (->
'active' if @get('tab') == 'builds'
).property('tab')
classPullRequests: (->
'active' if @get('tab') == 'pull_requests'
).property('tab')
classBranches: (->
'active' if @get('tab') == 'branches'
).property('tab')
classBuild: (->
tab = @get('tab')
classes = []
classes.push('active') if tab == 'build'
classes.push('display-inline') if tab == 'build' || tab == 'job'
classes.join(' ')
).property('tab')
# TODO: refactor tabs, most of the things here are not really DRY
classJob: (->
'active' if @get('tab') == 'job'
).property('tab')
classRequests: (->
'active' if @get('tab') == 'requests'
).property('tab')
classCaches: (->
'active' if @get('tab') == 'caches'
).property('tab')
classSettings: (->
'active' if @get('tab') == 'settings'
).property('tab')
classRequest: (->
'active' if @get('tab') == 'request'
).property('tab')
`export default RepoShowTabsComponent`

View File

@ -0,0 +1,74 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'nav',
classNames: ['tabnav'],
ariaRole: 'tablist',
classCurrent: function() {
if (this.get('tab') === 'current') {
return 'active';
}
}.property('tab'),
classBuilds: function() {
if (this.get('tab') === 'builds') {
return 'active';
}
}.property('tab'),
classPullRequests: function() {
if (this.get('tab') === 'pull_requests') {
return 'active';
}
}.property('tab'),
classBranches: function() {
if (this.get('tab') === 'branches') {
return 'active';
}
}.property('tab'),
classBuild: function() {
var classes, tab;
tab = this.get('tab');
classes = [];
if (tab === 'build') {
classes.push('active');
}
if (tab === 'build' || tab === 'job') {
classes.push('display-inline');
}
return classes.join(' ');
}.property('tab'),
classJob: function() {
if (this.get('tab') === 'job') {
return 'active';
}
}.property('tab'),
classRequests: function() {
if (this.get('tab') === 'requests') {
return 'active';
}
}.property('tab'),
classCaches: function() {
if (this.get('tab') === 'caches') {
return 'active';
}
}.property('tab'),
classSettings: function() {
if (this.get('tab') === 'settings') {
return 'active';
}
}.property('tab'),
classRequest: function() {
if (this.get('tab') === 'request') {
return 'active';
}
}.property('tab')
});

View File

@ -1,49 +0,0 @@
`import Ember from 'ember'`
`import config from 'travis/config/environment'`
RepoShowToolsComponent = Ember.Component.extend
popup: Ember.inject.service()
classNames: ['settings-menu']
classNameBindings: ['isOpen:display']
isOpen: false
click: (event) ->
if $(event.target).is('a') && $(event.target).parents('.settings-dropdown').length
@closeMenu()
closeMenu: ->
@toggleProperty('isOpen')
actions:
menu: ->
@toggleProperty('isOpen')
hasPermission: (->
if permissions = @get('currentUser.permissions')
permissions.contains parseInt(@get('repo.id'))
).property('currentUser.permissions.length', 'repo.id')
hasPushPermission: (->
if permissions = @get('currentUser.pushPermissions')
permissions.contains parseInt(@get('repo.id'))
).property('currentUser.pushPermissions.length', 'repo.id')
hasAdminPermission: (->
if permissions = @get('currentUser.adminPermissions')
permissions.contains parseInt(@get('repo.id'))
).property('currentUser.adminPermissions.length', 'repo.id')
displaySettingsLink: (->
@get('hasPushPermission')
).property('hasPushPermission')
displayCachesLink: (->
@get('hasPushPermission') && config.endpoints.caches
).property('hasPushPermission')
displayStatusImages: (->
@get('hasPermission')
).property('hasPermission')
`export default RepoShowToolsComponent`

View File

@ -0,0 +1,58 @@
import Ember from 'ember';
import config from 'travis/config/environment';
export default Ember.Component.extend({
popup: Ember.inject.service(),
classNames: ['settings-menu'],
classNameBindings: ['isOpen:display'],
isOpen: false,
click(event) {
if ($(event.target).is('a') && $(event.target).parents('.settings-dropdown').length) {
return this.closeMenu();
}
},
closeMenu() {
return this.toggleProperty('isOpen');
},
actions: {
menu() {
return this.toggleProperty('isOpen');
}
},
hasPermission: function() {
var permissions;
if (permissions = this.get('currentUser.permissions')) {
return permissions.contains(parseInt(this.get('repo.id')));
}
}.property('currentUser.permissions.length', 'repo.id'),
hasPushPermission: function() {
var permissions;
if (permissions = this.get('currentUser.pushPermissions')) {
return permissions.contains(parseInt(this.get('repo.id')));
}
}.property('currentUser.pushPermissions.length', 'repo.id'),
hasAdminPermission: function() {
var permissions;
if (permissions = this.get('currentUser.adminPermissions')) {
return permissions.contains(parseInt(this.get('repo.id')));
}
}.property('currentUser.adminPermissions.length', 'repo.id'),
displaySettingsLink: function() {
return this.get('hasPushPermission');
}.property('hasPushPermission'),
displayCachesLink: function() {
return this.get('hasPushPermission') && config.endpoints.caches;
}.property('hasPushPermission'),
displayStatusImages: function() {
return this.get('hasPermission');
}.property('hasPermission')
});

View File

@ -1,5 +0,0 @@
`import Ember from 'ember'`
ReposEmptyComponent = Ember.Component.extend()
`export default ReposEmptyComponent`

View File

@ -0,0 +1,3 @@
import Ember from 'ember';
export default Ember.Component.extend();

View File

@ -1,31 +0,0 @@
`import Ember from 'ember'`
`import Polling from 'travis/mixins/polling'`
`import { colorForState } from 'travis/utils/helpers'`
ReposListItemComponent = Ember.Component.extend Polling,
routing: Ember.inject.service('-routing')
tagName: 'li'
pollModels: 'repo'
classNames: ['repo']
classNameBindings: ['selected']
selected: (->
@get('repo') == @get('selectedRepo')
).property('selectedRepo')
color: (->
colorForState(@get('repo.lastBuildState'))
).property('repo.lastBuildState')
scrollTop: (->
if (window.scrollY > 0)
$('html, body').animate({scrollTop: 0}, 200)
)
click: ->
@scrollTop()
@get('routing').transitionTo('repo', @get('repo.slug').split('/'))
`export default ReposListItemComponent`

View File

@ -0,0 +1,32 @@
import Ember from 'ember';
import Polling from 'travis/mixins/polling';
import { colorForState } from 'travis/utils/helpers';
export default Ember.Component.extend(Polling, {
routing: Ember.inject.service('-routing'),
tagName: 'li',
pollModels: 'repo',
classNames: ['repo'],
classNameBindings: ['selected'],
selected: function() {
return this.get('repo') === this.get('selectedRepo');
}.property('selectedRepo'),
color: function() {
return colorForState(this.get('repo.lastBuildState'));
}.property('repo.lastBuildState'),
scrollTop: function() {
if (window.scrollY > 0) {
return $('html, body').animate({
scrollTop: 0
}, 200);
}
},
click() {
this.scrollTop();
return this.get('routing').transitionTo('repo', this.get('repo.slug').split('/'));
}
});

View File

@ -1,25 +0,0 @@
`import Ember from 'ember'`
RequestIconComponent = Ember.Component.extend
tagName: 'span'
classNames: ['status-icon', 'icon']
classNameBindings: ['event', 'state']
isPush: (->
@get('event') == 'push'
).property('event')
isPR: (->
@get('event') == 'pull_request'
).property('event')
isAPI: (->
@get('event') == 'api'
).property('event')
isEmpty: (->
true if @get('event') == null || @get('event') == null
).property('event')
`export default RequestIconComponent`

View File

@ -0,0 +1,25 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'span',
classNames: ['status-icon', 'icon'],
classNameBindings: ['event', 'state'],
isPush: function() {
return this.get('event') === 'push';
}.property('event'),
isPR: function() {
return this.get('event') === 'pull_request';
}.property('event'),
isAPI: function() {
return this.get('event') === 'api';
}.property('event'),
isEmpty: function() {
if (this.get('event') === null || this.get('event') === null) {
return true;
}
}.property('event')
});

View File

@ -1,45 +0,0 @@
`import Ember from 'ember'`
`import config from 'travis/config/environment'`
RequestsItemComponent = Ember.Component.extend
classNames: ['request-item']
classNameBindings: ['requestClass']
tagName: 'li'
requestClass: (->
if @get('request.isAccepted')
'accepted'
else
'rejected'
).property('content.isAccepted')
type: (->
if @get('request.isPullRequest')
'pull_request'
else
'push'
).property('request.isPullRequest')
status: (->
if @get('request.isAccepted')
'Accepted'
else
'Rejected'
).property('request.isAccepted')
hasBranchName: (->
@get('request.branchName')
).property('request')
message: (->
message = @get('request.message')
if config.pro && message == "private repository"
''
else if !message
'Build created successfully '
else
message
).property('request.message')
`export default RequestsItemComponent`

View File

@ -0,0 +1,48 @@
import Ember from 'ember';
import config from 'travis/config/environment';
export default Ember.Component.extend({
classNames: ['request-item'],
classNameBindings: ['requestClass'],
tagName: 'li',
requestClass: function() {
if (this.get('request.isAccepted')) {
return 'accepted';
} else {
return 'rejected';
}
}.property('content.isAccepted'),
type: function() {
if (this.get('request.isPullRequest')) {
return 'pull_request';
} else {
return 'push';
}
}.property('request.isPullRequest'),
status: function() {
if (this.get('request.isAccepted')) {
return 'Accepted';
} else {
return 'Rejected';
}
}.property('request.isAccepted'),
hasBranchName: function() {
return this.get('request.branchName');
}.property('request'),
message: function() {
var message;
message = this.get('request.message');
if (config.pro && message === "private repository") {
return '';
} else if (!message) {
return 'Build created successfully ';
} else {
return message;
}
}.property('request.message')
});

View File

@ -1,8 +0,0 @@
`import Ember from 'ember'`
`import Polling from 'travis/mixins/polling'`
RunningJobsItemComponent = Ember.Component.extend(Polling,
pollModels: 'job'
)
`export default RunningJobsItemComponent`

View File

@ -0,0 +1,6 @@
import Ember from 'ember';
import Polling from 'travis/mixins/polling';
export default Ember.Component.extend(Polling, {
pollModels: 'job'
});

View File

@ -1,20 +0,0 @@
`import Ember from 'ember'`
`import Polling from 'travis/mixins/polling'`
`import config from 'travis/config/environment'`
RunningJobsComponent = Ember.Component.extend Polling,
store: Ember.inject.service()
pollHook: (store) ->
@get('store').find('job', {})
init: ->
@_super.apply this, arguments
if !Ember.testing
Visibility.every config.intervals.updateTimes, @updateTimes.bind(this)
updateTimes: ->
if jobs = @get('jobs')
jobs.forEach (job) -> job.updateTimes()
`export default RunningJobsComponent`

View File

@ -0,0 +1,27 @@
import Ember from 'ember';
import Polling from 'travis/mixins/polling';
import config from 'travis/config/environment';
export default Ember.Component.extend(Polling, {
store: Ember.inject.service(),
pollHook(store) {
return this.get('store').find('job', {});
},
init() {
this._super.apply(this, arguments);
if (!Ember.testing) {
return Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},
updateTimes() {
var jobs;
if (jobs = this.get('jobs')) {
return jobs.forEach(function(job) {
return job.updateTimes();
});
}
}
});

View File

@ -1,21 +0,0 @@
`import Ember from 'ember'`
SettingsSwitchComponent = Ember.Component.extend
tagName: 'a'
classNames: ['switch']
classNameBindings: ['active']
click: ->
return if @get('isSaving')
@set('isSaving', true)
@toggleProperty('active')
setting = {}
setting[@get('key')] = @get('active')
@get('repo').saveSettings(setting).then =>
@set('isSaving', false)
, =>
@set('isSaving', false)
Travis.flash(error: 'There was an error while saving settings. Please try again.')
`export default SettingsSwitchComponent`

View File

@ -0,0 +1,26 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'a',
classNames: ['switch'],
classNameBindings: ['active'],
click() {
var setting;
if (this.get('isSaving')) {
return;
}
this.set('isSaving', true);
this.toggleProperty('active');
setting = {};
setting[this.get('key')] = this.get('active');
return this.get('repo').saveSettings(setting).then(() => {
return this.set('isSaving', false);
}, () => {
this.set('isSaving', false);
return Travis.flash({
error: 'There was an error while saving settings. Please try again.'
});
});
}
});

View File

@ -1,19 +0,0 @@
`import Ember from 'ember'`
ShowMoreButtonComponent = Ember.Component.extend
tagName: 'button'
classNames: ['showmore-button']
classNameBindings: ['isLoading', 'showMore']
showMore: true
attributeBindings: ['disabled']
disabledBinding: 'isLoading'
buttonLabel: (->
if @get('isLoading') then 'Loading' else 'Show more'
).property('isLoading')
click: ->
this.attrs.showMore()
`export default ShowMoreButtonComponent`

View File

@ -0,0 +1,22 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
classNames: ['showmore-button'],
classNameBindings: ['isLoading', 'showMore'],
showMore: true,
attributeBindings: ['disabled'],
disabledBinding: 'isLoading',
buttonLabel: function() {
if (this.get('isLoading')) {
return 'Loading';
} else {
return 'Show more';
}
}.property('isLoading'),
click() {
return this.attrs.showMore();
}
});

View File

@ -1,20 +0,0 @@
`import Ember from 'ember'`
SshKeyComponent = Ember.Component.extend
classNames: ['settings-sshkey']
isDeleting: false
actions:
delete: ->
return if @get('isDeleting')
@set('isDeleting', true)
deletingDone = => @set('isDeleting', false)
@get('key').deleteRecord()
@get('key').save().then(deletingDone, deletingDone).then =>
@sendAction('sshKeyDeleted')
`export default SshKeyComponent`

22
app/components/ssh-key.js Normal file
View File

@ -0,0 +1,22 @@
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['settings-sshkey'],
isDeleting: false,
actions: {
"delete": function() {
var deletingDone;
if (this.get('isDeleting')) {
return;
}
this.set('isDeleting', true);
deletingDone = () => {
return this.set('isDeleting', false);
};
this.get('key').deleteRecord();
return this.get('key').save().then(deletingDone, deletingDone).then(() => {
return this.sendAction('sshKeyDeleted');
});
}
}
});

Some files were not shown because too many files have changed in this diff Show More