Redirect to getting started page if user has no repositories

This commit is contained in:
Piotr Sarnacki 2013-06-11 17:22:52 +02:00
parent 56422df915
commit 704bd9434e
7 changed files with 60 additions and 29 deletions

View File

@ -15,6 +15,13 @@ Travis.ReposController = Ember.ArrayController.extend
@activate('recent')
).observes('currentUser.id')
tabOrIsLoadedDidChange: (->
if @get('tab') == 'owned' && @get('isLoaded') && @get('length') == 0 && !@get('gettingStartedLoaded')
@set('gettingStartedLoaded', true)
@container.lookup('router:main').transitionTo('getting_started')
).observes('isLoaded', 'tab')
isLoadedBinding: 'content.isLoaded'
needs: ['currentUser', 'repo']
currentUserBinding: 'controllers.currentUser'

View File

@ -103,6 +103,7 @@ Travis.Router.map ->
@resource 'pullRequests', path: '/pull_requests'
@resource 'branches', path: '/branches'
@route 'getting_started'
@route 'stats', path: '/stats'
@route 'auth', path: '/auth'
@route 'notFound', path: '/not-found'
@ -140,6 +141,16 @@ Travis.SetupLastBuild = Ember.Mixin.create
build = @controllerFor('repo').get('repo.lastBuild')
@controllerFor('build').set('build', build)
Travis.GettingStartedRoute = Ember.Route.extend
setupController: ->
$('body').attr('id', 'getting-started')
@controllerFor('application').connectLayout('simple')
@_super.apply(this, arguments)
renderTemplate: ->
@render 'top', outlet: 'top'
@_super.apply(this, arguments)
Travis.IndexCurrentRoute = Ember.Route.extend Travis.DontSetupModelForControllerMixin, Travis.SetupLastBuild,
renderTemplate: ->
@render 'repo'

View File

@ -0,0 +1,3 @@
It looks like you don't have any repositories set up, you can do that on the {{#linkTo "profile.index"}}profile page{{/linkTo}}.
More instructions....

View File

@ -5,30 +5,34 @@
{{view Travis.ReposListTabsView}}
<div class="tab">
{{#collection Travis.ReposListView contentBinding="this"}}
{{#with view.repo}}
<div class="slug-and-status">
<span class="status"></span>
{{#if slug}}
{{#linkTo repo this class="slug"}}{{slug}}{{/linkTo}}
{{/if}}
</div>
{{#with lastBuildHash}}
{{#if repo.slug}}
{{#linkTo build repo id class="last_build"}}{{number}}{{/linkTo}}
{{/if}}
{{#if isLoaded}}
{{#collection Travis.ReposListView contentBinding="this"}}
{{#with view.repo}}
<div class="slug-and-status">
<span class="status"></span>
{{#if slug}}
{{#linkTo repo this class="slug"}}{{slug}}{{/linkTo}}
{{/if}}
</div>
{{#with lastBuildHash}}
{{#if repo.slug}}
{{#linkTo build repo id class="last_build"}}{{number}}{{/linkTo}}
{{/if}}
{{/with}}
<p class="summary">
<span class="duration_label">{{t repositories.duration}}:</span>
<abbr class="duration" {{bindAttr title="lastBuildStartedAt"}}>{{formatDuration lastBuildDuration}}</abbr>,
<span class="finished_at_label">{{t repositories.finished_at}}:</span>
<abbr class="finished_at timeago" {{bindAttr title="lastBuildFinishedAt"}}>{{formatTime lastBuildFinishedAt}}</abbr>
</p>
<div class="indicator"><span></span></div>
{{/with}}
<p class="summary">
<span class="duration_label">{{t repositories.duration}}:</span>
<abbr class="duration" {{bindAttr title="lastBuildStartedAt"}}>{{formatDuration lastBuildDuration}}</abbr>,
<span class="finished_at_label">{{t repositories.finished_at}}:</span>
<abbr class="finished_at timeago" {{bindAttr title="lastBuildFinishedAt"}}>{{formatTime lastBuildFinishedAt}}</abbr>
</p>
<div class="indicator"><span></span></div>
{{/with}}
{{else}}
<p class="empty">You don't have any repos set up on Travis CI</p>
{{/collection}}
{{else}}
<p class="empty"></p>
{{/collection}}
<div class="loading"><span>Loading</span></div>
{{/if}}
</div>

View File

@ -19,7 +19,7 @@
{{outlet pane}}
</div>
{{else}}
<span>Loading</span>
<div class="loading"><span>Loading</span></div>
{{/if}}
{{/if}}
</div>

View File

@ -0,0 +1,6 @@
#getting-started
a
font-weight: bold
&:hover
text-decoration: underline

View File

@ -77,10 +77,10 @@
&.selected .indicator
display: block
.loading
padding: 15px 25px 15px 30px
background-color: $color-bg-list-odd
background-image: none
#left .loading
padding: 15px 25px 15px 30px
background-color: $color-bg-list-odd
background-image: none
#accounts
li