add cancel menu items
This commit is contained in:
parent
0a635c8b39
commit
f6975e5b02
|
@ -14,9 +14,9 @@ require 'travis/model'
|
||||||
startedAt: DS.attr('string', key: 'started_at')
|
startedAt: DS.attr('string', key: 'started_at')
|
||||||
finishedAt: DS.attr('string', key: 'finished_at')
|
finishedAt: DS.attr('string', key: 'finished_at')
|
||||||
|
|
||||||
repo: DS.belongsTo('Travis.Repo', key: 'repository_id')
|
repo: DS.belongsTo('Travis.Repo', key: 'repository_id')
|
||||||
commit: DS.belongsTo('Travis.Commit')
|
commit: DS.belongsTo('Travis.Commit')
|
||||||
jobs: DS.hasMany('Travis.Job', key: 'job_ids')
|
jobs: DS.hasMany('Travis.Job', key: 'job_ids')
|
||||||
|
|
||||||
config: (->
|
config: (->
|
||||||
Travis.Helpers.compact(@get('data.config'))
|
Travis.Helpers.compact(@get('data.config'))
|
||||||
|
@ -49,6 +49,14 @@ require 'travis/model'
|
||||||
$.map(headers.concat(keys), (key) -> return $.camelize(key))
|
$.map(headers.concat(keys), (key) -> return $.camelize(key))
|
||||||
).property('config')
|
).property('config')
|
||||||
|
|
||||||
|
canCancel: (->
|
||||||
|
@get('state') == 'created' # TODO
|
||||||
|
).property('state')
|
||||||
|
|
||||||
|
cancel: (->
|
||||||
|
Travis.ajax.post "/builds/#{@get('id')}", _method: 'delete'
|
||||||
|
)
|
||||||
|
|
||||||
requeue: ->
|
requeue: ->
|
||||||
Travis.ajax.post '/requests', build_id: @get('id')
|
Travis.ajax.post '/requests', build_id: @get('id')
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,10 @@ require 'travis/model'
|
||||||
allowFailure: DS.attr('boolean', key: 'allow_failure')
|
allowFailure: DS.attr('boolean', key: 'allow_failure')
|
||||||
|
|
||||||
repositorySlug: DS.attr('string')
|
repositorySlug: DS.attr('string')
|
||||||
|
repo: DS.belongsTo('Travis.Repo', key: 'repository_id')
|
||||||
repo: DS.belongsTo('Travis.Repo', key: 'repository_id')
|
build: DS.belongsTo('Travis.Build', key: 'build_id')
|
||||||
build: DS.belongsTo('Travis.Build', key: 'build_id')
|
commit: DS.belongsTo('Travis.Commit', key: 'commit_id')
|
||||||
commit: DS.belongsTo('Travis.Commit', key: 'commit_id')
|
log: DS.belongsTo('Travis.Artifact', key: 'log_id')
|
||||||
log: DS.belongsTo('Travis.Artifact', key: 'log_id')
|
|
||||||
|
|
||||||
repoSlug: (->
|
repoSlug: (->
|
||||||
@get('repositorySlug')
|
@get('repositorySlug')
|
||||||
|
@ -59,6 +58,14 @@ require 'travis/model'
|
||||||
[]
|
[]
|
||||||
).property('config')
|
).property('config')
|
||||||
|
|
||||||
|
canCancel: (->
|
||||||
|
@get('state') == 'created' || @get('state') == 'queued' # TODO
|
||||||
|
).property('state')
|
||||||
|
|
||||||
|
cancel: (->
|
||||||
|
Travis.ajax.post "/jobs/#{@get('id')}", _method: 'delete'
|
||||||
|
)
|
||||||
|
|
||||||
requeue: ->
|
requeue: ->
|
||||||
Travis.ajax.post '/requests', job_id: @get('id')
|
Travis.ajax.post '/requests', job_id: @get('id')
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,16 @@
|
||||||
<li>
|
<li>
|
||||||
<a href="#" name="status-images" class="open-popup" {{action statusImages target="view"}}>Status Images</a>
|
<a href="#" name="status-images" class="open-popup" {{action statusImages target="view"}}>Status Images</a>
|
||||||
</li>
|
</li>
|
||||||
|
{{#if view.canCancelBuild}}
|
||||||
|
<li>
|
||||||
|
<a href="#" {{action cancelBuild target="view"}}>Cancel Build</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
{{#if view.canCancelJob}}
|
||||||
|
<li>
|
||||||
|
<a href="#" {{action cancelJob target="view"}}>Cancel Job</a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
{{#if view.canRequeueBuild}}
|
{{#if view.canRequeueBuild}}
|
||||||
<li>
|
<li>
|
||||||
<a href="#" {{action requeueBuild target="view"}}>Rebuild</a>
|
<a href="#" {{action requeueBuild target="view"}}>Rebuild</a>
|
||||||
|
|
|
@ -90,6 +90,18 @@
|
||||||
element = $('#tools .menu').toggleClass('display')
|
element = $('#tools .menu').toggleClass('display')
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
|
||||||
|
requeue: ->
|
||||||
|
@closeMenu()
|
||||||
|
@get('build').requeue()
|
||||||
|
|
||||||
|
cancelBuild: ->
|
||||||
|
@closeMenu()
|
||||||
|
@get('build').cancel()
|
||||||
|
|
||||||
|
cancelJob: ->
|
||||||
|
@closeMenu()
|
||||||
|
@get('job').cancel()
|
||||||
|
|
||||||
statusImages: (event) ->
|
statusImages: (event) ->
|
||||||
@set('active', true)
|
@set('active', true)
|
||||||
@closeMenu()
|
@closeMenu()
|
||||||
|
@ -128,20 +140,30 @@
|
||||||
@get('isJobTab') && @get('job.isFinished') && @get('hasPermissions')
|
@get('isJobTab') && @get('job.isFinished') && @get('hasPermissions')
|
||||||
).property('isJobTab', 'job.isFinished', 'hasPermissions')
|
).property('isJobTab', 'job.isFinished', 'hasPermissions')
|
||||||
|
|
||||||
|
canCancelBuild: (->
|
||||||
|
@get('isBuildTab') && @get('build.canCancel') && @get('hasPermission')
|
||||||
|
).property('build.state', 'hasPushPermissions', 'tab')
|
||||||
|
|
||||||
canRegenerateKey: (->
|
canRegenerateKey: (->
|
||||||
@get('hasPermissions')
|
@get('hasPermissions')
|
||||||
).property('hasPermissions')
|
).property('hasPermissions')
|
||||||
|
|
||||||
isBuildTab: (->
|
canCancelJob: (->
|
||||||
# ['current', 'build', 'job'].indexOf(@get('tab')) > -1
|
console.log @get('isJobTab')
|
||||||
@get('tab') in ['current', 'build']
|
console.log @get('job.canCancel')
|
||||||
).property('tab')
|
console.log @get('hasPermission')
|
||||||
|
@get('isJobTab') && @get('job.canCancel') && @get('hasPermission')
|
||||||
|
).property('job.state', 'hasPushPermissions', 'tab')
|
||||||
|
|
||||||
isJobTab: (->
|
isJobTab: (->
|
||||||
@get('tab') == 'job'
|
@get('tab') == 'job'
|
||||||
).property('tab')
|
).property('tab')
|
||||||
|
|
||||||
hasPermissions: (->
|
isBuildTab: (->
|
||||||
|
['current', 'build'].indexOf(@get('tab')) > -1
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
hasPermission: (->
|
||||||
if permissions = Travis.app.get('currentUser.permissions')
|
if permissions = Travis.app.get('currentUser.permissions')
|
||||||
permissions.indexOf(@get('repo.id')) > -1
|
permissions.indexOf(@get('repo.id')) > -1
|
||||||
).property('Travis.app.currentUser.permissions.length', 'repo.id')
|
).property('Travis.app.currentUser.permissions.length', 'repo.id')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user