Show caches also if there're no caches for push builds

This commit fixes caches view to show caches also if only PR caches
exist. Previous version checked for pushes only.
This commit is contained in:
Piotr Sarnacki 2015-05-06 11:34:02 +02:00
parent 1fc1fdadfa
commit bfb4946df8
4 changed files with 17 additions and 16 deletions

View File

@ -7,6 +7,10 @@ Controller = Ember.Controller.extend
isDeleting: false
cachesExist: (->
@get('model.pushes.length') || @get('model.pullRequests.length')
).property('model.pushes.length', 'model.pullRequests.length')
actions:
deleteRepoCache: ->
return if @get('isDeleting')

View File

@ -12,11 +12,11 @@ Route = TravisRoute.extend
repo = @modelFor('repo')
Ajax.get("/repos/#{repo.get('id')}/caches").then( (data) ->
caches = {}
data["caches"].forEach (cacheData) ->
branch = cacheData.branch
cache = caches[branch]
if cache
cache.size += cacheData.size
@ -28,7 +28,7 @@ Route = TravisRoute.extend
pushes = []
pullRequests = []
for branch, cache of caches
if /PR./.test(branch)
cache.type = "pull_request"

View File

@ -10,10 +10,6 @@ Route = TravisRoute.extend
"#{model.name}"
model: (params) ->
owner = {}
$.get(config.apiEndpoint + "/v3/owner/#{params.owner}?include=user.repositories,organization.repositories,build.commit,repository.active").then( (data) ->
data
)
$.get(config.apiEndpoint + "/v3/owner/#{params.owner}?include=user.repositories,organization.repositories,build.commit,repository.active")
`export default Route`

View File

@ -1,17 +1,18 @@
{{#if model.pushes.length}}
{{#if cachesExist}}
<div class="caches-header">
<h1 class="caches-title">All caches <small>(<a href="http://docs.travis-ci.com/user/caching/" title="">documentation</a>)</small></h1>
<a href="#" {{action "deleteRepoCache"}} {{bind-attr class="isDeleting:deleting :delete-repo-caches :button--delete"}}>
Delete all repository caches
</a>
</div>
<h2 class="caches-title">Pushes</h2>
<ul id="caches" class="caches">
{{#each cache in model.pushes }}
{{caches-item cache=cache repo=repo caches=model.pushes}}
{{/each}}
</ul>
{{#if model.pushes.length}}
<h2 class="caches-title">Pushes</h2>
<ul id="caches" class="caches">
{{#each cache in model.pushes }}
{{caches-item cache=cache repo=repo caches=model.pushes}}
{{/each}}
</ul>
{{/if}}
{{#if model.pullRequests.length}}
<h2 class="caches-title">Pull Requests</h2>