Merge branch 'master' into new-flash

This commit is contained in:
Lisa Passing 2015-03-23 13:38:02 +01:00
commit 8be71f07f5
17 changed files with 212 additions and 63 deletions

View File

@ -0,0 +1,21 @@
`import Ember from 'ember'`
`import { colorForState } from 'travis/utils/helpers'`
`import { languageConfigKeys } from 'travis/utils/keys-map';`
JobsItemComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['job.state']
classNames: ['tile', 'tile--jobs', 'row']
languages: (->
output = []
if config = @get('job.config')
for key, languageName of languageConfigKeys
if version = config[key]
output.push(languageName + ': ' + version)
output.join(' ')
).property('job.config')
`export default JobsItemComponent`

View File

@ -0,0 +1,11 @@
`import Ember from 'ember'`
JobsListComponent = Ember.Component.extend
jobTableId: Ember.computed(->
if @get('required')
'jobs'
else
'allowed_failure_jobs'
)
`export default JobsListComponent`

View File

@ -12,6 +12,11 @@ Controller = Ember.Controller.extend GithubUrlPropertievs,
currentItemBinding: 'build' currentItemBinding: 'build'
jobsLoaded: (->
if jobs = @get('build.jobs')
jobs.everyBy('config')
).property('build.jobs.@each.config')
loading: (-> loading: (->
@get('build.isLoading') @get('build.isLoading')
).property('build.isLoading') ).property('build.isLoading')

View File

@ -32,7 +32,7 @@ $tooltip-grey: #6A6C6D
bottom: -2.5em bottom: -2.5em
@media #{$medium-up} @media #{$medium-up}
width: 25rem width: 18rem
.tooltip-inner .tooltip-inner
height: 4.1em height: 4.1em

View File

@ -76,8 +76,14 @@
{{/unless}} {{/unless}}
{{#if build.isMatrix}} {{#if build.isMatrix}}
{{view 'jobs' jobs=build.requiredJobs required="true"}} {{#if jobsLoaded}}
{{view 'jobs' jobs=build.allowedFailureJobs}} {{jobs-list jobs=build.requiredJobs required="true"}}
{{jobs-list jobs=build.allowedFailureJobs}}
{{else}}
<div class="spinner-container">
<span class="sync-spinner sync-spinner--grey"><i></i><i></i><i></i></span>
</div>
{{/if}}
{{else}} {{else}}
{{view 'log' job=build.jobs.firstObject}} {{view 'log' job=build.jobs.firstObject}}
{{/if}} {{/if}}

View File

@ -0,0 +1,46 @@
{{#link-to "job" job.repo job}}
<div class="tile-status tile-status--job">
<span {{bind-attr class=":icon :icon--job job.state"}}></span>
</div>
<p class="job-id jobs-item build-status">
<span class="icon icon--hash-dark"></span>
{{job.number}}
</p>
<p {{bind-attr class=":job-os :jobs-item :build-os job.config.os"}}>
<span {{bind-attr class=":icon job.config.os"}}></span>
</p>
{{#if languages}}
<p class="job-lang jobs-item build-lang">
<span class="icon icon--lang"></span>
{{languages}}
</p>
{{else}}
<p class="job-lang jobs-item build-lang is-empty">
<span class="icon icon--lang"></span>
no language set
</p>
{{/if}}
<div class="job-anchor jobs-item">
{{#if job.config.env}}
<p class="job-env jobs-item build-env">
<span class="icon icon--env"></span>
{{job.config.env}}
</p>
{{else}}
<p class="job-env jobs-item build-env is-empty">
<span class="icon icon--env"></span>
no environment variables set
</p>
{{/if}}
<p class="job-duration jobs-item" {{bind-attr title="job.startedAt"}}>
<span class="icon icon--clock-dark"></span>
{{format-duration job.duration}}
</p>
</div>
{{/link-to}}

View File

@ -0,0 +1,21 @@
{{#if jobs.length}}
<section>
{{#if required}}
<h2 class="build-title">Build Jobs</h2>
{{else}}
<h2 class="build-title">Allowed Failures
<span class="icon icon--question"></span>
<div class="tooltip">
<p class="tooltip-inner">These are jobs you can allow to fail without failing your entire build</p>
</div>
</h2>
{{/if}}
<ul>
{{#each job in jobs}}
{{jobs-item job=job}}
{{/each}}
</ul>
</section>
{{/if}}

View File

@ -7,7 +7,7 @@
<h2 class="build-title">Allowed Failures <h2 class="build-title">Allowed Failures
<span class="icon icon--question"></span> <span class="icon icon--question"></span>
<div class="tooltip"> <div class="tooltip">
<p class="tooltip-inner">These are jobs you can allow to fail without failing your entire build</p> <p class="tooltip-inner">These are jobs are allowed to fail, without failing your entire build.</p>
</div> </div>
</h2> </h2>
{{/if}} {{/if}}

View File

@ -28,8 +28,8 @@ podStatusImage = ( (url, slug, branch) ->
"=for HTML <a href=\"#{url}\"><img src=\"#{statusImageUrl(slug, branch)}\"></a>" "=for HTML <a href=\"#{url}\"><img src=\"#{statusImageUrl(slug, branch)}\"></a>"
) )
ccxmlStatusUrl = ( (slug) -> ccxmlStatusUrl = ( (slug, branch) ->
ccXmlUrl(slug) ccXmlUrl(slug, branch)
) )
format = (version, slug, branch) -> format = (version, slug, branch) ->
@ -43,7 +43,7 @@ format = (version, slug, branch) ->
when 'AsciiDoc' then asciidocStatusImage(url, slug, branch) when 'AsciiDoc' then asciidocStatusImage(url, slug, branch)
when 'Rst' then rstStatusImage(url, slug, branch) when 'Rst' then rstStatusImage(url, slug, branch)
when 'Pod' then podStatusImage(url, slug, branch) when 'Pod' then podStatusImage(url, slug, branch)
when 'CCTray' then ccxmlStatusUrl(url, slug, branch) when 'CCTray' then ccxmlStatusUrl(slug, branch)
`export default format` `export default format`

View File

@ -28,12 +28,17 @@ statusImage = (slug, branch) ->
else else
"#{location.protocol}//#{location.host}/#{slug}.svg" + if branch then "?branch=#{encodeURIComponent(branch)}" else '' "#{location.protocol}//#{location.host}/#{slug}.svg" + if branch then "?branch=#{encodeURIComponent(branch)}" else ''
ccXml = (slug) -> ccXml = (slug, branch) ->
url = "##{config.apiEndpoint}/repos/#{slug}/cc.xml"
if branch
url = "#{url}?branch=#{branch}"
if config.pro if config.pro
delimiter = if url.indexOf('?') == -1 then '?' else '&'
token = Travis.__container__.lookup('controller:currentUser').get('token') token = Travis.__container__.lookup('controller:currentUser').get('token')
"##{config.apiEndpoint}/repos/#{slug}/cc.xml?token=#{token}" url = "#{url}#{delimiter}token=#{token}"
else
"#{config.apiEndpoint}/repos/#{slug}/cc.xml" url
email = (email) -> email = (email) ->
"mailto:#{email}" "mailto:#{email}"

View File

@ -1,26 +0,0 @@
`import BasicView from 'travis/views/basic'`
`import { colorForState } from 'travis/utils/helpers'`
`import { languageConfigKeys } from 'travis/utils/keys-map';`
View = BasicView.extend
tagName: 'div'
classNameBindings: ['color']
repoBinding: 'context.repo'
jobBinding: 'context'
color: (->
colorForState(@get('job.state'))
).property('job.state')
languages: (->
output = []
if config = @get('job.config')
for key, languageName of languageConfigKeys
if version = config[key]
output.push(languageName + ': ' + version)
output.join(' ')
).property()
`export default View`

View File

@ -1,23 +0,0 @@
`import Ember from 'ember'`
`import BasicView from 'travis/views/basic'`
View = BasicView.extend
templateName: 'jobs'
buildBinding: 'controller.build'
jobTableId: Ember.computed(->
if @get('required')
'jobs'
else
'allowed_failure_jobs'
)
actions:
popupClose: ->
@popupCloseAll()
openHelpPopup: ->
@popupCloseAll()
@popup('help-allowed_failures')
`export default View`

View File

@ -6,9 +6,6 @@
"SL_firefox" "SL_firefox"
], ],
"launch_in_dev": [ "launch_in_dev": [
"PhantomJS",
"Chrome",
"Firefox"
], ],
"launchers": { "launchers": {
"SL_chrome": { "SL_chrome": {

View File

@ -13,6 +13,15 @@
<link rel="stylesheet" href="assets/vendor.css"> <link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/travis.css"> <link rel="stylesheet" href="assets/travis.css">
<link rel="stylesheet" href="assets/test-support.css"> <link rel="stylesheet" href="assets/test-support.css">
<style>
#ember-testing-container {
top: 100px;
right: -620px;
}
#ember-testing-container:hover {
right: 0;
}
</style>
{{content-for 'head-footer'}} {{content-for 'head-footer'}}
{{content-for 'test-head-footer'}} {{content-for 'test-head-footer'}}

View File

@ -0,0 +1,39 @@
`import { test, moduleForComponent } from 'ember-qunit'`
moduleForComponent 'jobs-item', 'JobsItemComponent', {
# specify the other units that are required for this test
needs: ['helper:format-duration']
}
test 'it renders', ->
attributes = {
id: 10
state: 'passed'
number: '2'
config: {
rvm: '2.1.2'
jdk: 'openjdk6'
os: 'linux',
env: 'TESTS=unit'
},
duration: 100
}
job = Ember.Object.create(attributes)
component = @subject(job: job)
@append()
ok component.$().hasClass('passed'), 'component should have a state class (passed)'
equal component.$('.job-id').text().trim(), '2', 'job number should be displayed'
equal component.$('.job-lang').text().trim(), 'JDK: openjdk6 Ruby: 2.1.2', 'langauges list should be displayed'
equal component.$('.job-env').text().trim(), 'TESTS=unit', 'env should be displayed'
ok component.$('.job-os').hasClass('linux'), 'OS class should be added for OS icon'
equal component.$('.job-duration').text().trim(), '1 min 40 sec', 'duration should be displayed'
test 'ouputs info on not set properties', ->
job = Ember.Object.create()
component = @subject(job: job)
@append()
ok component.$('.job-env').text().match(/no environment variables set/), 'a message for no env vars should be displayed'
ok component.$('.job-lang').text().match(/no language set/), 'a message about no language being set should be displayed'

View File

@ -0,0 +1,25 @@
`import { test, moduleForComponent } from 'ember-qunit'`
moduleForComponent 'jobs-list', 'JobsListComponent', {
needs: ['helper:format-duration', 'component:jobs-item']
}
test 'it renders a list of jobs', ->
jobs = [Ember.Object.create(id: 1, state: 'passed'),
Ember.Object.create(id: 1, state: 'failed')]
component = @subject(jobs: jobs, required: true)
@append()
equal component.$('.build-title').text().trim(), 'Build Jobs'
equal component.$('li').length, 2, 'there should be 2 job items'
ok component.$('li:nth(0)').hasClass('passed'), 'passed class should be applied to a job'
ok component.$('li:nth(1)').hasClass('failed'), 'failed class should be applied to a job'
test 'it renders "Allowed Failures" version without a `required` property', ->
jobs = [Ember.Object.create(id: 1)]
component = @subject(jobs: jobs)
@append()
ok component.$('.build-title').text().match /Allowed Failures/

View File

@ -0,0 +1,13 @@
`import Ember from 'ember'`
`import format from 'travis/utils/status-image-formats'`
`import config from 'travis/config/environment'`
module 'Status image formats'
test 'it generates CCTray url with a slug', ->
url = format('CCTray', 'travis-ci/travis-web')
equal url, '#/repos/travis-ci/travis-web/cc.xml'
test 'it generates CCTray url with a slug and a branch', ->
url = format('CCTray', 'travis-ci/travis-web', 'development')
equal url, '#/repos/travis-ci/travis-web/cc.xml?branch=development'