From 704bd9434e94a13c9b25872896e35606a1698861 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 11 Jun 2013 17:22:52 +0200 Subject: [PATCH] Redirect to getting started page if user has no repositories --- assets/scripts/app/controllers/repos.coffee | 7 +++ assets/scripts/app/routes.coffee | 11 ++++ .../scripts/app/templates/getting_started.hbs | 3 ++ assets/scripts/app/templates/repos/list.hbs | 52 ++++++++++--------- assets/scripts/app/templates/repos/show.hbs | 2 +- assets/styles/getting_started.sass | 6 +++ assets/styles/left/list.sass | 8 +-- 7 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 assets/scripts/app/templates/getting_started.hbs create mode 100644 assets/styles/getting_started.sass diff --git a/assets/scripts/app/controllers/repos.coffee b/assets/scripts/app/controllers/repos.coffee index ad750336..eb28ac62 100644 --- a/assets/scripts/app/controllers/repos.coffee +++ b/assets/scripts/app/controllers/repos.coffee @@ -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' diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index 01126b47..421d0a62 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -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' diff --git a/assets/scripts/app/templates/getting_started.hbs b/assets/scripts/app/templates/getting_started.hbs new file mode 100644 index 00000000..f8e8fbc0 --- /dev/null +++ b/assets/scripts/app/templates/getting_started.hbs @@ -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.... diff --git a/assets/scripts/app/templates/repos/list.hbs b/assets/scripts/app/templates/repos/list.hbs index 525efae7..f8cfaf70 100644 --- a/assets/scripts/app/templates/repos/list.hbs +++ b/assets/scripts/app/templates/repos/list.hbs @@ -5,30 +5,34 @@ {{view Travis.ReposListTabsView}}
- {{#collection Travis.ReposListView contentBinding="this"}} - {{#with view.repo}} -
- - {{#if slug}} - {{#linkTo repo this class="slug"}}{{slug}}{{/linkTo}} - {{/if}} -
- {{#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}} +
+ + {{#if slug}} + {{#linkTo repo this class="slug"}}{{slug}}{{/linkTo}} + {{/if}} +
+ {{#with lastBuildHash}} + {{#if repo.slug}} + {{#linkTo build repo id class="last_build"}}{{number}}{{/linkTo}} + {{/if}} + {{/with}} + +

+ {{t repositories.duration}}: + {{formatDuration lastBuildDuration}}, + {{t repositories.finished_at}}: + {{formatTime lastBuildFinishedAt}} +

+ +
{{/with}} - -

- {{t repositories.duration}}: - {{formatDuration lastBuildDuration}}, - {{t repositories.finished_at}}: - {{formatTime lastBuildFinishedAt}} -

- -
- {{/with}} + {{else}} +

You don't have any repos set up on Travis CI

+ {{/collection}} {{else}} -

- {{/collection}} +
Loading
+ {{/if}}
diff --git a/assets/scripts/app/templates/repos/show.hbs b/assets/scripts/app/templates/repos/show.hbs index 152d29f7..4e030667 100644 --- a/assets/scripts/app/templates/repos/show.hbs +++ b/assets/scripts/app/templates/repos/show.hbs @@ -19,7 +19,7 @@ {{outlet pane}} {{else}} - Loading +
Loading
{{/if}} {{/if}} diff --git a/assets/styles/getting_started.sass b/assets/styles/getting_started.sass new file mode 100644 index 00000000..964cbaf2 --- /dev/null +++ b/assets/styles/getting_started.sass @@ -0,0 +1,6 @@ +#getting-started + a + font-weight: bold + + &:hover + text-decoration: underline diff --git a/assets/styles/left/list.sass b/assets/styles/left/list.sass index 24352d73..5ec5de83 100644 --- a/assets/styles/left/list.sass +++ b/assets/styles/left/list.sass @@ -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