Show appropriate message if repository was not found

This commit is contained in:
Piotr Sarnacki 2013-03-11 19:47:59 +01:00
parent a529231f1f
commit 8fab8448c2
5 changed files with 39 additions and 21 deletions

View File

@ -3,6 +3,10 @@ Travis.RepoController = Travis.Controller.extend
needs: ['repos', 'currentUser']
currentUserBinding: 'controllers.currentUser'
isError: (-> @get('content.isError') ).property('content.isError')
slug: (-> @get('content.slug') ).property('content.slug')
isLoading: (-> @get('content.isLoading') ).property('content.isLoading')
init: ->
@_super.apply this, arguments
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)

View File

@ -140,7 +140,7 @@ Travis.RepoRoute = Ember.Route.extend
deserialize: (params) ->
slug = "#{params.owner}/#{params.name}"
content = Ember.Object.create slug: slug, isLoaded: false
content = Ember.Object.create slug: slug, isLoaded: false, isLoading: true
proxy = Ember.ObjectProxy.create(content: content)
repos = Travis.Repo.bySlug(slug)
@ -148,7 +148,14 @@ Travis.RepoRoute = Ember.Route.extend
observer = ->
if repos.get 'isLoaded'
repos.removeObserver 'isLoaded', observer
proxy.set 'content', repos.objectAt(0)
proxy.set 'isLoading', false
if repos.get('length') == 0
# isError is also used in DS.Model, but maybe we should use something
# more focused like notFound later
proxy.set 'isError', true
else
proxy.set 'content', repos.objectAt(0)
if repos.length
proxy.set('content', repos[0])

View File

@ -2,25 +2,28 @@
{{#if view.isEmpty}}
{{view Travis.ReposEmptyView}}
{{else}}
{{#if repo.isLoaded}}
{{#with repo}}
<h3>
<a {{bindAttr href="controller.urlGithub"}}>{{slug}}</a>
</h3>
<p class="description">{{description}}</p>
{{view Travis.RepoShowTabsView}}
{{view Travis.RepoShowToolsView}}
{{/with}}
{{#if isError}}
<span class="not-found">The repository at {{slug}} was not found.</span>
{{else}}
<span>Loading</span>
{{/if}}
{{#if repo.isLoaded}}
{{#with repo}}
<h3>
<a {{bindAttr href="controller.urlGithub"}}>{{slug}}</a>
</h3>
<div class="tab">
{{outlet pane}}
</div>
<p class="description">{{description}}</p>
{{view Travis.RepoShowTabsView}}
{{view Travis.RepoShowToolsView}}
{{/with}}
<div class="tab">
{{outlet pane}}
</div>
{{else}}
<span>Loading</span>
{{/if}}
{{/if}}
{{/if}}
</div>

View File

@ -5,8 +5,7 @@ Travis.reopen
repoBinding: 'controllers.repo'
reposBinding: 'controllers.repos'
isLoadedBinding: 'repo.isLoaded'
classNameBindings: ['loading:isLoaded']
classNameBindings: ['controller.isLoading:loading']
isEmpty: (->
@get('repos.isLoaded') && @get('repos.length') == 0

View File

@ -6,6 +6,11 @@
overflow-x: hidden
padding-right: 10px
.not-found
display: block
padding: 10px 5px
font-size: 12px
.description, .language
font-weight: normal
color: $color-text-light