Merge pull request #100 from KL-7/default-status-image-branch

Select current branch in status images popup.
This commit is contained in:
Piotr Sarnacki 2013-01-14 15:31:41 -08:00
commit 7c97317df6
2 changed files with 20 additions and 13 deletions

View File

@ -37,14 +37,14 @@
<p> <p>
<label>{{t repositories.branch}}:</label> <label>{{t repositories.branch}}:</label>
{{#if view.branches.isLoaded}} {{#if view.branches.isLoaded}}
{{view Ember.Select contentBinding="view.branches" selectionBinding="view.branch" optionLabelPath="content.commit.branch" optionValuePath="content.commit.branch"}} {{view Ember.Select contentBinding="view.branches" selectionBinding="view.statusImageBranch" optionLabelPath="content.commit.branch" optionValuePath="content.commit.branch"}}
{{else}} {{else}}
<span class="loading"></span> <span class="loading"></span>
{{/if}} {{/if}}
</p> </p>
<p> <p>
<label>{{t repositories.image_url}}:</label> <label>{{t repositories.image_url}}:</label>
<input type="text" class="url" {{bindAttr value="view.urlStatusImage"}}></input> <input type="text" class="url" {{bindAttr value="view.statusImageUrl"}}></input>
</p> </p>
<p> <p>
<label>{{t repositories.markdown}}:</label> <label>{{t repositories.markdown}}:</label>

View File

@ -173,26 +173,33 @@
@get('repo.branches') if @get('active') @get('repo.branches') if @get('active')
).property('active', 'repo.branches') ).property('active', 'repo.branches')
setStatusImageBranch: (->
if @get('repo.branches.isLoaded')
@set('statusImageBranch', @get('repo.branches').findProperty('commit.branch', @get('build.commit.branch')))
else
@set('statusImageBranch', null)
).observes('repo.branches', 'repo.branches.isLoaded', 'build.commit.branch')
urlRepo: (-> urlRepo: (->
'https://' + location.host + Travis.Urls.repo(@get('repo.slug')) 'https://' + location.host + Travis.Urls.repo(@get('repo.slug'))
).property('repo.slug') ).property('repo.slug')
urlStatusImage: (-> statusImageUrl: (->
Travis.Urls.statusImage(@get('repo.slug'), @get('branch.commit.branch')) Travis.Urls.statusImage(@get('repo.slug'), @get('statusImageBranch.commit.branch'))
).property('repo.slug', 'branch') ).property('repo.slug', 'statusImageBranch')
markdownStatusImage: (-> markdownStatusImage: (->
"[![Build Status](#{@get('urlStatusImage')})](#{@get('urlRepo')})" "[![Build Status](#{@get('statusImageUrl')})](#{@get('urlRepo')})"
).property('urlStatusImage') ).property('statusImageUrl')
textileStatusImage: (-> textileStatusImage: (->
"!#{@get('urlStatusImage')}!:#{@get('urlRepo')}" "!#{@get('statusImageUrl')}!:#{@get('urlRepo')}"
).property('urlStatusImage') ).property('statusImageUrl')
rdocStatusImage: (-> rdocStatusImage: (->
"{<img src=\"#{@get('urlStatusImage')}\" alt=\"Build Status\" />}[#{@get('urlRepo')}]" "{<img src=\"#{@get('statusImageUrl')}\" alt=\"Build Status\" />}[#{@get('urlRepo')}]"
).property('urlStatusImage') ).property('statusImageUrl')
asciidocStatusImage: (-> asciidocStatusImage: (->
"image:#{@get('urlStatusImage')}[\"Build Status\", link=\"#{@get('urlRepo')}\"]" "image:#{@get('statusImageUrl')}[\"Build Status\", link=\"#{@get('urlRepo')}\"]"
).property('urlStatusImage') ).property('statusImageUrl')