From 7363a1d7efd0537bc92b96c193704a8a5348ca93 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 13 Jun 2013 16:08:06 +0200 Subject: [PATCH 1/6] Render builds/not_found and repo/not_found in the next runloop run This is done to make sure that if something else render just after not_found, not_found will still be rendered. --- assets/scripts/app/routes.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index b1dac327..3215cbcf 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -124,7 +124,8 @@ Travis.SetupLastBuild = Ember.Mixin.create # TODO: it would be nicer to do it with promises repo = @controllerFor('repo').get('repo') if repo && repo.get('isLoaded') && !repo.get('lastBuild') - @render('builds/not_found', outlet: 'pane', into: 'repo') + Ember.run.next => + @render('builds/not_found', outlet: 'pane', into: 'repo') Travis.GettingStartedRoute = Ember.Route.extend setupController: -> @@ -281,7 +282,8 @@ Travis.RepoRoute = Ember.Route.extend proxy.set 'isLoading', false if repos.get('length') == 0 - self.render('repos/not_found', outlet: 'main') + Ember.run.next -> + self.render('repos/not_found', outlet: 'main') else proxy.set 'content', repos.objectAt(0) From 0bf5a413da98a313646687fc5ee346a0d9e7744b Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 29 Oct 2013 17:12:03 +0100 Subject: [PATCH 2/6] Update lib8 and rubyracer --- Gemfile | 4 ++-- Gemfile.lock | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 33be7c01..fbcdcd77 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'http://rubygems.org' -ruby '1.9.3' +ruby '2.0.0' gem 'puma' gem 'rack-ssl', '~> 1.3' @@ -17,12 +17,12 @@ group :assets do gem 'tilt' gem 'uglifier' gem 'yui-compressor' + gem 'libv8', '~> 3.16.0' end group :development, :test do gem 'rake' gem 'localeapp' - gem 'handlebars' gem 'localeapp-handlebars_i18n' end diff --git a/Gemfile.lock b/Gemfile.lock index 5a69095f..80adb3af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,6 @@ GEM coffee-script-source execjs coffee-script-source (1.5.0) - commonjs (0.2.6) compass (0.12.2) chunky_png (~> 1.2) fssm (>= 0.2.7) @@ -48,12 +47,9 @@ GEM pry (>= 0.9.10) terminal-table (>= 1.4.3) thor (>= 0.14.6) - handlebars (0.4.0) - commonjs (~> 0.2.3) - therubyracer (~> 0.11.1) i18n (0.6.3) json (1.7.7) - libv8 (3.11.8.13) + libv8 (3.16.14.3) listen (0.7.3) localeapp (0.6.9) gli @@ -89,7 +85,6 @@ GEM rake-pipeline-i18n-filters (0.0.5) rake-pipeline (~> 0.6) rb-fsevent (0.9.3) - ref (1.0.2) rerun (0.8.0) listen rest-client (1.6.7) @@ -116,9 +111,6 @@ GEM tilt (~> 1.3) slop (3.4.3) terminal-table (1.4.5) - therubyracer (0.11.4) - libv8 (~> 3.11.8.12) - ref thor (0.17.0) tilt (1.3.3) uglifier (1.3.0) @@ -136,7 +128,7 @@ DEPENDENCIES compass foreman guard - handlebars + libv8 (~> 3.16.0) localeapp localeapp-handlebars_i18n puma From fbed80f1666730d7c99df3f01c819af019acc342 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 13 Jun 2013 16:21:08 +0200 Subject: [PATCH 3/6] Display repos with no builds, but which are active in 'My repositories' When user activates a repository in the profile page, we now will display this repository on the 'My Repositories' list. When user chooses this repository, she will see an explenation why there is no builds and what could be done to fix this. Conflicts: assets/scripts/app/controllers.coffee assets/scripts/app/models/repo.coffee assets/scripts/app/templates/repos/list.hbs --- assets/scripts/app/controllers.coffee | 8 ++++++++ assets/scripts/app/models/repo.coffee | 3 ++- assets/scripts/app/routes.coffee | 2 +- assets/scripts/app/templates/builds/not_found.hbs | 6 +++++- assets/scripts/app/templates/repos/list.hbs | 13 ++++++++----- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/assets/scripts/app/controllers.coffee b/assets/scripts/app/controllers.coffee index f1b4f520..960e2024 100644 --- a/assets/scripts/app/controllers.coffee +++ b/assets/scripts/app/controllers.coffee @@ -48,6 +48,14 @@ Travis.FirstSyncController = Em.Controller.extend isSyncing: Ember.computed.alias('user.isSyncing') +Travis.BuildNotFoundController = Em.Controller.extend + needs: ['repo', 'currentUser'] + ownedAndActive: (-> + if permissions = @get('controllers.currentUser.permissions') + if repo = @get('controllers.repo.repo') + repo.get('active') && permissions.contains(parseInt(repo.get('id'))) + ).property('controllers.repo.repo', 'controllers.currentUser.permissions') + require 'controllers/accounts' require 'controllers/build' require 'controllers/builds' diff --git a/assets/scripts/app/models/repo.coffee b/assets/scripts/app/models/repo.coffee index 790b3f67..54fbdb42 100644 --- a/assets/scripts/app/models/repo.coffee +++ b/assets/scripts/app/models/repo.coffee @@ -12,6 +12,7 @@ require 'travis/model' lastBuildFinishedAt: Ember.attr('string') githubLanguage: Ember.attr('string') _lastBuildDuration: Ember.attr(Number, key: 'last_build_duration') + active: Ember.attr('boolean') lastBuild: Ember.belongsTo('Travis.Build', key: 'last_build_id') @@ -113,7 +114,7 @@ require 'travis/model' @find(owner_name: login, orderBy: 'name') accessibleBy: (login) -> - @find(member: login, orderBy: 'name') + @find(member: login, active: true) search: (query) -> @find(search: query, orderBy: 'name') diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index 3215cbcf..1c296e1f 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -125,7 +125,7 @@ Travis.SetupLastBuild = Ember.Mixin.create repo = @controllerFor('repo').get('repo') if repo && repo.get('isLoaded') && !repo.get('lastBuild') Ember.run.next => - @render('builds/not_found', outlet: 'pane', into: 'repo') + @render('builds/not_found', outlet: 'pane', into: 'repo', controller: 'buildNotFound') Travis.GettingStartedRoute = Ember.Route.extend setupController: -> diff --git a/assets/scripts/app/templates/builds/not_found.hbs b/assets/scripts/app/templates/builds/not_found.hbs index 7fbeea2e..1226b546 100644 --- a/assets/scripts/app/templates/builds/not_found.hbs +++ b/assets/scripts/app/templates/builds/not_found.hbs @@ -1 +1,5 @@ -There are no builds for this repository. +{{#if ownedAndActive}} + This repository is active, but there are no builds yet. Builds will appear here after you push new commits to the repository. +{{else}} + There are no builds for this repository. +{{/if}} diff --git a/assets/scripts/app/templates/repos/list.hbs b/assets/scripts/app/templates/repos/list.hbs index 378891fc..60ffe6a4 100644 --- a/assets/scripts/app/templates/repos/list.hbs +++ b/assets/scripts/app/templates/repos/list.hbs @@ -14,11 +14,14 @@ {{#linkTo "repo" this class="slug"}}{{slug}}{{/linkTo}} {{/if}} - {{#with lastBuildHash}} - {{#if repo.slug}} - {{#linkTo "build" repo id class="last_build"}}{{number}}{{/linkTo}} - {{/if}} - {{/with}} + + {{#if lastBuild}} + {{#with lastBuildHash}} + {{#if repo.slug}} + {{#linkTo "build" repo id class="last_build"}}{{number}}{{/linkTo}} + {{/if}} + {{/with}} + {{/if}}

{{t repositories.duration}}: From a8fe524c008a4dd6fcb5d5f2017161c6d9993dce Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 29 Oct 2013 18:50:56 +0100 Subject: [PATCH 4/6] Accidentaly commited change to ruby 2.0.0 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index fbcdcd77..2aa50f3a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'http://rubygems.org' -ruby '2.0.0' +ruby '1.9.3' gem 'puma' gem 'rack-ssl', '~> 1.3' From 018eafe84bc7990a7b8d1d0b341c28c147a6cba0 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 29 Oct 2013 20:48:27 +0100 Subject: [PATCH 5/6] Fix problem with getting started template rendering on first sync When first sync template is displayed, user usually doesn't have any repos, which also triggers rendering of getting started template. The fix for this is to handle the action to render getting started page on first sync and do nothing in such case. I also added a test to ensure that it works correctly. --- assets/scripts/app/controllers/repos.coffee | 10 +++---- assets/scripts/app/routes.coffee | 5 ++++ assets/scripts/app/views.coffee | 2 +- .../spec/integration/my_repos_spec.coffee | 1 - assets/scripts/spec/integration/sync.coffee | 26 +++++++++++++++++++ assets/scripts/spec/spec_helper.coffee | 16 +++++++----- assets/scripts/travis.coffee | 1 + 7 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 assets/scripts/spec/integration/sync.coffee diff --git a/assets/scripts/app/controllers/repos.coffee b/assets/scripts/app/controllers/repos.coffee index bfa09ace..f61de1a4 100644 --- a/assets/scripts/app/controllers/repos.coffee +++ b/assets/scripts/app/controllers/repos.coffee @@ -6,7 +6,7 @@ Travis.ReposController = Ember.ArrayController.extend 'owned' else 'recent' - ).property('currentUser') + ).property('currentUser.id') currentUserIdDidChange: (-> if @get('currentUser.id') @@ -16,10 +16,10 @@ Travis.ReposController = Ember.ArrayController.extend ).observes('currentUser.id') tabOrIsLoadedDidChange: (-> - if @get('tab') == 'owned' && @get('isLoaded') && @get('length') == 0 - - @container.lookup('router:main').send('renderNoOwnedRepos') - ).observes('isLoaded', 'tab') + Ember.run.scheduleOnce 'routerTransitions', this, -> + if @get('tab') == 'owned' && @get('isLoaded') && @get('length') == 0 + @container.lookup('router:main').send('renderNoOwnedRepos') + ).observes('isLoaded', 'tab', 'length') isLoadedBinding: 'content.isLoaded' needs: ['currentUser', 'repo'] diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index 1c296e1f..cb68dee1 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -140,6 +140,11 @@ Travis.GettingStartedRoute = Ember.Route.extend @_super.apply(this, arguments) Travis.FirstSyncRoute = Ember.Route.extend + events: + renderNoOwnedRepos: (->) + # do nothing, we are showing first sync, so it's normal that there is + # no owned repos + setupController: -> $('body').attr('id', 'home') @container.lookup('controller:repos').activate() diff --git a/assets/scripts/app/views.coffee b/assets/scripts/app/views.coffee index ae5928c1..7ddf2bc8 100644 --- a/assets/scripts/app/views.coffee +++ b/assets/scripts/app/views.coffee @@ -43,7 +43,7 @@ Travis.FirstSyncView = Travis.View.extend ).then(null, (e) -> console.log('There was a problem while redirecting from first sync', e) ) - , 5000 + , Travis.config.syncingPageRedirectionTime require 'views/accounts' require 'views/application' diff --git a/assets/scripts/spec/integration/my_repos_spec.coffee b/assets/scripts/spec/integration/my_repos_spec.coffee index 1c086406..6011772b 100644 --- a/assets/scripts/spec/integration/my_repos_spec.coffee +++ b/assets/scripts/spec/integration/my_repos_spec.coffee @@ -5,7 +5,6 @@ module "My repos", Ember.run -> Travis.reset() test "my repos is active by default when user is signed in", -> - Ember.run -> signInUser() visit('/').then -> wait().then -> diff --git a/assets/scripts/spec/integration/sync.coffee b/assets/scripts/spec/integration/sync.coffee new file mode 100644 index 00000000..768edc4e --- /dev/null +++ b/assets/scripts/spec/integration/sync.coffee @@ -0,0 +1,26 @@ +module "Sync", + setup: -> + Ember.run -> Travis.advanceReadiness() + teardown: -> + Ember.run -> Travis.reset() + +test "first sync page is show when user just signed up and is syncing", -> + Ember.run -> + signInUser( + is_syncing: true + synced_at: null + login: 'new-user' + ) + + Travis.config.syncingPageRedirectionTime = 100 + + wait().then -> + ok $('#first_sync').text().match(/Just a few more seconds as we talk to GitHub to find out which repositories belong to you./) + + stop() + Travis.__container__.lookup('controller:currentUser').get('content').set('isSyncing', false) + setTimeout -> + start() + visit('/').then -> + ok $('#getting-started').text().match(/Welcome to Travis CI!/) + , 120 diff --git a/assets/scripts/spec/spec_helper.coffee b/assets/scripts/spec/spec_helper.coffee index e869902c..b98554ea 100644 --- a/assets/scripts/spec/spec_helper.coffee +++ b/assets/scripts/spec/spec_helper.coffee @@ -16,15 +16,19 @@ Ember.Container.prototype.stub = (fullName, instance) -> instance.destroy = instance.destroy || (->) this.cache.dict[fullName] = instance -window.signInUser = -> +window.signInUser = (data) -> + data ||= {} + userData = { + id: 1 + email: 'tyrion@example.org' + login: 'tyrion' + token: 'abcdef' + } + userData = Ember.merge(userData, data) # for now let's just use harcoded data to log in the user, # we may extend it in the future to pass specific user data Travis.auth.signIn - user: - id: 1 - email: 'tyrion@example.org' - login: 'tyrion' - token: 'abcdef' + user: userData token: 'abcdef' #@app = (url, options = {}) -> diff --git a/assets/scripts/travis.coffee b/assets/scripts/travis.coffee index a5753048..71bce608 100644 --- a/assets/scripts/travis.coffee +++ b/assets/scripts/travis.coffee @@ -71,6 +71,7 @@ $.extend Travis, Travis.advanceReadiness() # bc, remove once merged to master config: + syncingPageRedirectionTime: 5000 api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href') pusher_key: $('meta[name="travis.pusher_key"]').attr('value') ga_code: $('meta[name="travis.ga_code"]').attr('value') From 190bf9e837bd6ba7d7ab9585531b1304e966b389 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 30 Oct 2013 14:36:29 +0100 Subject: [PATCH 6/6] Use lastBuildHash on repo, not lastBuild lastBuildHash uses information for last build, which is available on the repo object, so it will not trigger an ajax request if we haven't fetched a build yet. --- assets/scripts/app/templates/repos/list.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/app/templates/repos/list.hbs b/assets/scripts/app/templates/repos/list.hbs index 60ffe6a4..626ffb3c 100644 --- a/assets/scripts/app/templates/repos/list.hbs +++ b/assets/scripts/app/templates/repos/list.hbs @@ -15,7 +15,7 @@ {{/if}} - {{#if lastBuild}} + {{#if lastBuildHash.number}} {{#with lastBuildHash}} {{#if repo.slug}} {{#linkTo "build" repo id class="last_build"}}{{number}}{{/linkTo}}