initial attempt to trigger the first build of a repo through api

This commit is contained in:
Lisa Passing 2015-07-29 16:07:31 +02:00
parent d15d35a9ff
commit 5b361a49ef
4 changed files with 37 additions and 9 deletions

View File

@ -1,5 +1,21 @@
`import Ember from 'ember'`
`import Ajax from 'travis/utils/ajax'`
`import config from 'travis/config/environment'`
NoBuildsComponent = Ember.Component.extend()
NoBuildsComponent = Ember.Component.extend
actions:
triggerBuild: () ->
@set('isLoading', true)
apiEndpoint = config.apiEndpoint
$.ajax(apiEndpoint + "/v3/repo/#{@get('repo.repo.id')}/requests", {
headers: {
Authorization: 'token ' + @get('repo.auth')
},
type: "POST"
}).then( =>
@set('isLoading', false)
# @transitionToRoute('repo')
);
`export default NoBuildsComponent`

View File

@ -22,14 +22,21 @@ Controller = Ember.ArrayController.extend
).property('tab', 'lastObject.number')
displayPullRequests: (->
if Ember.isEmpty(@get('repo.builds.content'))
return false # if there is no build there is no PR
else if Ember.isEmpty(@get('repo.pullRequests.content'))
return true
if @get('tab') == 'pull_requests'
if Ember.isEmpty(@get('repo.pullRequests.content'))
true
else
false
else
return false
false
).property('tab', 'repo.builds', 'repo.pullRequests')
).property('tab', 'lastObject.number')
things: (->
return {
repo: @get('repo'),
auth: @auth.token()
}
).property('repo')
olderThanNumber: (id, number, type) ->
options = { repository_id: id, after_number: number }
@ -38,4 +45,5 @@ Controller = Ember.ArrayController.extend
@store.find('build', options)
`export default Controller`

View File

@ -3,7 +3,7 @@
{{#each controller as |build|}}
{{builds-item build=build}}
{{else}}
{{no-builds isPR=displayPullRequests}}
{{no-builds repo=things isPR=displayPullRequests}}
{{/each}}
{{#if displayShowMoreButton}}
<p>

View File

@ -65,7 +65,11 @@
{{#unless isPR}}
<h2 class="page-title">No builds for this repository</h2>
<p class="page-notice">Want to start testing this project on Travis CI?</p>
<a href="http://docs.travis-ci.com/user/getting-started/" class="button button--green">Read the Docs on Getting Started</a>
{{#if isLoading}}
{{loading-indicator}}
{{else}}
<a href="#" class="button button--green" {{action "triggerBuild"}}>Trigger the first build</a>
{{/if}}
{{else}}
<h2 class="page-title">No Pull Request builds for this Repositiory</h2>
{{/unless}}