Merge branch 'master' into lp-no-builds

This commit is contained in:
Lisa Passing 2015-08-10 18:53:03 +02:00
commit a6f18ab19c
37 changed files with 430 additions and 417 deletions

View File

@ -11,7 +11,16 @@ LimitConcurrentBuildsComponent = Ember.Component.extend
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')
@ -26,15 +35,6 @@ LimitConcurrentBuildsComponent = Ember.Component.extend
@set('value', 0)
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)
Ember.run.debounce(this, 'limitChanged', 1000)
`export default LimitConcurrentBuildsComponent`

View File

@ -0,0 +1,16 @@
`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,54 @@
`import Ember from 'ember'`
RepoShowTabsComponent = Ember.Component.extend
# 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' 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,47 @@
`import Ember from 'ember'`
`import config from 'travis/config/environment'`
RepoShowToolsComponent = Ember.Component.extend
popup: Ember.inject.service()
click: (event) ->
if $(event.target).is('a') && $(event.target).parents('.dropdown-menu').length
@closeMenu()
closeMenu: ->
$('.menu').removeClass('display')
actions:
menu: ->
@get('popup').close()
$('#tools .menu').toggleClass('display')
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')
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,31 @@
`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: ['color', '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,6 @@
`import Ember from 'ember'`
ReposListComponent = Ember.Component.extend
tagName: 'ul'
`export default ReposListComponent`

View File

@ -0,0 +1,20 @@
`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

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

View File

@ -45,5 +45,9 @@ Controller = Ember.ArrayController.extend
@store.find('build', options)
actions:
showMoreBuilds: ->
@showMore()
`export default Controller`

View File

@ -1,14 +0,0 @@
`import Ember from 'ember'`
Controller = Ember.ArrayController.extend
isLoaded: false
content: (->
result = @store.filter('job', {}, (job) ->
['created', 'queued'].indexOf(job.get('state')) != -1
)
result.then =>
@set('isLoaded', true)
result
).property()
`export default Controller`

View File

@ -2,7 +2,8 @@
`import limit from 'travis/utils/computed-limit'`
`import Repo from 'travis/models/repo'`
Controller = Ember.ArrayController.extend
Controller = Ember.Controller.extend
contentBinding: 'repos'
actions:
activate: (name) ->
@activate(name)
@ -29,8 +30,8 @@ Controller = Ember.ArrayController.extend
if @get('tab') == 'owned' && @get('isLoaded') && @get('length') == 0
@container.lookup('router:main').send('redirectToGettingStarted')
isLoadedBinding: 'content.isLoaded'
needs: ['currentUser', 'repo', 'runningJobs', 'queue']
isLoadedBinding: 'repos.isLoaded'
needs: ['currentUser', 'repo']
currentUserBinding: 'controllers.currentUser.model'
selectedRepo: (->
# we need to observe also repo.content here, because we use
@ -39,16 +40,37 @@ Controller = Ember.ArrayController.extend
@get('controllers.repo.repo.content') || @get('controllers.repo.repo')
).property('controllers.repo.repo', 'controllers.repo.repo.content')
startedJobsCount: Ember.computed.alias('controllers.runningJobs.length')
startedJobsCount: Ember.computed.alias('runningJobs.length')
allJobsCount: (->
@get('startedJobsCount') + @get('controllers.queue.length')
).property('startedJobsCount', 'controllers.queue.length')
@get('startedJobsCount') + @get('queuedJobs.length')
).property('startedJobsCount', 'queuedJobs.length')
init: ->
@_super.apply this, arguments
if !Ember.testing
Visibility.every @config.intervals.updateTimes, @updateTimes.bind(this)
runningJobs: (->
# TODO: this should also query for received jobs
result = @store.filter('job', {}, (job) ->
['started', 'received'].indexOf(job.get('state')) != -1
)
result.set('isLoaded', false)
result.then =>
result.set('isLoaded', true)
result
).property()
queuedJobs: (->
result = @get('store').filter('job', {}, (job) ->
['created', 'queued'].indexOf(job.get('state')) != -1
)
result.set('isLoaded', false)
result.then =>
result.set('isLoaded', true)
result
).property()
recentRepos: (->
# I return an empty array here, because we're removing left sidebar, but
# I don't want to refactor too much code (it will be all changed anyway
@ -57,8 +79,8 @@ Controller = Ember.ArrayController.extend
).property()
updateTimes: ->
if content = @get('content')
content.forEach (r) -> r.updateTimes()
if repos = @get('repos')
repos.forEach (r) -> r.updateTimes()
activate: (tab, params) ->
@set('sortProperties', ['sortOrder'])
@ -66,7 +88,7 @@ Controller = Ember.ArrayController.extend
this["view_#{tab}".camelize()](params)
viewOwned: ->
@set('content', @get('userRepos'))
@set('repos', @get('userRepos'))
viewRunning: ->
@ -79,7 +101,7 @@ Controller = Ember.ArrayController.extend
viewSearch: (phrase) ->
@set('search', phrase)
@set('content', Repo.search(@store, phrase))
@set('repos', Repo.search(@store, phrase))
searchObserver: (->
search = @get('search')

View File

@ -1,24 +0,0 @@
`import Ember from 'ember'`
Controller = Ember.ArrayController.extend
init: ->
@_super.apply this, arguments
if !Ember.testing
Visibility.every @config.intervals.updateTimes, @updateTimes.bind(this)
updateTimes: ->
if content = @get('content')
content.forEach (job) -> job.updateTimes()
isLoaded: false
content: (->
# TODO: this should also query for received jobs
result = @store.filter('job', {}, (job) ->
['started', 'received'].indexOf(job.get('state')) != -1
)
result.then =>
@set('isLoaded', true)
result
).property()
`export default Controller`

View File

@ -12,15 +12,17 @@ Route = TravisRoute.extend
@controllerFor('repos').activate(@get('reposTabName'))
@currentRepoDidChange()
@controllerFor('repos').addObserver('firstObject', this, 'currentRepoDidChange')
if repos = @controllerFor('repos').get('repos')
repos.addObserver('firstObject', this, 'currentRepoDidChange')
deactivate: ->
@controllerFor('repos').removeObserver('firstObject', this, 'currentRepoDidChange')
if repos = @controllerFor('repos').get('repos')
repos.removeObserver('firstObject', this, 'currentRepoDidChange')
@_super.apply(this, arguments)
currentRepoDidChange: ->
if repo = @controllerFor('repos').get('firstObject')
if repo = @controllerFor('repos').get('repos.firstObject')
@controllerFor('repo').set('repo', repo)
actions:

View File

@ -44,21 +44,9 @@ Route = TravisRoute.extend
hasPushAccess: ->
repoId = parseInt @modelFor('repo').get('id')
pushAccess = true
Ajax.get '/users/permissions', (data) =>
admin = data.admin.filter (item) ->
return item == repoId
push = data.push.filter (item) ->
return item == repoId
pull = data.pull.filter (item) ->
return item == repoId
if Ember.isEmpty admin && Ember.isEmpty push && !Ember.isEmpty pull
pushAccess = false
pushAccess
@auth.get('currentUser').get('pushPermissions').filter (item) ->
item == repoId
model: () ->
return Ember.RSVP.hash({

15
app/services/popup.coffee Normal file
View File

@ -0,0 +1,15 @@
`import Ember from 'ember'`
PopupService = Ember.Service.extend
open: (name) ->
@closeAll()
name = event?.target?.name || name
$("##{name}").toggleClass('display')
close: ->
if view = Ember.View.currentPopupView
view.destroy()
Ember.View.currentPopupView = null
$('.popup').removeClass('display')
`export default PopupService`

View File

@ -7,7 +7,7 @@
{{/each}}
{{#if displayShowMoreButton}}
<p>
{{view 'show-more-button'}}
{{show-more-button isLoading=isLoading showMore=(action 'showMoreBuilds')}}
{{#if isLoading}}
{{loading-indicator}}
{{/if}}

View File

@ -1,6 +1,6 @@
{{#if isLoaded}}
{{#if length}}
{{#each job in controller}}
{{#if jobs.isLoaded}}
{{#if jobs.length}}
{{#each jobs as |job|}}
<div class="tile tile--sidebar {{job.state}}">
{{#if job.repo.slug}}
<span class="icon icon--job {{job.state}}"></span>

View File

@ -0,0 +1,83 @@
<div class="tabnav" role="tablist">
<ul class="tab tabs--main">
<li id="tab_current" class={{classCurrent}}>
{{#if repo.slug}}
{{#link-to "repo" repo current-when="repo.index"}}
Current
{{/link-to}}
{{/if}}
</li>
<li id="tab_branches" class={{classBranches}}>
{{#if repo.slug}}
{{#link-to "branches" repo}}
Branches
{{/link-to}}
{{/if}}
</li>
<li id="tab_builds" class={{classBuilds}}>
{{#if repo.slug}}
{{#link-to "builds" repo}}
Build History
{{/link-to}}
{{/if}}
</li>
<li id="tab_pull_requests" class={{classPullRequests}}>
{{#if repo.slug}}
{{#link-to "pullRequests" repo}}
Pull Requests
{{/link-to}}
{{/if}}
</li>
<li id="tab_build" class={{classBuild}}>
{{#if build.id}}
{{#if repo.slug}}
{{#link-to "build" repo build}}
Build #{{build.number}}
{{/link-to}}
{{/if}}
{{/if}}
</li>
<li id="tab_job" class={{classJob}}>
{{#if job.id}}
{{#if repo.slug}}
{{#link-to "job" repo job}}
Job #{{job.number}}
{{/link-to}}
{{/if}}
{{/if}}
</li>
<li id="tab_settings" class={{classSettings}}>
{{#if repo.slug}}
{{#link-to "settings" repo}}
Settings
{{/link-to}}
{{/if}}
</li>
<li id="tab_requests" class="{{classRequests}}">
{{#if repo.slug}}
{{#link-to "requests" repo}}
Requests
{{/link-to}}
{{/if}}
</li>
{{#if config.caches_enabled}}
<li id="tab_caches" class={{classCaches}}>
{{#if repo.slug}}
{{#link-to "caches" repo}}
Caches
{{/link-to}}
{{/if}}
</li>
{{/if}}
<li id="tab_request" class={{classRequest}}>
{{#if request.id}}
{{#if repo.slug}}
{{#link-to "request" repo request}}
Request #{{request.id}}
{{/link-to}}
{{/if}}
{{/if}}
</li>
</ul>
</div>

View File

@ -0,0 +1,18 @@
<div class="dropdown dropdown--classic" id="tools">
<a href="#" {{action "menu"}} class="menu-popup-button dropdown-button btn" type=""><span class="icon icon-cog-light"></span> Settings <span class="icon icon-arrow-down"></span></a>
<ul class="dropdown-menu menu">
{{#if displaySettingsLink}}
<li>
{{#link-to "settings" repo}}Settings{{/link-to}}
</li>
{{/if}}
<li>
{{#link-to "requests" repo}}Requests{{/link-to}}
</li>
{{#if displayCachesLink}}
<li>
{{#link-to "caches" repo}}Caches{{/link-to}}
</li>
{{/if}}
</ul>
</div>

View File

@ -0,0 +1,35 @@
<div class="tile tile--sidebar {{repo.lastBuildState}}">
<h2 class="tile-title">
{{#if repo.slug}}
<span class="icon icon--job {{repo.lastBuildState}}"></span>
{{#link-to "repo" repo class="slug"}}{{repo.slug}}{{/link-to}}
{{/if}}
</h2>
{{#with repo.lastBuildHash as lastBuild}}
{{#if repo.slug}}
{{#if lastBuild.id}}
<p class="tile-title float-right">
<span class="icon icon--hash"></span>
{{#link-to "build" repo lastBuild.id
class="last_build"}}{{lastBuild.number}}{{/link-to}}
</p>
{{/if}}
{{/if}}
{{/with}}
<p>
<span class="icon icon--clock"></span>
Duration:
<abbr class="duration" title={{lastBuildStartedAt}}>
{{format-duration repo.lastBuildDuration}}
</abbr>
</p>
<p>
<span class="icon icon--cal"></span>
Finished:
<abbr class="finished_at timeago" title={{lastBuildFinishedAt}}>
{{format-time repo.lastBuildFinishedAt}}
</abbr>
</p>
</div>

View File

@ -0,0 +1,7 @@
{{#each repos as |repo|}}
{{repos-list-item repo=repo selectedRepo=selectedRepo}}
{{else}}
<p class="empty">{{noReposMessage}}</p>
{{/each}}

View File

@ -1,6 +1,6 @@
{{#if isLoaded}}
{{#if controller.length}}
{{#each job in controller}}
{{#if jobs.isLoaded}}
{{#if jobs.length}}
{{#each jobs as |job| }}
<div class="tile tile--sidebar {{job.state}}">
{{#if job.repo.slug}}
<span class="icon icon--job {{job.state}}"></span>

View File

@ -0,0 +1 @@
<span class="icon icon--eye"></span>{{buttonLabel}}

View File

@ -18,9 +18,9 @@
</header>
<div class="repo-menus">
<div class="repo-menu-header">
{{view 'repo-show-tools'}}
{{repo-show-tools repo=repo build=build job=job tab=tab currentUser=auth.currentUser}}
{{view 'repo-show-tabs'}}
{{repo-show-tabs repo=repo tab=tab}}
</div>
<div class="tabbody repo-main">
{{#if repo.active}}

View File

@ -9,60 +9,17 @@
{{#if showRunningJobs}}
<div class="tabbody sidebar-list">
<div>
{{render "runningJobs"}}
{{running-jobs jobs=runningJobs}}
</div>
<hr class="sidebar-seperator">
<div>
{{render "queue"}}
{{queued-jobs jobs=queuedJobs}}
</div>
</div>
{{else}}
<div class="tabbody sidebar-list">
{{#if isLoaded}}
{{#collection 'repos-list' content=this}}
{{#with view.repo as repo}}
<div class="tile tile--sidebar {{repo.lastBuildState}}">
<h2 class="tile-title">
{{#if repo.slug}}
<span class="icon icon--job {{repo.lastBuildState}}"></span>
{{#link-to "repo" repo class="slug"}}{{repo.slug}}{{/link-to}}
{{/if}}
</h2>
{{#with repo.lastBuildHash as lastBuild}}
{{#if repo.slug}}
{{#if lastBuild.id}}
<p class="tile-title float-right">
<span class="icon icon--hash"></span>
{{#link-to "build" repo lastBuild.id
class="last_build"}}{{lastBuild.number}}{{/link-to}}
</p>
{{/if}}
{{/if}}
{{/with}}
<p>
<span class="icon icon--clock"></span>
Duration:
<abbr class="duration" title={{lastBuildStartedAt}}>
{{format-duration repo.lastBuildDuration}}
</abbr>
</p>
<p>
<span class="icon icon--cal"></span>
Finished:
<abbr class="finished_at timeago" title={{lastBuildFinishedAt}}>
{{format-time repo.lastBuildFinishedAt}}
</abbr>
</p>
</div>
{{/with}}
{{else}}
<p class="empty">{{noReposMessage}}</p>
{{/collection}}
{{repos-list repos=repos selectedRepo=selectedRepo}}
{{else}}
{{loading-indicator center=true}}
{{/if}}

View File

@ -1,83 +1 @@
<div class="tabnav" role="tablist">
<ul class="tab tabs--main">
<li id="tab_current" class={{view.classCurrent}}>
{{#if repo.slug}}
{{#link-to "repo" repo current-when="repo.index"}}
Current
{{/link-to}}
{{/if}}
</li>
<li id="tab_branches" class={{view.classBranches}}>
{{#if repo.slug}}
{{#link-to "branches" repo}}
Branches
{{/link-to}}
{{/if}}
</li>
<li id="tab_builds" class={{view.classBuilds}}>
{{#if repo.slug}}
{{#link-to "builds" repo}}
Build History
{{/link-to}}
{{/if}}
</li>
<li id="tab_pull_requests" class={{view.classPullRequests}}>
{{#if repo.slug}}
{{#link-to "pullRequests" repo}}
Pull Requests
{{/link-to}}
{{/if}}
</li>
<li id="tab_build" class={{view.classBuild}}>
{{#if build.id}}
{{#if repo.slug}}
{{#link-to "build" repo build}}
Build #{{build.number}}
{{/link-to}}
{{/if}}
{{/if}}
</li>
<li id="tab_job" class={{view.classJob}}>
{{#if job.id}}
{{#if repo.slug}}
{{#link-to "job" repo job}}
Job #{{job.number}}
{{/link-to}}
{{/if}}
{{/if}}
</li>
<li id="tab_settings" class={{view.classSettings}}>
{{#if repo.slug}}
{{#link-to "settings" repo}}
Settings
{{/link-to}}
{{/if}}
</li>
<li id="tab_requests" class="{{view.classRequests}}">
{{#if repo.slug}}
{{#link-to "requests" repo}}
Requests
{{/link-to}}
{{/if}}
</li>
{{#if config.caches_enabled}}
<li id="tab_caches" class={{view.classCaches}}>
{{#if repo.slug}}
{{#link-to "caches" repo}}
Caches
{{/link-to}}
{{/if}}
</li>
{{/if}}
<li id="tab_request" class={{view.classRequest}}>
{{#if request.id}}
{{#if repo.slug}}
{{#link-to "request" repo request}}
Request #{{request.id}}
{{/link-to}}
{{/if}}
{{/if}}
</li>
</ul>
</div>

View File

@ -1,47 +1 @@
<div class="dropdown dropdown--classic" id="tools">
<a href="#" {{action "menu" target=view}} class="menu-popup-button dropdown-button btn" type=""><span class="icon icon-cog-light"></span> Settings <span class="icon icon-arrow-down"></span></a>
<ul class="dropdown-menu menu">
{{#if view.displaySettingsLink}}
<li>
{{#link-to "settings" view.repo}}Settings{{/link-to}}
</li>
{{/if}}
<li>
{{#link-to "requests" view.repo}}Requests{{/link-to}}
</li>
{{#if view.displayCachesLink}}
<li>
{{#link-to "caches" view.repo}}Caches{{/link-to}}
</li>
{{/if}}
</ul>
</div>
<div id="regenerate-key" class="popup">
<a href="#" class="close" {{action "popupClose" target=view}}></a>
<p>
Do you really want to regenerate ssl keys for this repository? Please note that
any data, which is encrypted, such as notification services credentials or secure
environment variables will not be accessible during the builds until you re-encrypt
it with the new key.
</p>
<p>
<a class="sync_now button" {{action "regenerateKey" target=view}}>Yes, do it!</a>
<span class="or">or</span>
<a href="#" class="cancel" {{action "popupClose" target=view}}>Cancel</a>
</p>
</div>
<div id="regeneration-success" class="popup">
<a href="#" class="close" {{action "popupClose" target=view}}></a>
<p>
Key for this repository has been regenerated. If you used previous key
for encryption, you will need encrypt your data again with the new key.
</p>
<p>
You can read more about encryption keys <a href="http://about.travis-ci.org/docs/user/encryption-keys/">in Travis documentation</a>
</p>
</div>

View File

@ -1 +0,0 @@
<span class="icon icon--eye"></span>{{view.label}}

View File

@ -12,13 +12,6 @@ TravisPusher.prototype.init = (config) ->
Pusher.host = config.host if config.host
@pusher = new Pusher(config.key, encrypted: config.encrypted, disableStats: true)
@callbacksToProcess = []
Visibility.change (e, state) =>
@processSavedCallbacks() if state == 'visible'
setInterval @processSavedCallbacks.bind(this), @processingIntervalWhenHidden
TravisPusher.prototype.subscribeAll = (channels) ->
@subscribe(channel) for channel in channels
@ -44,35 +37,18 @@ TravisPusher.prototype.prefix = (channel) ->
else
channel
# process pusher messages in batches every 5 minutes when the page is hidden
TravisPusher.prototype.processingIntervalWhenHidden = 1000 * 60 * 5
TravisPusher.prototype.receive = (event, data) ->
return if event.substr(0, 6) == 'pusher'
data = @normalize(event, data) if data.id
@processWhenVisible =>
# TODO remove job:requeued, once sf-restart-event has been merged
# TODO this also needs to clear logs on build:created if matrix jobs are already loaded
if event == 'job:created' || event == 'job:requeued'
if job = @store.getById('job', data.job.id)
job.clearLog()
# TODO remove job:requeued, once sf-restart-event has been merged
# TODO this also needs to clear logs on build:created if matrix jobs are already loaded
if event == 'job:created' || event == 'job:requeued'
if job = @store.getById('job', data.job.id)
job.clearLog()
Ember.run.next =>
@store.receivePusherEvent(event, data)
TravisPusher.prototype.processSavedCallbacks = ->
while callback = @callbacksToProcess.shiftObject()
callback.call(this)
TravisPusher.prototype.processLater = (callback) ->
@callbacksToProcess.pushObject(callback)
TravisPusher.prototype.processWhenVisible = (callback) ->
if Visibility.hidden() && Visibility.isSupported()
@processLater(callback)
else
callback.call(this)
Ember.run.next =>
@store.receivePusherEvent(event, data)
TravisPusher.prototype.normalize = (event, data) ->
switch event

View File

@ -1,6 +1,8 @@
`import BasicView from 'travis/views/basic'`
View = BasicView.extend
popup: Ember.inject.service()
classNames: ['application']
click: (event) ->
# TODO: this solves the case of closing menus and popups,
@ -8,7 +10,7 @@ View = BasicView.extend
# yet, but this does not seem optimal
targetAndParents = $(event.target).parents().andSelf()
if ! ( targetAndParents.hasClass('open-popup') || targetAndParents.hasClass('popup') )
@popupCloseAll()
@get('popup').close()
# TODO: I needed to add second check to this conditional, because for some reason
# event.stopPropagation() in menu() function in RepoShowToolsView does

View File

@ -1,21 +1,5 @@
`import Ember from 'ember'`
View = Ember.View.extend
actions:
popup: (name) -> @popup(name)
popupClose: -> @popupClose()
popup: (name) ->
@popupCloseAll()
name = event?.target?.name || name
$("##{name}").toggleClass('display')
popupClose: ->
$('.popup').removeClass('display')
popupCloseAll: ->
if view = Ember.View.currentPopupView
view.destroy()
Ember.View.currentPopupView = null
$('.popup').removeClass('display')
View = Ember.View.extend()
`export default View`

View File

@ -42,6 +42,8 @@ Object.defineProperty Log.Limit.prototype, 'limited',
@count >= @max_lines
View = BasicView.extend
popup: Ember.inject.service()
templateName: 'jobs/pre'
currentUserBinding: 'controller.auth.currentUser'
@ -60,15 +62,18 @@ View = BasicView.extend
@teardownLog()
versionDidChange: (->
@rerender() if @get('_state') == 'inDOM'
this.$('#log').empty()
@teardownLog()
@createEngine()
).observes('log.version')
logDidChange: (->
console.log 'log view: log did change: rerender' if Log.DEBUG
this.$('#log').empty()
@teardownLog()
if @get('log')
@createEngine()
@rerender() if @get('_state') == 'inDOM'
).observes('log')
teardownLog: ->
@ -144,7 +149,7 @@ View = BasicView.extend
removeLogPopup: ->
if @get('canRemoveLog')
@popup('remove-log-popup')
@get('popup').open('remove-log-popup')
return false
noop: -> # TODO required?

View File

@ -1,84 +0,0 @@
`import Ember from 'ember'`
`import BasicView from 'travis/views/basic'`
`import config from 'travis/config/environment'`
View = BasicView.extend
templateName: 'repos/show/tools'
repoBinding: 'controller.repo'
buildBinding: 'controller.build'
jobBinding: 'controller.job'
tabBinding: 'controller.tab'
currentUserBinding: 'controller.auth.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')
displayCachesLink: (->
@get('hasPushPermission') && config.endpoints.caches
).property('hasPushPermission')
displayStatusImages: (->
@get('hasPermission')
).property('hasPermission')
`export default View`

View File

@ -5,6 +5,7 @@
`import Polling from 'travis/mixins/polling'`
View = BasicView.extend Polling,
popup: Ember.inject.service()
reposBinding: 'controllers.repos'
repoBinding: 'controller.repo'
buildBinding: 'controller.build'
@ -25,7 +26,7 @@ View = BasicView.extend Polling,
actions:
statusImages: () ->
@popupCloseAll()
@get('popup').close()
view = StatusImagesView.create(toolsView: this, container: @container)
BasicView.currentPopupView = view
view.appendTo($('body'))

View File

@ -1,8 +0,0 @@
`import BasicView from 'travis/views/basic'`
`import Polling from 'travis/mixins/polling'`
View = BasicView.extend Polling,
pollHook: (store) ->
@get('controller.store').find('job', {})
`export default View`

View File

@ -3,16 +3,16 @@
"dependencies": {
"handlebars": "2.0.0",
"jquery": "^1.11.1",
"ember": "1.13.3",
"ember": "1.13.6",
"ember-data": "1.0.0-beta.16.1",
"ember-resolver": "~0.1.15",
"loader.js": "ember-cli/loader.js#1.0.1",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli/ember-cli-test-loader#0.1.0",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.4",
"ember-qunit": "0.4.0",
"ember-qunit": "0.4.9",
"ember-qunit-notifications": "0.0.5",
"qunit": "~1.17.1",
"qunit": "~1.18.0",
"visibilityjs": "~1.2.1",
"JavaScript-MD5": "~1.1.0",
"moment": "~2.9.0",

View File

@ -14,14 +14,14 @@
},
"repository": "",
"engines": {
"node": "0.10.32"
"node": "0.12.x"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.0.2",
"broccoli-sass": "0.6.5",
"ember-cli": "^1.13.1",
"broccoli-sass": "0.6.6",
"ember-cli": "1.13.7",
"ember-cli-app-version": "0.4.0",
"ember-cli-autoprefixer": "^0.3.0",
"ember-cli-babel": "5.0.0",
@ -35,7 +35,7 @@
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-inline-images": "^0.0.4",
"ember-cli-pretender": "0.3.1",
"ember-cli-qunit": "0.3.15",
"ember-cli-qunit": "0.3.20",
"ember-cli-release": "0.2.3",
"ember-cli-sauce": "^1.1.0",
"ember-cli-uglify": "1.0.1",