diff --git a/assets/scripts/app/views.coffee b/assets/scripts/app/views.coffee
index adbb4af5..7fea9840 100644
--- a/assets/scripts/app/views.coffee
+++ b/assets/scripts/app/views.coffee
@@ -7,6 +7,8 @@ require 'views/build'
require 'views/events'
require 'views/flash'
require 'views/job'
+require 'views/jobs'
+require 'views/jobs-item'
require 'views/log'
require 'views/repo'
require 'views/profile'
diff --git a/assets/scripts/app/views/job.coffee b/assets/scripts/app/views/job.coffee
index d87e283d..a9c52f93 100644
--- a/assets/scripts/app/views/job.coffee
+++ b/assets/scripts/app/views/job.coffee
@@ -1,55 +1,33 @@
-Travis.reopen
- JobsView: Travis.View.extend
- templateName: 'jobs/list'
- buildBinding: 'controller.build'
+require 'helpers/helpers'
- jobTableId: Ember.computed(->
- if @get('required')
- 'jobs'
- else
- 'allowed_failure_jobs'
- )
+colorForState = Travis.Helpers.colorForState
+githubCommit = Travis.Urls.githubCommit
+gravatarImage = Travis.Urls.gravatarImage
- actions:
- popupClose: ->
- @popupCloseAll()
+View = Ember.View.extend
+ templateName: 'jobs/show'
- openHelpPopup: ->
- @popupCloseAll()
- @popup('help-allowed_failures')
+ repoBinding: 'controller.repo'
+ jobBinding: 'controller.job'
+ commitBinding: 'job.commit'
+ annotationsBinding: 'job.annotations'
- JobsItemView: Travis.View.extend
- tagName: 'tr'
- classNameBindings: ['color']
- repoBinding: 'context.repo'
- jobBinding: 'context'
+ currentItemBinding: 'job'
- color: (->
- Travis.Helpers.colorForState(@get('job.state'))
- ).property('job.state')
+ color: (->
+ colorForState(@get('job.state'))
+ ).property('job.state')
- JobView: Travis.View.extend
- templateName: 'jobs/show'
+ urlGithubCommit: (->
+ githubCommit(@get('repo.slug'), @get('commit.sha'))
+ ).property('repo.slug', 'commit.sha')
- repoBinding: 'controller.repo'
- jobBinding: 'controller.job'
- commitBinding: 'job.commit'
- annotationsBinding: 'job.annotations'
+ urlCommitterGravatarImage: (->
+ gravatarImage(@get('commit.committerEmail'), 40)
+ ).property('commit.committerEmail')
- currentItemBinding: 'job'
+ urlAuthorGravatarImage: (->
+ gravatarImage(@get('commit.authorEmail'), 40)
+ ).property('commit.authorEmail')
- color: (->
- Travis.Helpers.colorForState(@get('job.state'))
- ).property('job.state')
-
- urlGithubCommit: (->
- Travis.Urls.githubCommit(@get('repo.slug'), @get('commit.sha'))
- ).property('repo.slug', 'commit.sha')
-
- urlCommitterGravatarImage: (->
- Travis.Urls.gravatarImage(@get('commit.committerEmail'), 40)
- ).property('commit.committerEmail')
-
- urlAuthorGravatarImage: (->
- Travis.Urls.gravatarImage(@get('commit.authorEmail'), 40)
- ).property('commit.authorEmail')
+Travis.JobView = View
diff --git a/assets/scripts/app/views/jobs-item.coffee b/assets/scripts/app/views/jobs-item.coffee
new file mode 100644
index 00000000..59ae69b4
--- /dev/null
+++ b/assets/scripts/app/views/jobs-item.coffee
@@ -0,0 +1,11 @@
+View = Travis.View.extend
+ tagName: 'tr'
+ classNameBindings: ['color']
+ repoBinding: 'context.repo'
+ jobBinding: 'context'
+
+ color: (->
+ Travis.Helpers.colorForState(@get('job.state'))
+ ).property('job.state')
+
+Travis.JobsItemView = View
diff --git a/assets/scripts/app/views/jobs.coffee b/assets/scripts/app/views/jobs.coffee
new file mode 100644
index 00000000..5584023a
--- /dev/null
+++ b/assets/scripts/app/views/jobs.coffee
@@ -0,0 +1,20 @@
+View = Ember.View.extend
+ templateName: 'jobs/list'
+ buildBinding: 'controller.build'
+
+ jobTableId: Ember.computed(->
+ if @get('required')
+ 'jobs'
+ else
+ 'allowed_failure_jobs'
+ )
+
+ actions:
+ popupClose: ->
+ @popupCloseAll()
+
+ openHelpPopup: ->
+ @popupCloseAll()
+ @popup('help-allowed_failures')
+
+Travis.JobsView = View
diff --git a/assets/scripts/app/views/repo/list.coffee b/assets/scripts/app/views/repo/list.coffee
deleted file mode 100644
index 9b130163..00000000
--- a/assets/scripts/app/views/repo/list.coffee
+++ /dev/null
@@ -1,49 +0,0 @@
-@Travis.reopen
- ReposView: Travis.View.extend
- templateName: 'repos/list'
-
- ReposListView: Em.CollectionView.extend
- elementId: 'repos'
- tagName: 'ul'
-
- emptyView: Ember.View.extend
- template: Ember.Handlebars.compile('
Loading
')
-
- itemViewClass: Travis.View.extend
- repoBinding: 'content'
- classNames: ['repo']
- classNameBindings: ['color', 'selected']
- selected: (->
- @get('content') == @get('controller.selectedRepo')
- ).property('controller.selectedRepo')
-
- color: (->
- Travis.Helpers.colorForState(@get('repo.lastBuildState'))
- ).property('repo.lastBuildState')
-
- click: ->
- @get('controller').transitionToRoute('/' + @get('repo.slug'))
-
- ReposListTabsView: 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')
diff --git a/assets/scripts/app/views/repo/show.coffee b/assets/scripts/app/views/repo/show.coffee
deleted file mode 100644
index c84c2db6..00000000
--- a/assets/scripts/app/views/repo/show.coffee
+++ /dev/null
@@ -1,335 +0,0 @@
-Travis.reopen
- RepoView: Travis.View.extend
- templateName: 'repos/show'
-
- 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: (->
- Travis.Urls.statusImage(@get('controller.repo.slug'))
- ).property('controller.repo.slug')
-
- actions:
- statusImages: () ->
- @popupCloseAll()
- view = Travis.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()
-
- RepoShowTabsView: 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')
-
- RepoShowToolsView: Travis.View.extend
- templateName: 'repos/show/tools'
-
- repoBinding: 'controller.repo'
- buildBinding: 'controller.build'
- jobBinding: 'controller.job'
- tabBinding: 'controller.tab'
- currentUserBinding: 'controller.currentUser'
- slugBinding: 'controller.repo.slug'
-
-
- didInsertElement: ->
- self = this
- $('.menu a').on 'click', ->
- self.closeMenu()
-
- willRemoveElement: ->
- $('.menu a').off 'click'
-
- closeMenu: ->
- $('.menu').removeClass('display')
-
- actions:
- menu: ->
- @popupCloseAll()
- $('#tools .menu').toggleClass('display')
- return false
-
- regenerateKeyPopup: ->
- if @get('canRegenerateKey')
- @set('active', true)
- @closeMenu()
- @popup('regenerate-key-popup')
- return false
-
- regenerateKey: ->
- @popupCloseAll()
-
- (@get('repo.content') || @get('repo')).regenerateKey
- success: =>
- @popup('regeneration-success')
- error: ->
- Travis.lookup('controller:flash').loadFlashes([{ error: 'Travis encountered an error while trying to regenerate the key, please try again.'}])
-
- canRegenerateKey: (->
- @get('hasAdminPermission')
- ).property('hasAdminPermission')
-
- 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')
-
- displayRegenerateKey: (->
- @get('canRegenerateKey')
- ).property('canRegenerateKey')
-
- displaySettingsLink: (->
- @get('hasPushPermission')
- ).property('hasPushPermission')
-
- displayStatusImages: (->
- @get('hasPermission')
- ).property('hasPermission')
-
- RepoActionsView: Travis.View.extend
- templateName: 'repos/show/actions'
-
- repoBinding: 'controller.repo'
- buildBinding: 'controller.build'
- jobBinding: 'controller.job'
- tabBinding: 'controller.tab'
- currentUserBinding: 'controller.currentUser'
-
- actions:
- requeueBuild: ->
- if @get('canRequeueBuild')
- @requeue @get('build')
-
- requeueJob: ->
- if @get('canRequeueJob')
- @requeue @get('_job')
-
- cancelBuild: ->
- if @get('canCancelBuild')
- Travis.flash(notice: 'Build cancellation has been scheduled.')
- @get('build').cancel().then ->
- Travis.flash(success: 'Build has been successfully canceled.')
- , (xhr) ->
- if xhr.status == 422
- Travis.flash(error: 'This build can\'t be canceled')
- else if xhr.status == 403
- Travis.flash(error: 'You don\'t have sufficient access to cancel this build')
- else
- Travis.flash(error: 'An error occured when canceling the build')
-
-
- removeLog: ->
- @popupCloseAll()
- if @get('canRemoveLog')
- job = @get('_job') || @get('build.jobs.firstObject')
- 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')
-
- cancelJob: ->
- if @get('canCancelJob')
- Travis.flash(notice: 'Job cancellation has been scheduled.')
- @get('_job').cancel().then ->
- Travis.flash(success: 'Job has been successfully canceled.')
- , (xhr) ->
- if xhr.status == 422
- Travis.flash(error: 'This job can\'t be canceled')
- else if xhr.status == 403
- Travis.flash(error: 'You don\'t have sufficient access to cancel this job')
- else
- Travis.flash(error: 'An error occured when canceling the job')
-
- codeClimatePopup: ->
- @popupCloseAll()
- @popup('code-climate')
- return false
-
- removeLogPopup: ->
- if @get('canRemoveLog')
- @set('active', true)
- @popup('remove-log-popup')
- return false
-
- 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')
-
- displayRequeueBuild: (->
- @get('isBuildTab') && @get('build.isFinished')
- ).property('isBuildTab', 'build.isFinished')
-
- canRequeueBuild: (->
- @get('displayRequeueBuild') && @get('hasPermission')
- ).property('displayRequireBuild', 'hasPermission')
-
- displayRequeueJob: (->
- @get('isJobTab') && @get('job.isFinished')
- ).property('isJobTab', 'job.isFinished')
-
- canRequeueJob: (->
- @get('displayRequeueJob') && @get('hasPermission')
- ).property('displayRequeueJob', 'hasPermission')
-
- showDownloadLog: (->
- @get('jobIdForLog') && (@get('isJobTab') || @get('isBuildTab'))
- ).property('jobIdForLog', 'isJobTab', 'isBuildTab')
-
- _job: (->
- if id = @get('jobIdForLog')
- Travis.Job.find(id)
- ).property('jobIdForLog')
-
- jobIdForLog: (->
- job = @get('job.id')
- unless job
- if @get('build.jobs.length') == 1
- job = @get('build.jobs').objectAt?(0).get?('id')
- job
- ).property('job.id', 'build.jobs.firstObject.id', 'build.jobs.length')
-
- plainTextLogUrl: (->
- if id = @get('jobIdForLog')
- url = Travis.Urls.plainTextLog(id)
- if Travis.config.pro
- token = @get('job.log.token') || @get('build.jobs.firstObject.log.token')
- url += "&access_token=#{token}"
- url
- ).property('jobIdForLog', 'job.log.token', 'build.jobs.firstObject.log.token')
-
- canRemoveLog: (->
- @get('displayRemoveLog')
- ).property('displayRemoveLog')
-
- displayRemoveLog: (->
- if job = @get('_job')
- (@get('isJobTab') || (@get('isBuildTab') && @get('build.jobs.length') == 1)) &&
- job.get('canRemoveLog') && @get('hasPermission')
- ).property('isJobTab', 'isBuildTab', 'build.jobs.length', '_job.canRemoveLog', 'jobIdForLog', 'canRemoveLog', 'hasPermission')
-
- canCancelBuild: (->
- @get('displayCancelBuild') && @get('hasPermission')
- ).property('displayCancelBuild', 'hasPermission')
-
- displayCancelBuild: (->
- @get('isBuildTab') && @get('build.canCancel')
- ).property('isBuildTab', 'build.canCancel')
-
- canCancelJob: (->
- @get('displayCancelJob') && @get('hasPermission')
- ).property('displayCancelJob', 'hasPermission')
-
- displayCancelJob: (->
- @get('isJobTab') && @get('job.canCancel')
- ).property('isJobTab', 'job.canCancel')
-
- isJobTab: (->
- @get('tab') == 'job'
- ).property('tab', 'repo.id')
-
- isBuildTab: (->
- ['current', 'build'].indexOf(@get('tab')) > -1
- ).property('tab')
-
- displayCodeClimate: (->
- @get('repo.githubLanguage') == 'Ruby'
- ).property('repo.githubLanguage')
-
- requeueFinished: ->
- @set('requeueing', false)
-
- requeue: (thing) ->
- return if @get('requeueing')
- @set('requeueing', true)
- thing.requeue().then(this.requeueFinished.bind(this), this.requeueFinished.bind(this))
-