Show landing page before signin in

This commit is contained in:
Piotr Sarnacki 2015-03-23 17:35:59 +01:00
parent 53b2f6ca0e
commit b30492296c
5 changed files with 50 additions and 15 deletions

View File

@ -50,14 +50,10 @@ Controller = Ember.ArrayController.extend
Visibility.every @config.intervals.updateTimes, @updateTimes.bind(this)
recentRepos: (->
Ember.ArrayProxy.extend(
isLoadedBinding: 'repos.isLoaded'
repos: Repo.withLastBuild(@store)
sorted: Ember.computed.sort('repos', 'sortedReposKeys')
content: limit('sorted', 'limit')
sortedReposKeys: ['sortOrder:asc']
limit: 30
).create()
# I return an empty array here, because we're removing left sidebar, but
# I don't want to refactor too much code (it will be all changed anyway
# when we switch to new dashboard)
[]
).property()
updateTimes: ->

View File

@ -3,8 +3,26 @@
`import Location from 'travis/utils/location'`
Router = Ember.Router.extend
# TODO: we should use TravisLocation here
location: if Ember.testing then 'none' else 'travis'
location: (->
if Ember.testing
'none'
else
# this is needed, because in the location
# we need to decide if repositories or home needs
# to be displayed, based on the current login status
#
# we should probably think about a more general way to
# do this, location should not know about auth status
Location.create(auth: @container.lookup('auth:main'))
).property()
# TODO: this is needed, because in the original version
# the router tries to run `this.location`, which fails
# with computed properties. It can be removed once this is
# changed in Ember.js
generate: ->
url = this.router.generate.apply(this.router, arguments)
return this.get('location').formatURL(url)
handleURL: (url) ->
url = url.replace(/#.*?$/, '')

View File

@ -51,6 +51,6 @@ Route = TravisRoute.extend BuildFaviconMixin,
if @get('config').pro
@transitionTo('auth')
else
@transitionTo('main')
@transitionTo('home')
`export default Route`

View File

@ -1,5 +1,5 @@
<div class="wrapper">
<header id="top" class="top">
{{render "top"}}
</header>
@ -12,7 +12,7 @@
</div>
</div>
<aside id="left">
<aside id="left" {{bind-attr class="auth.signedIn::hidden"}}>
{{outlet "left"}}
</aside>

View File

@ -1,8 +1,29 @@
`import Ember from 'ember'`
Location = Ember.HistoryLocation.extend
init: ->
@_super.apply this, arguments
if auth = @get('auth')
# location's getURL is first called before we even
# get to routes, so autoSignIn won't be called in
# such case
auth.autoSignIn() unless auth.get('signedIn')
getURL: ->
location = @get('location')
location.pathname + location.search + location.hash
url = this._super.apply(this, arguments)
if location.pathname == '/'
if @get('auth.signedIn')
return '/repositories'
else
return '/home'
url
formatURL: (logicalPath) ->
if logicalPath == '/repositories' || logicalPath == '/home'
'/'
else
@_super.apply this, arguments
`export default Location`