diff --git a/assets/scripts/app/controllers/repos.coffee b/assets/scripts/app/controllers/repos.coffee index 0a3cf28c..8bb5a377 100644 --- a/assets/scripts/app/controllers/repos.coffee +++ b/assets/scripts/app/controllers/repos.coffee @@ -16,10 +16,13 @@ Travis.ReposController = Ember.ArrayController.extend ).observes('currentUser.id') tabOrIsLoadedDidChange: (-> + @possiblyRedirectToGettingStartedPage() + ).observes('isLoaded', 'tab', 'length') + + possiblyRedirectToGettingStartedPage: -> Ember.run.scheduleOnce 'routerTransitions', this, -> if @get('tab') == 'owned' && @get('isLoaded') && @get('length') == 0 - @container.lookup('router:main').send('renderNoOwnedRepos') - ).observes('isLoaded', 'tab', 'length') + @container.lookup('router:main').send('redirectToGettingStarted') isLoadedBinding: 'content.isLoaded' needs: ['currentUser', 'repo'] diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index ac225f0f..0b9023e6 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -38,6 +38,9 @@ Travis.Route = Ember.Route.extend Travis.ApplicationRoute = Travis.Route.extend actions: + redirectToGettingStarted: -> + # do nothing, we handle it only in index path + renderDefaultTemplate: -> @renderDefaultTemplate() if @renderDefaultTemplate @@ -49,9 +52,6 @@ Travis.ApplicationRoute = Travis.Route.extend else return true - renderNoOwnedRepos: -> - @transitionTo('getting_started') - renderFirstSync: -> @renderFirstSync() @@ -116,7 +116,7 @@ Travis.GettingStartedRoute = Travis.Route.extend Travis.FirstSyncRoute = Travis.Route.extend actions: - renderNoOwnedRepos: (->) + redirectToGettingStarted: -> # do nothing, we are showing first sync, so it's normal that there is # no owned repos @@ -142,12 +142,19 @@ Travis.IndexCurrentRoute = Travis.Route.extend Travis.SetupLastBuild, @controllerFor('repo').activate('index') @controllerFor('repos').addObserver('firstObject', this, 'currentRepoDidChange') + afterModel: -> + @controllerFor('repos').possiblyRedirectToGettingStartedPage() + deactivate: -> @controllerFor('repos').removeObserver('firstObject', this, 'currentRepoDidChange') currentRepoDidChange: -> @controllerFor('repo').set('repo', @controllerFor('repos').get('firstObject')) + actions: + redirectToGettingStarted: -> + @transitionTo('getting_started') + Travis.AbstractBuildsRoute = Travis.Route.extend renderTemplate: -> @render 'builds', into: 'repo', outlet: 'pane'