Add button for removing logs
This commit is contained in:
parent
e98d429426
commit
c3a843a886
|
@ -83,6 +83,14 @@ require 'travis/model'
|
||||||
Travis.ajax.post "/jobs/#{@get('id')}/cancel"
|
Travis.ajax.post "/jobs/#{@get('id')}/cancel"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
removeLog: ->
|
||||||
|
Travis.ajax.patch("/jobs/#{@get('id')}/log").then =>
|
||||||
|
@reloadLog()
|
||||||
|
|
||||||
|
reloadLog: ->
|
||||||
|
@clearLog()
|
||||||
|
@get('log').fetch()
|
||||||
|
|
||||||
requeue: ->
|
requeue: ->
|
||||||
Travis.ajax.post "/jobs/#{@get('id')}/restart"
|
Travis.ajax.post "/jobs/#{@get('id')}/restart"
|
||||||
|
|
||||||
|
@ -125,6 +133,12 @@ require 'travis/model'
|
||||||
moment(finishedAt).format('lll')
|
moment(finishedAt).format('lll')
|
||||||
).property('finishedAt')
|
).property('finishedAt')
|
||||||
|
|
||||||
|
canRemoveLog: (->
|
||||||
|
# This should somehow get the status of removed log, but unfortunately there is
|
||||||
|
# no easy way to do that at the moment
|
||||||
|
true
|
||||||
|
).property()
|
||||||
|
|
||||||
@Travis.Job.reopenClass
|
@Travis.Job.reopenClass
|
||||||
queued: ->
|
queued: ->
|
||||||
filtered = Ember.FilteredRecordArray.create(
|
filtered = Ember.FilteredRecordArray.create(
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
<div id="actions">
|
<div id="actions">
|
||||||
<ul>
|
<ul>
|
||||||
|
{{#if view.displayRemoveLog}}
|
||||||
|
<li class="icon" title="Remove Log">
|
||||||
|
<a href="#" {{action "removeLog" target="view"}}
|
||||||
|
{{bind-attr class="view.canRemoveLog::disabled"}}><img class="icon" src="/images/icons/off.svg" width="20"></a>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
{{#if view.displayCancelBuild}}
|
{{#if view.displayCancelBuild}}
|
||||||
<li class="icon" title="Cancel Build">
|
<li class="icon" title="Cancel Build">
|
||||||
<a href="#" {{action "cancelBuild" target="view"}}
|
<a href="#" {{action "cancelBuild" target="view"}}
|
||||||
|
|
|
@ -193,6 +193,20 @@ Travis.reopen
|
||||||
else
|
else
|
||||||
Travis.flash(error: 'An error occured when canceling the build')
|
Travis.flash(error: 'An error occured when canceling the build')
|
||||||
|
|
||||||
|
|
||||||
|
removeLog: ->
|
||||||
|
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: ->
|
cancelJob: ->
|
||||||
if @get('canCancelJob')
|
if @get('canCancelJob')
|
||||||
Travis.flash(notice: 'Job cancellation has been scheduled.')
|
Travis.flash(notice: 'Job cancellation has been scheduled.')
|
||||||
|
@ -246,6 +260,14 @@ Travis.reopen
|
||||||
Travis.Urls.plainTextLog(id)
|
Travis.Urls.plainTextLog(id)
|
||||||
).property('jobIdForLog')
|
).property('jobIdForLog')
|
||||||
|
|
||||||
|
canRemoveLog: (->
|
||||||
|
@get('displayRemoveLog') && @get('hasPermission')
|
||||||
|
).property('displayRemoveLog', 'hasPermission')
|
||||||
|
|
||||||
|
displayRemoveLog: (->
|
||||||
|
(@get('isJobTab') || (@get('isBuildTab') && @get('build.jobs.length') == 1)) && @get('build.jobs.firstObject.canRemoveLog')
|
||||||
|
).property('isJobTab', 'isBuildTab', 'build.jobs.length', 'job.canRemoveLog')
|
||||||
|
|
||||||
canCancelBuild: (->
|
canCancelBuild: (->
|
||||||
@get('displayCancelBuild') && @get('hasPermission')
|
@get('displayCancelBuild') && @get('hasPermission')
|
||||||
).property('displayCancelBuild', 'hasPermission')
|
).property('displayCancelBuild', 'hasPermission')
|
||||||
|
|
|
@ -14,6 +14,9 @@ Travis.ajax = Em.Object.create
|
||||||
post: (url, data, callback) ->
|
post: (url, data, callback) ->
|
||||||
@ajax(url, 'post', data: data, success: callback)
|
@ajax(url, 'post', data: data, success: callback)
|
||||||
|
|
||||||
|
patch: (url, data, callback) ->
|
||||||
|
@ajax(url, 'patch', data: data, success: callback)
|
||||||
|
|
||||||
needsAuth: (method, url) ->
|
needsAuth: (method, url) ->
|
||||||
return true if Travis.ajax.pro
|
return true if Travis.ajax.pro
|
||||||
return true if method != 'GET'
|
return true if method != 'GET'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user