More ember-cli preparation
This commit is contained in:
parent
3aabd40874
commit
3d42a5961d
|
@ -1,4 +1,6 @@
|
||||||
Travis.BuildController = Ember.Controller.extend Travis.GithubUrlProperties,
|
gravatarImage = Travis.Urls.gravatarImage
|
||||||
|
|
||||||
|
Controller = Ember.Controller.extend Travis.GithubUrlProperties,
|
||||||
needs: ['repo']
|
needs: ['repo']
|
||||||
repoBinding: 'controllers.repo.repo'
|
repoBinding: 'controllers.repo.repo'
|
||||||
commitBinding: 'build.commit'
|
commitBinding: 'build.commit'
|
||||||
|
@ -12,9 +14,11 @@ Travis.BuildController = Ember.Controller.extend Travis.GithubUrlProperties,
|
||||||
).property('build.isLoading')
|
).property('build.isLoading')
|
||||||
|
|
||||||
urlCommitterGravatarImage: (->
|
urlCommitterGravatarImage: (->
|
||||||
Travis.Urls.gravatarImage(@get('commit.committerEmail'), 40)
|
gravatarImage(@get('commit.committerEmail'), 40)
|
||||||
).property('commit.committerEmail')
|
).property('commit.committerEmail')
|
||||||
|
|
||||||
urlAuthorGravatarImage: (->
|
urlAuthorGravatarImage: (->
|
||||||
Travis.Urls.gravatarImage(@get('commit.authorEmail'), 40)
|
gravatarImage(@get('commit.authorEmail'), 40)
|
||||||
).property('commit.authorEmail')
|
).property('commit.authorEmail')
|
||||||
|
|
||||||
|
Travis.BuildController = Controller
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
require 'travis/limited_array'
|
require 'travis/limited_array'
|
||||||
|
|
||||||
|
Repo = Travis.Repo
|
||||||
|
|
||||||
Travis.ReposController = Ember.ArrayController.extend
|
Travis.ReposController = Ember.ArrayController.extend
|
||||||
actions:
|
actions:
|
||||||
activate: (name) ->
|
activate: (name) ->
|
||||||
|
@ -32,7 +34,7 @@ Travis.ReposController = Ember.ArrayController.extend
|
||||||
recentRepos: (->
|
recentRepos: (->
|
||||||
Ember.ArrayProxy.extend(
|
Ember.ArrayProxy.extend(
|
||||||
isLoadedBinding: 'repos.isLoaded'
|
isLoadedBinding: 'repos.isLoaded'
|
||||||
repos: Travis.Repo.withLastBuild()
|
repos: Repo.withLastBuild()
|
||||||
sorted: Ember.computed.sort('repos', 'sortedReposKeys')
|
sorted: Ember.computed.sort('repos', 'sortedReposKeys')
|
||||||
content: Ember.computed.limit('sorted', 'limit')
|
content: Ember.computed.limit('sorted', 'limit')
|
||||||
sortedReposKeys: ['sortOrder:asc']
|
sortedReposKeys: ['sortOrder:asc']
|
||||||
|
@ -47,7 +49,7 @@ Travis.ReposController = Ember.ArrayController.extend
|
||||||
activate: (tab, params) ->
|
activate: (tab, params) ->
|
||||||
@set('sortProperties', ['sortOrder'])
|
@set('sortProperties', ['sortOrder'])
|
||||||
@set('tab', tab)
|
@set('tab', tab)
|
||||||
this["view#{$.camelize(tab)}"](params)
|
this["view#{tab.camelize()}"](params)
|
||||||
|
|
||||||
viewRecent: ->
|
viewRecent: ->
|
||||||
@set('content', @get('recentRepos'))
|
@set('content', @get('recentRepos'))
|
||||||
|
|
|
@ -22,7 +22,7 @@ Travis.RequestController = Ember.ObjectController.extend
|
||||||
|
|
||||||
message: (->
|
message: (->
|
||||||
message = @get('model.message')
|
message = @get('model.message')
|
||||||
if Travis.config.pro && message == "private repository"
|
if @config.pro && message == "private repository"
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
message
|
message
|
||||||
|
|
|
@ -1,41 +1,53 @@
|
||||||
@Travis.Urls =
|
plainTextLog = (id) ->
|
||||||
plainTextLog: (id) ->
|
"#{Travis.config.api_endpoint}/jobs/#{id}/log.txt?deansi=true"
|
||||||
"#{Travis.config.api_endpoint}/jobs/#{id}/log.txt?deansi=true"
|
|
||||||
|
|
||||||
githubPullRequest: (slug, pullRequestNumber) ->
|
githubPullRequest = (slug, pullRequestNumber) ->
|
||||||
"#{Travis.config.source_endpoint}/#{slug}/pull/#{pullRequestNumber}"
|
"#{Travis.config.source_endpoint}/#{slug}/pull/#{pullRequestNumber}"
|
||||||
|
|
||||||
githubCommit: (slug, sha) ->
|
githubCommit = (slug, sha) ->
|
||||||
"#{Travis.config.source_endpoint}/#{slug}/commit/#{sha}"
|
"#{Travis.config.source_endpoint}/#{slug}/commit/#{sha}"
|
||||||
|
|
||||||
githubRepo: (slug) ->
|
githubRepo = (slug) ->
|
||||||
"#{Travis.config.source_endpoint}/#{slug}"
|
"#{Travis.config.source_endpoint}/#{slug}"
|
||||||
|
|
||||||
githubWatchers: (slug) ->
|
githubWatchers = (slug) ->
|
||||||
"#{Travis.config.source_endpoint}/#{slug}/watchers"
|
"#{Travis.config.source_endpoint}/#{slug}/watchers"
|
||||||
|
|
||||||
githubNetwork: (slug) ->
|
githubNetwork = (slug) ->
|
||||||
"#{Travis.config.source_endpoint}/#{slug}/network"
|
"#{Travis.config.source_endpoint}/#{slug}/network"
|
||||||
|
|
||||||
githubAdmin: (slug) ->
|
githubAdmin = (slug) ->
|
||||||
"#{Travis.config.source_endpoint}/#{slug}/settings/hooks#travis_minibucket"
|
"#{Travis.config.source_endpoint}/#{slug}/settings/hooks#travis_minibucket"
|
||||||
|
|
||||||
statusImage: (slug, branch) ->
|
statusImage = (slug, branch) ->
|
||||||
if Travis.config.pro
|
if Travis.config.pro
|
||||||
token = Travis.__container__.lookup('controller:currentUser').get('token')
|
token = Travis.__container__.lookup('controller:currentUser').get('token')
|
||||||
"#{location.protocol}//#{location.host}/#{slug}.svg?token=#{token}" + if branch then "&branch=#{branch}" else ''
|
"#{location.protocol}//#{location.host}/#{slug}.svg?token=#{token}" + if branch then "&branch=#{branch}" else ''
|
||||||
else
|
else
|
||||||
"#{location.protocol}//#{location.host}/#{slug}.svg" + if branch then "?branch=#{encodeURIComponent(branch)}" else ''
|
"#{location.protocol}//#{location.host}/#{slug}.svg" + if branch then "?branch=#{encodeURIComponent(branch)}" else ''
|
||||||
|
|
||||||
ccXml: (slug) ->
|
ccXml = (slug) ->
|
||||||
if Travis.config.pro
|
if Travis.config.pro
|
||||||
token = Travis.__container__.lookup('controller:currentUser').get('token')
|
token = Travis.__container__.lookup('controller:currentUser').get('token')
|
||||||
"##{Travis.config.api_endpoint}/repos/#{slug}/cc.xml?token=#{token}"
|
"##{Travis.config.api_endpoint}/repos/#{slug}/cc.xml?token=#{token}"
|
||||||
else
|
else
|
||||||
"#{Travis.config.api_endpoint}/repos/#{slug}/cc.xml"
|
"#{Travis.config.api_endpoint}/repos/#{slug}/cc.xml"
|
||||||
|
|
||||||
email: (email) ->
|
email = (email) ->
|
||||||
"mailto:#{email}"
|
"mailto:#{email}"
|
||||||
|
|
||||||
gravatarImage: (email, size) ->
|
gravatarImage = (email, size) ->
|
||||||
"https://www.gravatar.com/avatar/#{md5(email)}?s=#{size}&d=#{encodeURIComponent(Travis.config.avatar_default_url)}"
|
"https://www.gravatar.com/avatar/#{md5(email)}?s=#{size}&d=#{encodeURIComponent(Travis.config.avatar_default_url)}"
|
||||||
|
|
||||||
|
Travis.Urls = {
|
||||||
|
plainTextLog: plainTextLog,
|
||||||
|
githubPullRequest: githubPullRequest,
|
||||||
|
githubCommit: githubCommit,
|
||||||
|
githubRepo: githubRepo,
|
||||||
|
githubWatchers: githubWatchers,
|
||||||
|
githubNetwork: githubNetwork,
|
||||||
|
githubAdmin: githubAdmin,
|
||||||
|
statusImage: statusImage,
|
||||||
|
ccXml: ccXml,
|
||||||
|
email: email
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ require 'views/jobs'
|
||||||
require 'views/jobs-item'
|
require 'views/jobs-item'
|
||||||
require 'views/log'
|
require 'views/log'
|
||||||
require 'views/repo'
|
require 'views/repo'
|
||||||
|
require 'views/repos-list'
|
||||||
|
require 'views/repos-list-tabs'
|
||||||
require 'views/profile'
|
require 'views/profile'
|
||||||
require 'views/stats'
|
require 'views/stats'
|
||||||
require 'views/signin'
|
require 'views/signin'
|
||||||
|
|
|
@ -5,8 +5,6 @@ githubCommit = Travis.Urls.githubCommit
|
||||||
gravatarImage = Travis.Urls.gravatarImage
|
gravatarImage = Travis.Urls.gravatarImage
|
||||||
|
|
||||||
View = Ember.View.extend
|
View = Ember.View.extend
|
||||||
templateName: 'jobs/show'
|
|
||||||
|
|
||||||
repoBinding: 'controller.repo'
|
repoBinding: 'controller.repo'
|
||||||
jobBinding: 'controller.job'
|
jobBinding: 'controller.job'
|
||||||
commitBinding: 'job.commit'
|
commitBinding: 'job.commit'
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
View = Ember.View.extend
|
View = Ember.View.extend
|
||||||
templateName: 'jobs/list'
|
|
||||||
buildBinding: 'controller.build'
|
buildBinding: 'controller.build'
|
||||||
|
|
||||||
jobTableId: Ember.computed(->
|
jobTableId: Ember.computed(->
|
||||||
|
|
57
assets/scripts/app/views/repo-show-tabs.coffee
Normal file
57
assets/scripts/app/views/repo-show-tabs.coffee
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
View = Travis.View.extend
|
||||||
|
templateName: 'repos/show/tabs'
|
||||||
|
|
||||||
|
tabBinding: 'controller.tab'
|
||||||
|
contextBinding: 'controller'
|
||||||
|
|
||||||
|
# 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')
|
||||||
|
|
||||||
|
classEvents: (->
|
||||||
|
'active' if @get('tab') == 'events'
|
||||||
|
).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 display-inline' if @get('tab') == 'job'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
classRequests: (->
|
||||||
|
'active display-inline' if @get('tab') == 'requests'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
classCaches: (->
|
||||||
|
'active display-inline' if @get('tab') == 'caches'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
classSettings: (->
|
||||||
|
'active display-inline' if @get('tab') == 'settings'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
classRequest: (->
|
||||||
|
'active display-inline' if @get('tab') == 'request'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
Travis.RepoShowTabsView = View
|
|
@ -1,2 +1,37 @@
|
||||||
require 'views/repo/list'
|
statusImage = Travis.Urls.statusImage
|
||||||
require 'views/repo/show'
|
StatusImagesView = Travis.StatusImagesView
|
||||||
|
|
||||||
|
View = Travis.View.extend
|
||||||
|
reposBinding: 'controllers.repos'
|
||||||
|
repoBinding: 'controller.repo'
|
||||||
|
buildBinding: 'controller.build'
|
||||||
|
jobBinding: 'controller.job'
|
||||||
|
tabBinding: 'controller.tab'
|
||||||
|
|
||||||
|
classNameBindings: ['controller.isLoading:loading']
|
||||||
|
|
||||||
|
isEmpty: (->
|
||||||
|
@get('repos.isLoaded') && @get('repos.length') == 0
|
||||||
|
).property('repos.isLoaded', 'repos.length')
|
||||||
|
|
||||||
|
statusImageUrl: (->
|
||||||
|
statusImage(@get('controller.repo.slug'))
|
||||||
|
).property('controller.repo.slug')
|
||||||
|
|
||||||
|
actions:
|
||||||
|
statusImages: () ->
|
||||||
|
@popupCloseAll()
|
||||||
|
view = StatusImagesView.create(toolsView: this)
|
||||||
|
Travis.View.currentPopupView = view
|
||||||
|
view.appendTo($('body'))
|
||||||
|
return false
|
||||||
|
|
||||||
|
ReposEmptyView: Travis.View.extend
|
||||||
|
template: (->
|
||||||
|
if Travis.config.pro
|
||||||
|
'pro/repos/show/empty'
|
||||||
|
else
|
||||||
|
''
|
||||||
|
).property()
|
||||||
|
|
||||||
|
Travis.RepoView = View
|
||||||
|
|
25
assets/scripts/app/views/repos-list-tabs.coffee
Normal file
25
assets/scripts/app/views/repos-list-tabs.coffee
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
View = Travis.View.extend
|
||||||
|
templateName: 'repos/list/tabs'
|
||||||
|
tabBinding: 'controller.tab'
|
||||||
|
currentUserBinding: 'controller.currentUser.id'
|
||||||
|
|
||||||
|
classRecent: (->
|
||||||
|
'active' if @get('tab') == 'recent'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
classOwned: (->
|
||||||
|
classes = []
|
||||||
|
classes.push('active') if @get('tab') == 'owned'
|
||||||
|
classes.push('display-inline') if @get('currentUser')
|
||||||
|
classes.join(' ')
|
||||||
|
).property('tab', 'currentUser')
|
||||||
|
|
||||||
|
classSearch: (->
|
||||||
|
'active' if @get('tab') == 'search'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
classNew: (->
|
||||||
|
'display-inline' if @get('currentUser')
|
||||||
|
).property('currentUser')
|
||||||
|
|
||||||
|
Travis.ReposListTabsView = View
|
25
assets/scripts/app/views/repos-list.coffee
Normal file
25
assets/scripts/app/views/repos-list.coffee
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
colorForState = Travis.Helpers.colorForState
|
||||||
|
|
||||||
|
View = Em.CollectionView.extend
|
||||||
|
elementId: 'repos'
|
||||||
|
tagName: 'ul'
|
||||||
|
|
||||||
|
emptyView: Ember.View.extend
|
||||||
|
template: Ember.Handlebars.compile('<div class="loading"><span>Loading</span></div>')
|
||||||
|
|
||||||
|
itemViewClass: Travis.View.extend
|
||||||
|
repoBinding: 'content'
|
||||||
|
classNames: ['repo']
|
||||||
|
classNameBindings: ['color', 'selected']
|
||||||
|
selected: (->
|
||||||
|
@get('content') == @get('controller.selectedRepo')
|
||||||
|
).property('controller.selectedRepo')
|
||||||
|
|
||||||
|
color: (->
|
||||||
|
colorForState(@get('repo.lastBuildState'))
|
||||||
|
).property('repo.lastBuildState')
|
||||||
|
|
||||||
|
click: ->
|
||||||
|
@get('controller').transitionToRoute('/' + @get('repo.slug'))
|
||||||
|
|
||||||
|
Travis.ReposListView = View
|
|
@ -1,13 +1,13 @@
|
||||||
jQuery.support.cors = true
|
jQuery.support.cors = true
|
||||||
|
|
||||||
|
default_options =
|
||||||
|
accepts:
|
||||||
|
json: 'application/json; version=2'
|
||||||
|
|
||||||
Travis.ajax = Em.Object.create
|
Travis.ajax = Em.Object.create
|
||||||
publicEndpoints: [/\/repos\/?.*/, /\/builds\/?.*/, /\/jobs\/?.*/]
|
publicEndpoints: [/\/repos\/?.*/, /\/builds\/?.*/, /\/jobs\/?.*/]
|
||||||
privateEndpoints: [/\/repos\/\d+\/caches/]
|
privateEndpoints: [/\/repos\/\d+\/caches/]
|
||||||
|
|
||||||
DEFAULT_OPTIONS:
|
|
||||||
accepts:
|
|
||||||
json: 'application/json; version=2'
|
|
||||||
|
|
||||||
get: (url, callback, errorCallback) ->
|
get: (url, callback, errorCallback) ->
|
||||||
@ajax(url, 'get', success: callback, error: errorCallback)
|
@ajax(url, 'get', success: callback, error: errorCallback)
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ Travis.ajax = Em.Object.create
|
||||||
delete data.flash if data?
|
delete data.flash if data?
|
||||||
error.apply(this, arguments)
|
error.apply(this, arguments)
|
||||||
|
|
||||||
options = $.extend(options, Travis.ajax.DEFAULT_OPTIONS)
|
options = $.extend(options, default_options)
|
||||||
|
|
||||||
if testMode?
|
if testMode?
|
||||||
console.log('Running ajax with', options.url)
|
console.log('Running ajax with', options.url)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user