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