diff --git a/assets/scripts/app/models/job.coffee b/assets/scripts/app/models/job.coffee
index 58c5d271..92a711fb 100644
--- a/assets/scripts/app/models/job.coffee
+++ b/assets/scripts/app/models/job.coffee
@@ -83,6 +83,14 @@ require 'travis/model'
Travis.ajax.post "/jobs/#{@get('id')}/cancel"
)
+ removeLog: ->
+ Travis.ajax.patch("/jobs/#{@get('id')}/log").then =>
+ @reloadLog()
+
+ reloadLog: ->
+ @clearLog()
+ @get('log').fetch()
+
requeue: ->
Travis.ajax.post "/jobs/#{@get('id')}/restart"
@@ -125,6 +133,12 @@ require 'travis/model'
moment(finishedAt).format('lll')
).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
queued: ->
filtered = Ember.FilteredRecordArray.create(
diff --git a/assets/scripts/app/templates/repos/show/actions.hbs b/assets/scripts/app/templates/repos/show/actions.hbs
index c6626123..bb398840 100644
--- a/assets/scripts/app/templates/repos/show/actions.hbs
+++ b/assets/scripts/app/templates/repos/show/actions.hbs
@@ -1,5 +1,11 @@
+ {{#if view.displayRemoveLog}}
+ -
+
+
+ {{/if}}
{{#if view.displayCancelBuild}}
-
+ 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.')
@@ -246,6 +260,14 @@ Travis.reopen
Travis.Urls.plainTextLog(id)
).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: (->
@get('displayCancelBuild') && @get('hasPermission')
).property('displayCancelBuild', 'hasPermission')
diff --git a/assets/scripts/lib/travis/ajax.coffee b/assets/scripts/lib/travis/ajax.coffee
index 95911d06..5b3a37ed 100644
--- a/assets/scripts/lib/travis/ajax.coffee
+++ b/assets/scripts/lib/travis/ajax.coffee
@@ -14,6 +14,9 @@ Travis.ajax = Em.Object.create
post: (url, data, callback) ->
@ajax(url, 'post', data: data, success: callback)
+ patch: (url, data, callback) ->
+ @ajax(url, 'patch', data: data, success: callback)
+
needsAuth: (method, url) ->
return true if Travis.ajax.pro
return true if method != 'GET'