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,23 +137,27 @@
|
||||||
<div class="dropup--blue">
|
<div class="dropup--blue">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
{{#unless triggeredBuild.isTriggered}}
|
{{#if hasTriggered}}
|
||||||
<a {{action 'tiggerBuild'}}>
|
<span>build was triggered</span>
|
||||||
<span class="icon-trigger">
|
|
||||||
<svg x="0px" y="0px" viewBox="0 0 20 20" xml:space="preserve">
|
|
||||||
<g id="Trigger">
|
|
||||||
<path fill="#A7AEAE" d="M17.2,7.9C17,7.6,16.6,7.7,16.3,8l-1,1.2C14.9,6,12.2,3.6,9,3.6c-3.6,0-6.4,2.9-6.4,6.4s2.9,6.4,6.4,6.4
|
|
||||||
c1.8,0,3.6-0.8,4.8-2.2c0.2-0.3,0.2-0.7-0.1-0.9c-0.3-0.2-0.7-0.2-0.9,0.1c-1,1.1-2.4,1.7-3.9,1.7c-2.8,0-5.1-2.3-5.1-5.1
|
|
||||||
S6.1,4.9,9,4.9c2.7,0,4.9,2.1,5.1,4.7l-1.7-1.1c-0.3-0.2-0.7-0.1-0.9,0.2s-0.1,0.7,0.2,0.9l2.8,1.8c0,0,0,0,0,0
|
|
||||||
c0.1,0.1,0.2,0.1,0.3,0.1c0.1,0,0.2,0,0.3-0.1c0,0,0.1,0,0.1-0.1c0,0,0.1-0.1,0.1-0.1l2-2.4C17.6,8.5,17.5,8.1,17.2,7.9z"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
Trigger a build
|
|
||||||
</a>
|
|
||||||
{{else}}
|
{{else}}
|
||||||
processing request
|
{{#if isTriggering}}
|
||||||
{{/unless}}
|
{{loading-indicator}}
|
||||||
|
{{else}}
|
||||||
|
<a {{action 'tiggerBuild'}}>
|
||||||
|
<span class="icon-trigger">
|
||||||
|
<svg x="0px" y="0px" viewBox="0 0 20 20" xml:space="preserve">
|
||||||
|
<g id="Trigger">
|
||||||
|
<path fill="#A7AEAE" d="M17.2,7.9C17,7.6,16.6,7.7,16.3,8l-1,1.2C14.9,6,12.2,3.6,9,3.6c-3.6,0-6.4,2.9-6.4,6.4s2.9,6.4,6.4,6.4
|
||||||
|
c1.8,0,3.6-0.8,4.8-2.2c0.2-0.3,0.2-0.7-0.1-0.9c-0.3-0.2-0.7-0.2-0.9,0.1c-1,1.1-2.4,1.7-3.9,1.7c-2.8,0-5.1-2.3-5.1-5.1
|
||||||
|
S6.1,4.9,9,4.9c2.7,0,4.9,2.1,5.1,4.7l-1.7-1.1c-0.3-0.2-0.7-0.1-0.9,0.2s-0.1,0.7,0.2,0.9l2.8,1.8c0,0,0,0,0,0
|
||||||
|
c0.1,0.1,0.2,0.1,0.3,0.1c0.1,0,0.2,0,0.3-0.1c0,0,0.1,0,0.1-0.1c0,0,0.1-0.1,0.1-0.1l2-2.4C17.6,8.5,17.5,8.1,17.2,7.9z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
Trigger a build
|
||||||
|
</a>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
</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