fix trigger build request and ui feedback

This commit is contained in:
Lisa P 2015-09-15 18:41:03 +02:00
parent e8fb719591
commit 8ea023cdbd
2 changed files with 32 additions and 30 deletions

View File

@ -10,6 +10,8 @@ BranchRowComponent = Ember.Component.extend
classNameBindings: ['build.last_build.state']
classNames: ['branch-row']
isLoading: false
isTriggering: false
hasTriggered: false
urlGithubCommit: (->
githubCommitUrl(@get('build.repository.slug'), @get('build.last_build.commit.sha'))
@ -49,32 +51,28 @@ BranchRowComponent = Ember.Component.extend
lastBuilds
).property()
triggeredBuild: (->
triggeredBuild = Ember.ArrayProxy.create(
isTriggered: false,
status: null
)
).property("triggeredBuild.status['@type']")
triggerBuild: (->
apiEndpoint = config.apiEndpoint
repoId = @get('build.repository.id')
branchName = @get('build.name')
options = {
type: 'POST'
type: 'POST',
body: {
request: {
branch: @get('build.name')
}
}
}
if @get('auth.signedIn')
options.headers = { Authorization: "token #{@auth.token()}" }
$.ajax("#{apiEndpoint}/v3/repo/#{repoId}/requests", options).then (response) ->
@triggerBuild.set('isTriggered', true)
@triggerBuild.set('status', response)
console.log(response)
console.log('Build triggered')
$.ajax("#{apiEndpoint}/v3/repo/#{repoId}/requests", options).then (response) =>
@.set('isTriggering', false)
@.set('hasTriggered', true)
)
actions:
tiggerBuild: (branch) ->
console.log('trigger build')
@.set('isTriggering', true)
@triggerBuild()
viewAllBuilds: (branch) ->

View File

@ -137,7 +137,12 @@
<div class="dropup--blue">
<ul>
<li>
{{#unless triggeredBuild.isTriggered}}
{{#if hasTriggered}}
<span>build was triggered</span>
{{else}}
{{#if isTriggering}}
{{loading-indicator}}
{{else}}
<a {{action 'tiggerBuild'}}>
<span class="icon-trigger">
<svg x="0px" y="0px" viewBox="0 0 20 20" xml:space="preserve">
@ -151,9 +156,8 @@
</span>
Trigger a build
</a>
{{else}}
processing request
{{/unless}}
{{/if}}
{{/if}}
</li>
<li><a {{action 'viewAllBuilds'}}>
<span class="icon-eye">