Prevent sending double restart request

When requeue icon was clicked 2 times it was sometimes the case that we
sent 2 requests. This commit prevents that and also adds a little nice
indicator instead of restart button while we're sending the request.
This commit is contained in:
Piotr Sarnacki 2014-05-05 15:35:37 +02:00
parent 2172fb705a
commit 31cb3c0bb5
3 changed files with 35 additions and 9 deletions

View File

@ -14,14 +14,22 @@
{{/if}}
{{#if view.displayRequeueBuild}}
<li class="icon" title="Restart Build">
<a href="#" {{action "requeueBuild" target="view"}}
{{bind-attr class="view.canRequeueBuild::disabled"}}><img class="icon" src="/images/icons/repeat.png" width="20"></a>
{{#if view.requeueing}}
<span class="icon loading"></span>
{{else}}
<a href="#" {{action "requeueBuild" target="view"}}
{{bind-attr class="view.canRequeueBuild::disabled"}}><img class="icon" src="/images/icons/repeat.png" width="20"></a>
{{/if}}
</li>
{{/if}}
{{#if view.displayRequeueJob}}
<li class="icon" title="Restart Job">
<a href="#" {{action "requeueJob" target="view"}}
{{bind-attr class="view.canRequeueJob::disabled"}}><img src="/images/icons/repeat.png" width="20"></a>
{{#if view.requeueing}}
<span class="icon loading"></span>
{{else}}
<a href="#" {{action "requeueJob" target="view"}}
{{bind-attr class="view.canRequeueJob::disabled"}}><img src="/images/icons/repeat.png" width="20"></a>
{{/if}}
</li>
{{/if}}
{{!TODO: for some reason showDownloadLog, which just delegates to jobIdForLog

View File

@ -154,9 +154,6 @@ Travis.reopen
tabBinding: 'controller.tab'
currentUserBinding: 'controller.currentUser'
requeue: ->
@get('build').requeue()
cancelBuild: ->
if @get('canCancelBuild')
Travis.flash(notice: 'Build cancelation has been scheduled.')
@ -256,12 +253,20 @@ Travis.reopen
@popup('code-climate')
event.stopPropagation() if event?
requeueFinished: ->
@set('requeueing', false)
requeue: (thing) ->
return if @get('requeueing')
@set('requeueing', true)
thing.requeue().then(this.requeueFinished.bind(this), this.requeueFinished.bind(this))
requeueBuild: ->
if @get('canRequeueBuild')
@get('build').requeue()
@requeue @get('build')
requeueJob: ->
if @get('canRequeueJob')
@get('job').requeue()
@requeue @get('job')

View File

@ -61,6 +61,19 @@
text-align: right
li.icon
span.loading
display: inline-block
height: 20px
position: relative
top: 1px
cursor: pointer
color: #fef4e9
border: solid 1px #d6d6d6
background-color: #f4f4f4
text-align: center
margin-left: 5px
background-position: center center
a
display: inline-block
width: 25px