More ember-cli compat changes

This commit is contained in:
Piotr Sarnacki 2015-01-29 12:54:27 +01:00
parent e00d5d5d5c
commit f94ff75a13
60 changed files with 366 additions and 531 deletions

View File

@ -1,5 +1,8 @@
Adapter = DS.ActiveModelAdapter.extend
host: Travis.config.api_endpoint
host: (->
Travis.config.api_endpoint
).property()
ajaxOptions: (url, type, options) ->
hash = @_super(url, type, options)

View File

@ -1,126 +1,126 @@
unless window.TravisApplication
window.TravisApplication = Em.Application.extend(Ember.Evented,
LOG_TRANSITIONS: true,
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
setup: ->
@pusher = new Travis.Pusher(key: Travis.config.pusher_key, host: Travis.config.pusher_host) if Travis.config.pusher_key
@tailing = new Travis.Tailing($(window), '#tail', '#log')
@toTop = new Travis.ToTop($(window), '.to-top', '#log-container')
setup: ->
@pusher = new Travis.Pusher(key: Travis.config.pusher_key, host: Travis.config.pusher_host) if Travis.config.pusher_key
@tailing = new Travis.Tailing($(window), '#tail', '#log')
@toTop = new Travis.ToTop($(window), '.to-top', '#log-container')
@on 'user:signed_in', (user) ->
Travis.onUserUpdate(user)
@on 'user:signed_in', (user) ->
Travis.onUserUpdate(user)
@on 'user:synced', (user) ->
Travis.onUserUpdate(user)
@on 'user:synced', (user) ->
Travis.onUserUpdate(user)
reset: ->
@_super.apply(this, arguments)
@get('modelClasses').forEach (klass) ->
klass.resetData()
@setup()
lookup: ->
@__container__.lookup.apply @__container__, arguments
lookup: ->
@__container__.lookup.apply @__container__, arguments
flash: (options) ->
Travis.lookup('controller:flash').loadFlashes([options])
flash: (options) ->
Travis.lookup('controller:flash').loadFlashes([options])
receive: (event, data) ->
[name, type] = event.split(':')
receive: (event, data) ->
[name, type] = event.split(':')
store = @__container__.lookup('store:main')
store = @__container__.lookup('store:main')
if name == 'job' && data.job?.commit
store.pushPayload(commits: [data.job.commit])
if name == 'job' && data.job?.commit
store.pushPayload(commits: [data.job.commit])
if name == 'build' && data.build?.commit
# TODO: commit should be a sideload record on build, not mixed with it
build = data.build
commit = {
id: build.commit_id
author_email: build.author_email
author_name: build.author_name
branch: build.branch
committed_at: build.committed_at
committer_email: build.committer_email
committer_name: build.committer_name
compare_url: build.compare_url
message: build.message
sha: build.commit
}
delete(data.build.commit)
if name == 'build' && data.build?.commit
# TODO: commit should be a sideload record on build, not mixed with it
build = data.build
commit = {
id: build.commit_id
author_email: build.author_email
author_name: build.author_name
branch: build.branch
committed_at: build.committed_at
committer_email: build.committer_email
committer_name: build.committer_name
compare_url: build.compare_url
message: build.message
sha: build.commit
}
delete(data.build.commit)
store.pushPayload(commit: [commit])
store.pushPayload(commit: [commit])
if event == 'job:log'
console.log 'store: received job:log event', data if Log.DEBUG
data = data.job
job = store.recordForId('job', data.id)
job.appendLog(number: parseInt(data.number), content: data._log, final: data.final)
else if data[name]
@_loadOne(store, name, data)
else
throw "can't load data for #{name}" unless type
if event == 'job:log'
console.log 'store: received job:log event', data if Log.DEBUG
data = data.job
job = store.recordForId('job', data.id)
job.appendLog(number: parseInt(data.number), content: data._log, final: data.final)
else if data[name]
@_loadOne(store, name, data)
_loadOne: (store, type, json) ->
payload = {}
payload[type.pluralize()] = [json[type]]
store.pushPayload(payload)
# we get other types of records only in a few situations and
# it's not always needed to update data, so I'm specyfing which
# things I want to update here:
if type == 'build' && (json.repository || json.repo)
data = json.repository || json.repo
store.pushPayload(repos: [data])
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: ->
@slider = new Travis.Slider(@storage)
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
currentDate: ->
new Date()
onUserUpdate: (user) ->
if Travis.config.pro
@identifyCustomer(user)
@subscribePusher(user)
@setupCharm(user)
subscribePusher: (user) ->
channels = user.channels
channels = channels.map (channel) ->
if channel.match /^private-/
channel
else
throw "can't load data for #{name}" unless type
"private-#{channel}"
Travis.pusher.subscribeAll(channels)
_loadOne: (store, type, json) ->
payload = {}
payload[type.pluralize()] = [json[type]]
store.pushPayload(payload)
setupCharm: (user) ->
$.extend window.__CHARM,
customer: user.login,
customer_id: user.id,
email: user.email
# we get other types of records only in a few situations and
# it's not always needed to update data, so I'm specyfing which
# things I want to update here:
if type == 'build' && (json.repository || json.repo)
data = json.repository || json.repo
store.pushPayload(repos: [data])
displayCharm: ->
__CHARM.show()
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: ->
@slider = new Travis.Slider(@storage)
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
currentDate: ->
new Date()
onUserUpdate: (user) ->
if Travis.config.pro
@identifyCustomer(user)
@subscribePusher(user)
@setupCharm(user)
subscribePusher: (user) ->
channels = user.channels
channels = channels.map (channel) ->
if channel.match /^private-/
channel
else
"private-#{channel}"
Travis.pusher.subscribeAll(channels)
setupCharm: (user) ->
$.extend window.__CHARM,
customer: user.login,
customer_id: user.id,
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
)
displayCharm: ->
__CHARM.show()
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
)
window.App = App unless window.App

View File

@ -1,4 +1,4 @@
Travis.AccountController = Ember.ObjectController.extend
Controller = Ember.ObjectController.extend
allHooks: []
needs: ['currentUser']
userBinding: 'controllers.currentUser'
@ -38,9 +38,11 @@ Travis.AccountController = Ember.ObjectController.extend
).property('allHooks.length', 'allHooks')
showPrivateReposHint: (->
Travis.config.show_repos_hint == 'private'
@config.show_repos_hint == 'private'
) .property()
showPublicReposHint: (->
Travis.config.show_repos_hint == 'public'
@config.show_repos_hint == 'public'
) .property()
Travis.AccountController = Controller

View File

@ -1,2 +1,4 @@
Travis.AccountsController = Ember.ArrayController.extend
Controller = Ember.ArrayController.extend
tab: 'accounts'
Travis.AccountsController = Controller

View File

@ -1,4 +1,4 @@
Controller = Em.Controller.extend
Controller = Ember.Controller.extend
needs: ['currentUser', 'repos']
userBinding: 'controllers.currentUser'

View File

@ -1 +1,3 @@
Travis.AuthController = Ember.Controller.extend()
Controller = Ember.Controller.extend()
Travis.AuthController = Controller

View File

@ -1,5 +1,3 @@
require 'helpers/urls'
gravatarImage = Travis.Urls.gravatarImage
Controller = Ember.Controller.extend Travis.GithubUrlProperties,

View File

@ -1,4 +1,4 @@
Travis.BuildsController = Em.ArrayController.extend
Controller = Ember.ArrayController.extend
isPullRequestsList: false
sortAscending: false
@ -26,3 +26,5 @@ Travis.BuildsController = Em.ArrayController.extend
options.event_type = type.replace(/s$/, '') # poor man's singularize
@store.find('build', options)
Travis.BuildsController = Controller

View File

@ -1,6 +1,7 @@
colorForState = Travis.Helpers.colorForState
GithubUrlProperties = Travis.GithubUrlProperties
Controller = Em.ObjectController.extend(Travis.GithubUrlProperties,
Controller = Ember.ObjectController.extend(GithubUrlProperties,
needs: ['builds']
isPullRequestsListBinding: 'controllers.builds.isPullRequestsList'
buildBinding: 'content'

View File

@ -0,0 +1,24 @@
Ajax = Travis.ajax
Controller = Ember.ObjectController.extend
isDeleting: false
needs: ['repo', 'caches']
repo: Ember.computed.alias('controllers.repo.repo')
actions:
delete: ->
return if @get('isDeleting')
if confirm('Are you sure?')
@set('isDeleting', true)
data = { branch: @get('branch') }
deletingDone = => @set('isDeleting', false)
repo = @get('repo')
Ajax("/repos/#{repo.get('id')}/caches", "DELETE", data: data).then(deletingDone, deletingDone).then =>
model = @get('model')
@get('controllers.caches').removeObject(model)
Travis.CachesByBranchController = Controller

View File

@ -0,0 +1,26 @@
Ajax = Travis.ajax
Controller = Ember.ObjectController.extend
isDeleting: false
needs: ['repo', 'caches']
repo: Ember.computed.alias('controllers.repo.repo')
actions:
delete: ->
return if @get('isDeleting')
if confirm('Are you sure?')
@set('isDeleting', true)
data = { branch: @get('branch'), match: @get('slug') }
deletingDone = => @set('isDeleting', false)
repo = @get('repo')
Ajax("/repos/#{repo.get('id')}/caches", "DELETE", data: data).then(deletingDone, deletingDone).then =>
model = @get('model')
@get('parent.caches').removeObject(model)
if @get('parent.caches.length') == 0
@get('controllers.caches').removeObject(@get('parent'))
Travis.CacheItemController = Controller

View File

@ -1,4 +1,4 @@
Travis.CachesController = Ember.ArrayController.extend
Controller = Ember.ArrayController.extend
isDeleting: false
needs: ['repo']
repo: Ember.computed.alias('controllers.repo.repo')
@ -16,46 +16,4 @@ Travis.CachesController = Ember.ArrayController.extend
Travis.ajax.ajax("/repos/#{repo.get('id')}/caches", "DELETE").then(deletingDone, deletingDone).then =>
@clear()
Travis.CachesByBranchController = Ember.ObjectController.extend
isDeleting: false
needs: ['repo', 'caches']
repo: Ember.computed.alias('controllers.repo.repo')
actions:
delete: ->
return if @get('isDeleting')
if confirm('Are you sure?')
@set('isDeleting', true)
data = { branch: @get('branch') }
deletingDone = => @set('isDeleting', false)
repo = @get('repo')
Travis.ajax.ajax("/repos/#{repo.get('id')}/caches", "DELETE", data: data).then(deletingDone, deletingDone).then =>
model = @get('model')
@get('controllers.caches').removeObject(model)
Travis.CacheItemController = Ember.ObjectController.extend
isDeleting: false
needs: ['repo', 'caches']
repo: Ember.computed.alias('controllers.repo.repo')
actions:
delete: ->
return if @get('isDeleting')
if confirm('Are you sure?')
@set('isDeleting', true)
data = { branch: @get('branch'), match: @get('slug') }
deletingDone = => @set('isDeleting', false)
repo = @get('repo')
Travis.ajax.ajax("/repos/#{repo.get('id')}/caches", "DELETE", data: data).then(deletingDone, deletingDone).then =>
model = @get('model')
@get('parent.caches').removeObject(model)
if @get('parent.caches.length') == 0
@get('controllers.caches').removeObject(@get('parent'))
Travis.CachesController = Controller

View File

@ -1,4 +1,4 @@
Travis.CurrentUserController = Em.ObjectController.extend
Controller = Ember.ObjectController.extend
sync: ->
@get('model').sync()
@ -9,3 +9,5 @@ Travis.CurrentUserController = Em.ObjectController.extend
Ember.run.scheduleOnce 'routerTransitions', this, ->
@container.lookup('router:main').send('renderFirstSync')
).observes('isSyncing', 'auth.currentUser')
Travis.CurrentUserController = Controller

View File

@ -3,7 +3,7 @@ require 'travis/validations'
Validations = Travis.Validations
EnvVar = Travis.EnvVar
Travis.EnvVarsNewController = Ember.Controller.extend Validations,
Controller = Ember.Controller.extend Validations,
needs: ['repo']
repo: Ember.computed.alias('controllers.repo.repo')
@ -42,3 +42,5 @@ Travis.EnvVarsNewController = Ember.Controller.extend Validations,
self.transitionToRoute('env_vars')
, =>
@set('isSaving', false)
Travis.EnvVarsNewController = Controller

View File

@ -1,6 +1,8 @@
require 'travis/validations'
Travis.EnvVarController = Ember.ObjectController.extend Travis.Validations,
Validations = Travis.Validations
Controller = Ember.ObjectController.extend Validations,
isEditing: false
isDeleting: false
@ -43,3 +45,5 @@ Travis.EnvVarController = Ember.ObjectController.extend Travis.Validations,
# TODO: handle errors
env_var.save().then =>
@set('isEditing', false)
Travis.EnvVarController = Controller

View File

@ -1,2 +1,4 @@
Travis.EnvVarsController = Ember.ArrayController.extend
Controller = Ember.ArrayController.extend
vars: Ember.computed.filterBy('model', 'isNew', false)
Travis.EnvVarsController = Controller

View File

@ -1,4 +1,4 @@
Controller = Em.Controller.extend
Controller = Ember.Controller.extend
needs: ['currentUser']
user: Ember.computed.alias('controllers.currentUser')

View File

@ -1,10 +1,13 @@
Travis.FlashController = Ember.ArrayController.extend
LimitedArray = Travis.LimitedArray
Broadcast = Travis.Broadcast
Controller = Ember.ArrayController.extend
needs: ['currentUser']
currentUserBinding: 'controllers.currentUser'
init: ->
@_super.apply this, arguments
@set('flashes', Travis.LimitedArray.create(limit: 2, content: []))
@set('flashes', LimitedArray.create(limit: 2, content: []))
model: (->
broadcasts = @get('unseenBroadcasts')
@ -31,7 +34,7 @@ Travis.FlashController = Ember.ArrayController.extend
Ember.run.later(this, (-> @get('flashes.content').removeObject(msg)), 15000)
close: (msg) ->
if msg instanceof Travis.Broadcast
if msg instanceof Broadcast
msg.setSeen()
@notifyPropertyChange('unseenBroadcasts')
else
@ -40,3 +43,5 @@ Travis.FlashController = Ember.ArrayController.extend
actions:
close: (msg) ->
@close(msg)
Travis.FlashController = Controller

View File

@ -1,3 +1,3 @@
Controller = Em.Controller.extend()
Controller = Ember.Controller.extend()
Travis.MainErrorController = Controller

View File

@ -1,4 +1,4 @@
Travis.ProfileController = Ember.Controller.extend
Controller = Ember.Controller.extend
name: 'profile'
needs: ['currentUser', 'accounts', 'account']
@ -22,3 +22,5 @@ Travis.ProfileController = Ember.Controller.extend
id = if @get('account.type') == 'user' then 'user' else @get('account.login')
"#{@get('config').billing_endpoint}/subscriptions/#{id}"
).property('account.login', 'account.type')
Travis.ProfileController = Controller

View File

@ -1,7 +1,4 @@
require 'models/job'
Job = Travis.Job
Controller = Em.ArrayController.extend
Controller = Ember.ArrayController.extend
content: (->
@store.filter 'job', {}, (job) ->
['created', 'queued'].indexOf(job.get('state')) != -1

View File

@ -14,7 +14,7 @@ Controller = Ember.Controller.extend
init: ->
@_super.apply this, arguments
if !Ember.testing
Visibility.every Travis.INTERVALS.updateTimes, @updateTimes.bind(this)
Visibility.every @config.intervals.updateTimes, @updateTimes.bind(this)
updateTimes: ->
Ember.run this, ->

View File

@ -30,7 +30,7 @@ Controller = Ember.ArrayController.extend
init: ->
@_super.apply this, arguments
if !Ember.testing
Visibility.every Travis.INTERVALS.updateTimes, @updateTimes.bind(this)
Visibility.every @config.intervals.updateTimes, @updateTimes.bind(this)
recentRepos: (->
Ember.ArrayProxy.extend(

View File

@ -1,4 +1,4 @@
Travis.RequestsController = Ember.ArrayController.extend
Controller = Ember.ArrayController.extend
needs: ['repo']
repo: Ember.computed.alias('controllers.repo.repo')
@ -6,3 +6,5 @@ Travis.RequestsController = Ember.ArrayController.extend
slug = @get('repo.slug')
"https://lint.travis-ci.org/#{slug}"
).property('repo.slug')
Travis.RequestsController = Controller

View File

@ -1,7 +1,4 @@
require 'models/job'
Job = Travis.Job
Controller = Em.ArrayController.extend
Controller = Ember.ArrayController.extend
content: (->
@store.filter 'job', { state: 'started' }, (job) ->
['started', 'received'].indexOf(job.get('state')) != -1

View File

@ -1,4 +1,4 @@
Travis.SettingsIndexController = Em.ObjectController.extend
Controller = Ember.ObjectController.extend
settings: Ember.computed.alias('model.settings')
settingsChanged: (->
@ -16,3 +16,5 @@ Travis.SettingsIndexController = Em.ObjectController.extend
save: ->
@get('model').saveSettings(@get('settings')).then null, ->
Travis.flash(error: 'There was an error while saving settings. Please try again.')
Travis.SettingsIndexController = Controller

View File

@ -1,4 +1,4 @@
Controller = Em.ArrayController.extend
Controller = Ember.ArrayController.extend
init: ->
@_super.apply this, arguments
@tickables = []

View File

@ -1,6 +1,8 @@
require 'travis/validations'
Travis.SshKeyController = Ember.ObjectController.extend Travis.Validations,
Validations = Travis.Validations
Controller = Ember.ObjectController.extend Validations,
isEditing: false
isSaving: false
isDeleting: false
@ -57,3 +59,5 @@ Travis.SshKeyController = Ember.ObjectController.extend Travis.Validations,
edit: ->
@set('isEditing', true)
Travis.SshKeyController = Controller

View File

@ -1,4 +1,4 @@
Controller = Em.Controller.extend
Controller = Ember.Controller.extend
needs: ['currentUser']
userBinding: 'controllers.currentUser'

View File

@ -1,8 +0,0 @@
Travis.GithubUrlProperties = Ember.Mixin.create
urlGithubCommit: (->
Travis.Urls.githubCommit(@get('repo.slug'), @get('commit.sha'))
).property('repo.slug', 'commit.sha')
urlGithubPullRequest: (->
Travis.Urls.githubPullRequest(@get('repo.slug'), @get('build.pullRequestNumber'))
).property('repo.slug', 'build.pullRequestNumber')

View File

@ -1,5 +1,3 @@
notEmpty = Ember.computed.notEmpty
ErrorsView = Ember.View.extend
tagName: 'span'
template: Ember.Handlebars.compile("{{#each view.errors}}{{message}}{{/each}}")
@ -12,7 +10,7 @@ ErrorsView = Ember.View.extend
codes: (->
@get('errors').mapBy('code')
).property('@errors')
show: notEmpty('errors.[]')
show: Ember.computed.notEmpty('errors.[]')
fn = (name, options) ->
errors = @get('errors').for(name)

View File

@ -1,7 +1,5 @@
notEmpty = Ember.computed.notEmpty
FormFieldRowView = Ember.View.extend
invalid: notEmpty('errors.[]')
invalid: Ember.computed.notEmpty('errors.[]')
classNameBindings: ['invalid']
classNames: 'field'

View File

@ -1,3 +1,45 @@
loadConfig = ->
pages_endpoint = $('meta[rel="travis.pages_endpoint"]').attr('href')
billing_endpoint = $('meta[rel="travis.billing_endpoint"]').attr('href')
customer_io_site_id = $('meta[name="travis.customer_io_site_id"]').attr('value')
setupCustomerio(customer_io_site_id) if customer_io_site_id
enterprise = $('meta[name="travis.enterprise"]').attr('value') == 'true'
# for now I set pro to true also for enterprise, but it should be changed
# to allow more granular config later
pro = $('meta[name="travis.pro"]').attr('value') == 'true' || enterprise
return {
syncingPageRedirectionTime: 5000
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
source_endpoint: $('meta[rel="travis.source_endpoint"]').attr('href')
pusher_key: $('meta[name="travis.pusher_key"]').attr('value')
pusher_host: $('meta[name="travis.pusher_host"]').attr('value')
ga_code: $('meta[name="travis.ga_code"]').attr('value')
code_climate: $('meta[name="travis.code_climate"]').attr('value')
ssh_key_enabled: $('meta[name="travis.ssh_key_enabled"]').attr('value') == 'true'
code_climate_url: $('meta[name="travis.code_climate_url"]').attr('value')
caches_enabled: $('meta[name="travis.caches_enabled"]').attr('value') == 'true'
show_repos_hint: 'private'
avatar_default_url: 'https://travis-ci.org/images/ui/default-avatar.png'
pusher_log_fallback: $('meta[name="travis.pusher_log_fallback"]').attr('value') == 'true'
pro: pro
enterprise: enterprise
sidebar_support_box: pro && !enterprise
pages_endpoint: pages_endpoint || billing_endpoint
billing_endpoint: billing_endpoint
url_legal: "#{billing_endpoint}/pages/legal"
url_imprint: "#{billing_endpoint}/pages/imprint"
url_security: "#{billing_endpoint}/pages/security"
url_terms: "#{billing_endpoint}/pages/terms"
customer_io_site_id: customer_io_site_id
intervals: { times: -1, updateTimes: 1000 }
}
initialize = (container, application) ->
application.register 'config:main', application.config, { instantiate: false }
@ -10,4 +52,8 @@ ConfigInitializer =
initialize: initialize
Ember.onLoad 'Ember.Application', (Application) ->
Application.config loadConfig()
Application.ajax.pro = Application.config.pro
Application.initializer ConfigInitializer

View File

@ -0,0 +1,13 @@
githubCommit = Travis.Urls.githubCommit
githubPullRequest = Travis.Urls.githubPullRequest
mixin = Ember.Mixin.create
urlGithubCommit: (->
githubCommit(@get('repo.slug'), @get('commit.sha'))
).property('repo.slug', 'commit.sha')
urlGithubPullRequest: (->
githubPullRequest(@get('repo.slug'), @get('build.pullRequestNumber'))
).property('repo.slug', 'build.pullRequestNumber')
Travis.GithubUrlProperties = mixin

View File

@ -1,5 +1,4 @@
require 'travis/model'
require 'models/extensions'
require 'utils/duration-calculations'
require 'travis/ajax'

View File

@ -1,5 +1,4 @@
require 'travis/model'
require 'models/extensions'
require 'models/log'
require 'travis/ajax'

View File

@ -1,6 +1,5 @@
require 'travis/expandable-record-array'
require 'travis/model'
require 'helpers/helpers'
Model = Travis.Model
ExpandableRecordArray = Travis.ExpandableRecordArray

View File

@ -1,20 +1,20 @@
require 'travis/location'
require 'routes/application'
Ember.Router.reopen
Router = Ember.Router.extend
location: 'history'
handleURL: (url) ->
url = url.replace(/#.*?$/, '')
@_super(url)
Travis.Router.reopen
location: 'history'
didTransition: ->
@_super.apply @, arguments
if Travis.config.ga_code
_gaq.push ['_trackPageview', location.pathname]
Travis.Router.map ->
Router.map ->
@resource 'dashboard', ->
@route 'repositories', path: '/'
@ -32,14 +32,14 @@ Travis.Router.map ->
@resource 'pullRequests', path: '/pull_requests'
@resource 'branches', path: '/branches'
@resource 'requests', path: '/requests'
@resource 'caches', path: '/caches' if Travis.config.caches_enabled
@resource 'caches', path: '/caches'
@resource 'request', path: '/requests/:request_id'
@resource 'settings', ->
@route 'index', path: '/'
@resource 'env_vars', ->
@route 'new'
@resource 'ssh_key' if Travis.config.ssh_key_enabled
@resource 'ssh_key'
@route 'first_sync'
@route 'insufficient_oauth_permissions'
@ -52,3 +52,4 @@ Travis.Router.map ->
@route 'notFound', path: "/*path"
Travis.Router = Router

View File

@ -1,7 +1,5 @@
require 'routes/route'
require 'models/account'
Account = Travis.Account
TravisRoute = Travis.Route
Route = TravisRoute.extend

View File

@ -20,7 +20,7 @@ Route = SimpleLayoutRoute.extend
if !controller.get('isSyncing')
self = this
Ember.run.later this, ->
Repo.fetch(member: @get('controller.user.login')).then( (repos) ->
@store.find('repo', member: @get('controller.user.login')).then( (repos) ->
if repos.get('length')
self.transitionTo('main')
else

View File

@ -1,5 +1,4 @@
require 'routes/route'
require 'pusher'
TravisRoute = Travis.Route
channels = Travis.Pusher.CHANNELS

View File

@ -1,7 +1,6 @@
require 'routes/route'
require 'models/request'
Request = Travis.Request
TravisRoute = Travis.Route
Route = TravisRoute.extend
@ -10,6 +9,6 @@ Route = TravisRoute.extend
@controllerFor('repo').activate('request')
model: (params) ->
Request.fetch params.request_id
@store.find 'request', params.request_id
Travis.RequestRoute = Route

View File

@ -1,8 +1,6 @@
require 'routes/route'
require 'models/request'
TravisRoute = Travis.Route
Request = Travis.Request
Route = TravisRoute.extend
needsAuth: true
@ -12,6 +10,6 @@ Route = TravisRoute.extend
@controllerFor('repo').activate('requests')
model: ->
Request.fetch repository_id: @modelFor('repo').get('id')
@store.find 'request', repository_id: @modelFor('repo').get('id')
Travis.RequestsRoute = Route

View File

@ -1,24 +0,0 @@
@Travis.Slider = (storage) ->
@minimize() if storage.getItem('travis.maximized') == 'true'
this
$.extend Travis.Slider.prototype,
persist: ->
Travis.storage.setItem('travis.maximized', @isMinimized())
isMinimized: ->
return $('body').hasClass('maximized');
minimize: ->
$('body').addClass('maximized')
toggle: ->
$('body').toggleClass('maximized')
@persist()
# TODO gotta force redraws here :/
element = $('<span></span>')
$('#top .profile').append(element)
Em.run.later (-> element.remove()), 10

View File

@ -1,3 +1,5 @@
Travis.Store = DS.Store.extend
Store = DS.Store.extend
defaultAdapter: 'application'
adapter: 'application'
Travis.Store = Store

View File

@ -1,30 +0,0 @@
@Travis.FixtureAdapter = DS.Adapter.extend
find: (store, type, id) ->
fixtures = type.FIXTURES
Ember.assert "Unable to find fixtures for model type " + type.toString(), !!fixtures
return if fixtures.hasLoaded
setTimeout (->
store.loadMany type, fixtures
fixtures.hasLoaded = true
), 300
findMany: ->
@find.apply this, arguments
findAll: (store, type) ->
fixtures = type.FIXTURES
Ember.assert "Unable to find fixtures for model type " + type.toString(), !!fixtures
ids = fixtures.map (item, index, self) ->
item.id
store.loadMany type, ids, fixtures
findQuery: (store, type, params, array) ->
fixtures = type.FIXTURES
Ember.assert "Unable to find fixtures for model type " + type.toString(), !!fixtures
hashes = for fixture in fixtures
matches = for key, value of params
key == 'orderBy' || fixture[key] == value
if matches.reduce((a, b) -> a && b) then fixture else null
array.load(hashes.compact())

View File

@ -1,150 +0,0 @@
require 'travis/ajax'
require 'models'
DS.JSONTransforms['object'] = {
deserialize: (serialized) -> serialized
serialize: (deserialized) -> deserialized
}
Travis.Serializer = DS.RESTSerializer.extend
# The next 3 methods specify the behavior of adding records to dirty sets
# (ie. which records will be treated as dirty on the next commit). We don't
# allow to change most of the records on the client, so for anything except
# the User, we ignore dirtyiness.
dirtyRecordsForAttributeChange: (dirtySet, record) ->
if record.constructor == Travis.User
@_super.apply this, arguments
dirtyRecordsForBelongsToChange: (dirtySet, record) ->
if record.constructor == Travis.User
@_super.apply this, arguments
dirtyRecordsForHasManyChange: (dirtySet, record) ->
if record.constructor == Travis.User
@_super.apply this, arguments
merge: (record, serialized) ->
data = record.get('data')
# TODO: write test that ensures that we go to materializingData
# only if we can
state = record.get('stateManager.currentState.path')
unless state == "rootState.loaded.materializing"
record.send('materializingData')
record.eachAttribute( (name, attribute) ->
value = @extractAttribute(record.constructor, serialized, name)
if value != undefined
value = @deserializeValue(value, attribute.type)
if value != data.attributes[name]
record.materializeAttribute(name, value)
record.notifyPropertyChange(name)
, this)
record.eachRelationship( (name, relationship) ->
if relationship.kind == 'belongsTo'
key = @_keyForBelongsTo(record.constructor, relationship.key)
value = @extractBelongsTo(record.constructor, serialized, key)
if value != undefined && data.belongsTo[name] != value
record.materializeBelongsTo name, value
record.notifyPropertyChange(name)
else if relationship.kind == 'hasMany'
key = @_keyForHasMany(record.constructor, relationship.key)
value = @extractHasMany(record.constructor, serialized, key)
if value != undefined
record.materializeHasMany name, value
record.notifyPropertyChange(name)
, this)
record.notifyPropertyChange('data')
Travis.RestAdapter = DS.RESTAdapter.extend
serializer: Travis.Serializer
mappings:
broadcasts: Travis.Broadcast
repositories: Travis.Repo
repository: Travis.Repo
repos: Travis.Repo
repo: Travis.Repo
builds: Travis.Build
build: Travis.Build
commits: Travis.Commit
commit: Travis.Commit
jobs: Travis.Job
job: Travis.Job
account: Travis.Account
accounts: Travis.Account
worker: Travis.Worker
workers: Travis.Worker
annotation: Travis.Annotation
annotations: Travis.Annotation
plurals:
repositories: 'repositories',
repository: 'repositories',
repo: 'repos',
repos: 'repos',
build: 'builds'
branch: 'branches'
job: 'jobs'
worker: 'workers'
profile: 'profile'
annotation: 'annotations'
ajax: ->
Travis.ajax.ajax.apply(this, arguments)
sideload: (store, type, json, root) ->
if json && json.result
return
else
@_super.apply this, arguments
merge: (store, record, serialized) ->
@get('serializer').merge(record, serialized)
didFindRecord: (store, type, payload, id) ->
if (type == Travis.Build || type == Travis.Job) && payload.commit?
payload.commits = payload.commit
delete payload.commit
@_super.apply this, arguments
didSaveRecord: (store, type, record, payload) ->
# API sometimes return { result: true } response
# which does not play nice with ember-data. For now
# let's just change payload to have serialized record
# included, but ideally it should be fixed in the API
# to be consistent across all the endpoints.
if payload?.result == true
payload = {}
payload[type.singularName()] = record.serialize()
@_super(store, type, record, payload)
Travis.RestAdapter.map 'Travis.Commit', {}
Travis.RestAdapter.map 'Travis.Build', {
repoId: { key: 'repository_id' }
repo: { key: 'repository_id' }
_duration: { key: 'duration' }
jobs: { key: 'job_ids' }
_config: { key: 'config' }
}
Travis.RestAdapter.map 'Travis.Repo', {
_lastBuildDuration: { key: 'last_build_duration' }
}
Travis.RestAdapter.map 'Travis.Job', {
repoId: { key: 'repository_id' }
repo: { key: 'repository_id' }
_config: { key: 'config' }
annotations: { key: 'annotation_ids' }
}
Travis.RestAdapter.map 'Travis.User', {
_name: { key: 'name' }
}

View File

@ -1,5 +1,3 @@
require 'helpers/helpers'
durationFrom = Travis.Helpers.durationFrom
Travis.DurationCalculations = Ember.Mixin.create

View File

@ -1,5 +1,4 @@
require 'config/emoij'
require 'helpers/urls'
config_keys_map = Travis.CONFIG_KEYS_MAP
config = Travis.config

View File

@ -0,0 +1,25 @@
keys = {
go: 'Go'
rvm: 'Ruby'
gemfile: 'Gemfile'
env: 'ENV'
jdk: 'JDK'
otp_release: 'OTP Release'
php: 'PHP'
node_js: 'Node.js'
perl: 'Perl'
python: 'Python'
scala: 'Scala'
compiler: 'Compiler'
ghc: 'GHC'
os: 'OS'
ruby: 'Ruby'
xcode_sdk: 'Xcode SDK'
xcode_scheme:'Xcode Scheme'
d: 'D'
julia: 'Julia'
csharp: 'C#'
dart: 'Dart'
}
Travis.CONFIG_KEYS_MAP = keys

View File

@ -1,4 +1,4 @@
Travis.LimitedArray = Em.ArrayProxy.extend
LimitedArray = Ember.ArrayProxy.extend
limit: 10
isLoadedBinding: 'content.isLoaded'
arrangedContent: Ember.computed.limit('content', 'limit')
@ -21,3 +21,5 @@ Travis.LimitedArray = Em.ArrayProxy.extend
showAll: ->
@set 'limit', Infinity
Travis.LimitedArray = LimitedArray

View File

@ -0,0 +1,22 @@
Slider = (storage) ->
@minimize() if storage.getItem('travis.maximized') == 'true'
this
Slider.prototype.persist = ->
Travis.storage.setItem('travis.maximized', @isMinimized())
Slider.prototype.isMinimized = ->
return $('body').hasClass('maximized');
Slider.prototype.minimize = ->
$('body').addClass('maximized')
Slider.prototype.toggle = ->
$('body').toggleClass('maximized')
@persist()
# TODO gotta force redraws here :/
element = $('<span></span>')
$('#top .profile').append(element)
Em.run.later (-> element.remove()), 10
Travis.Slider = Slider

View File

@ -1,5 +1,3 @@
get = Ember.get
Error = Ember.Object.extend
message: (->
switch code = @get('code')
@ -43,13 +41,13 @@ Validator = Ember.Object.extend
isValid: (target) ->
name = @get('name')
@get('validator').call(target, get(target, name))
@get('validator').call(target, Ember.get(target, name))
validate: (target) ->
unless @isValid(target)
@setError(target)
Travis.Validations = Ember.Mixin.create
Validations = Ember.Mixin.create
init: ->
@_super.apply this, arguments
@ -89,3 +87,5 @@ Travis.Validations = Ember.Mixin.create
addErrorsFromResponse: (errors) ->
for error in errors
@get('errors').add(error.field, error.code)
Travis.Validations = Validations

View File

@ -1,5 +1,3 @@
require 'helpers/helpers'
colorForState = Travis.Helpers.colorForState
View = Travis.View.extend

View File

@ -1,5 +1,3 @@
require 'helpers/helpers'
colorForState = Travis.Helpers.colorForState
githubCommit = Travis.Urls.githubCommit
gravatarImage = Travis.Urls.gravatarImage

View File

@ -6,89 +6,10 @@ require 'app'
window.ENV ||= {}
window.ENV.RAISE_ON_DEPRECATION = true
window.Travis = TravisApplication.create(
LOG_ACTIVE_GENERATION: true,
LOG_MODULE_RESOLVER: true,
LOG_TRANSITIONS: true,
LOG_TRANSITIONS_INTERNAL: true,
LOG_VIEW_LOOKUPS: true
)
window.Travis = App.create()
Travis.deferReadiness()
pages_endpoint = $('meta[rel="travis.pages_endpoint"]').attr('href')
billing_endpoint = $('meta[rel="travis.billing_endpoint"]').attr('href')
customer_io_site_id = $('meta[name="travis.customer_io_site_id"]').attr('value')
setupCustomerio(customer_io_site_id) if customer_io_site_id
enterprise = $('meta[name="travis.enterprise"]').attr('value') == 'true'
# for now I set pro to true also for enterprise, but it should be changed
# to allow more granular config later
pro = $('meta[name="travis.pro"]').attr('value') == 'true' || enterprise
$.extend Travis,
run: ->
Travis.advanceReadiness() # bc, remove once merged to master
config:
syncingPageRedirectionTime: 5000
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
source_endpoint: $('meta[rel="travis.source_endpoint"]').attr('href')
pusher_key: $('meta[name="travis.pusher_key"]').attr('value')
pusher_host: $('meta[name="travis.pusher_host"]').attr('value')
ga_code: $('meta[name="travis.ga_code"]').attr('value')
code_climate: $('meta[name="travis.code_climate"]').attr('value')
ssh_key_enabled: $('meta[name="travis.ssh_key_enabled"]').attr('value') == 'true'
code_climate_url: $('meta[name="travis.code_climate_url"]').attr('value')
caches_enabled: $('meta[name="travis.caches_enabled"]').attr('value') == 'true'
show_repos_hint: 'private'
avatar_default_url: 'https://travis-ci.org/images/ui/default-avatar.png'
pusher_log_fallback: $('meta[name="travis.pusher_log_fallback"]').attr('value') == 'true'
pro: pro
enterprise: enterprise
sidebar_support_box: pro && !enterprise
pages_endpoint: pages_endpoint || billing_endpoint
billing_endpoint: billing_endpoint
url_legal: "#{billing_endpoint}/pages/legal"
url_imprint: "#{billing_endpoint}/pages/imprint"
url_security: "#{billing_endpoint}/pages/security"
url_terms: "#{billing_endpoint}/pages/terms"
customer_io_site_id: customer_io_site_id
CONFIG_KEYS_MAP: {
go: 'Go'
rvm: 'Ruby'
gemfile: 'Gemfile'
env: 'ENV'
jdk: 'JDK'
otp_release: 'OTP Release'
php: 'PHP'
node_js: 'Node.js'
perl: 'Perl'
python: 'Python'
scala: 'Scala'
compiler: 'Compiler'
ghc: 'GHC'
os: 'OS'
ruby: 'Ruby'
xcode_sdk: 'Xcode SDK'
xcode_scheme:'Xcode Scheme'
d: 'D'
julia: 'Julia'
csharp: 'C#'
dart: 'Dart'
}
QUEUES: [
{ name: 'linux', display: 'Linux' }
{ name: 'mac_osx', display: 'Mac and OSX' }
]
INTERVALS: { times: -1, updateTimes: 1000 }
Ember.LinkView.reopen
loadingClass: 'loading_link'
@ -101,8 +22,15 @@ if charm_key = $('meta[name="travis.charm_key"]').attr('value')
require 'travis/ajax'
Travis.ajax.pro = Travis.config.pro
require 'utils/urls'
require 'utils/helpers'
require 'utils/status-image-formats'
require 'utils/pusher'
require 'utils/slider'
require 'utils/tailing'
require 'mixins/github-url-properties'
require 'utils/keys-map'
require 'adapters/application'
require 'serializers/application'
require 'serializers/repo'
@ -168,11 +96,13 @@ require 'controllers/job'
require 'controllers/profile'
require 'controllers/repos'
require 'controllers/repo'
require 'controllers/settings'
require 'controllers/settings/index'
require 'controllers/current-user'
require 'controllers/request'
require 'controllers/requests'
require 'controllers/caches'
require 'controllers/caches-item'
require 'controllers/caches-by-branch'
require 'controllers/env-var'
require 'controllers/env-vars'
require 'controllers/env-var-new'
@ -187,11 +117,6 @@ require 'controllers/queue'
require 'controllers/running-jobs'
require 'controllers/dashboard/repositories'
require 'utils/helpers'
require 'utils/urls'
require 'helpers/status-image-formats'
require 'helpers/github-url-properties'
Travis.Handlebars = {}
require 'helpers/label'
@ -241,7 +166,6 @@ Ember.LinkView.reopen
_trackEvent: (event) ->
event.preventDefault()
require 'models/extensions'
require 'models/account'
require 'models/broadcast'
require 'models/branch'
@ -258,11 +182,6 @@ require 'models/user'
require 'models/env-var'
require 'models/ssh-key'
require 'utlils/pusher'
require 'slider'
require 'tailing'
require 'templates'
require 'ext/ember/namespace'
require 'views/view'
require 'views/accounts'

View File

@ -29,7 +29,7 @@
<script src="/scripts/app.js"></script>
<script>
minispade.require('travis')
Travis.run()
Travis.advanceReadiness()
</script>
</head>
<body id="home"></body>