travis-web/assets/scripts/app/views.coffee
Piotr Sarnacki 018eafe84b 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.
2013-10-29 20:48:27 +01:00

61 lines
1.7 KiB
CoffeeScript

require 'ext/ember/namespace'
Em.View.reopen
init: ->
this.container ||= Travis.__container__
@_super.apply(this, arguments)
@Travis.reopen
View: Em.View.extend
popup: (name) ->
@popupCloseAll()
name = event?.target?.name || name
$("##{name}").toggleClass('display')
popupClose: ->
$(event.target).closest('.popup').removeClass('display')
popupCloseAll: ->
if view = Travis.View.currentPopupView
view.destroy()
Travis.View.currentPopupView = null
$('.popup').removeClass('display')
Travis.GettingStartedView = Travis.View.extend
templateName: 'no_owned_repos'
Travis.FirstSyncView = Travis.View.extend
didInsertElement: ->
this.addObserver('controller.isSyncing', this, this.isSyncingDidChange)
willDestroyElement: ->
this.removeObserver('controller.isSyncing', this, this.isSyncingDidChange)
isSyncingDidChange: ->
if !@get('controller.isSyncing')
self = this
Ember.run.later this, ->
Travis.Repo.fetch(member: @get('controller.user.login')).then( (repos) ->
if repos.get('length')
self.get('controller').transitionToRoute('index.current')
else
self.get('controller').transitionToRoute('profile')
).then(null, (e) ->
console.log('There was a problem while redirecting from first sync', e)
)
, Travis.config.syncingPageRedirectionTime
require 'views/accounts'
require 'views/application'
require 'views/build'
require 'views/events'
require 'views/flash'
require 'views/job'
require 'views/log'
require 'views/repo'
require 'views/profile'
require 'views/stats'
require 'views/signin'
require 'views/top'
require 'views/status_images'