fix trigger build request and ui feedback
This commit is contained in:
parent
e8fb719591
commit
8ea023cdbd
|
@ -10,6 +10,8 @@ BranchRowComponent = Ember.Component.extend
|
||||||
classNameBindings: ['build.last_build.state']
|
classNameBindings: ['build.last_build.state']
|
||||||
classNames: ['branch-row']
|
classNames: ['branch-row']
|
||||||
isLoading: false
|
isLoading: false
|
||||||
|
isTriggering: false
|
||||||
|
hasTriggered: false
|
||||||
|
|
||||||
urlGithubCommit: (->
|
urlGithubCommit: (->
|
||||||
githubCommitUrl(@get('build.repository.slug'), @get('build.last_build.commit.sha'))
|
githubCommitUrl(@get('build.repository.slug'), @get('build.last_build.commit.sha'))
|
||||||
|
@ -49,32 +51,28 @@ BranchRowComponent = Ember.Component.extend
|
||||||
lastBuilds
|
lastBuilds
|
||||||
).property()
|
).property()
|
||||||
|
|
||||||
triggeredBuild: (->
|
|
||||||
triggeredBuild = Ember.ArrayProxy.create(
|
|
||||||
isTriggered: false,
|
|
||||||
status: null
|
|
||||||
)
|
|
||||||
).property("triggeredBuild.status['@type']")
|
|
||||||
|
|
||||||
triggerBuild: (->
|
triggerBuild: (->
|
||||||
apiEndpoint = config.apiEndpoint
|
apiEndpoint = config.apiEndpoint
|
||||||
repoId = @get('build.repository.id')
|
repoId = @get('build.repository.id')
|
||||||
branchName = @get('build.name')
|
|
||||||
options = {
|
options = {
|
||||||
type: 'POST'
|
type: 'POST',
|
||||||
|
body: {
|
||||||
|
request: {
|
||||||
|
branch: @get('build.name')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if @get('auth.signedIn')
|
if @get('auth.signedIn')
|
||||||
options.headers = { Authorization: "token #{@auth.token()}" }
|
options.headers = { Authorization: "token #{@auth.token()}" }
|
||||||
$.ajax("#{apiEndpoint}/v3/repo/#{repoId}/requests", options).then (response) ->
|
$.ajax("#{apiEndpoint}/v3/repo/#{repoId}/requests", options).then (response) =>
|
||||||
@triggerBuild.set('isTriggered', true)
|
@.set('isTriggering', false)
|
||||||
@triggerBuild.set('status', response)
|
@.set('hasTriggered', true)
|
||||||
console.log(response)
|
|
||||||
console.log('Build triggered')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
tiggerBuild: (branch) ->
|
tiggerBuild: (branch) ->
|
||||||
console.log('trigger build')
|
console.log('trigger build')
|
||||||
|
@.set('isTriggering', true)
|
||||||
@triggerBuild()
|
@triggerBuild()
|
||||||
|
|
||||||
viewAllBuilds: (branch) ->
|
viewAllBuilds: (branch) ->
|
||||||
|
|
|
@ -137,7 +137,12 @@
|
||||||
<div class="dropup--blue">
|
<div class="dropup--blue">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
{{#unless triggeredBuild.isTriggered}}
|
{{#if hasTriggered}}
|
||||||
|
<span>build was triggered</span>
|
||||||
|
{{else}}
|
||||||
|
{{#if isTriggering}}
|
||||||
|
{{loading-indicator}}
|
||||||
|
{{else}}
|
||||||
<a {{action 'tiggerBuild'}}>
|
<a {{action 'tiggerBuild'}}>
|
||||||
<span class="icon-trigger">
|
<span class="icon-trigger">
|
||||||
<svg x="0px" y="0px" viewBox="0 0 20 20" xml:space="preserve">
|
<svg x="0px" y="0px" viewBox="0 0 20 20" xml:space="preserve">
|
||||||
|
@ -151,9 +156,8 @@
|
||||||
</span>
|
</span>
|
||||||
Trigger a build
|
Trigger a build
|
||||||
</a>
|
</a>
|
||||||
{{else}}
|
{{/if}}
|
||||||
processing request
|
{{/if}}
|
||||||
{{/unless}}
|
|
||||||
</li>
|
</li>
|
||||||
<li><a {{action 'viewAllBuilds'}}>
|
<li><a {{action 'viewAllBuilds'}}>
|
||||||
<span class="icon-eye">
|
<span class="icon-eye">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user