Clean up controllers a bit

This commit is contained in:
Piotr Sarnacki 2015-01-15 16:26:21 +01:00
parent 6540304db5
commit 681622b58c
12 changed files with 49 additions and 89 deletions

View File

@ -1,45 +1,9 @@
require 'helpers'
Travis.Controller = Em.Controller.extend()
Travis.TopController = Em.Controller.extend
needs: ['currentUser']
userBinding: 'controllers.currentUser'
userName: (->
@get('user.name') || @get('user.login')
).property('user.login', 'user.name')
gravatarUrl: (->
"#{location.protocol}//www.gravatar.com/avatar/#{@get('user.gravatarId')}?s=48&d=mm"
).property('user.gravatarId')
signedIn: (->
Travis.get('authState') == 'signed-in'
).property('Travis.authState')
signedOut: (->
Travis.get('authState') == 'signed-out'
).property('Travis.authState')
signingIn: (->
Travis.get('authState') == 'signing-in'
).property('Travis.authState')
Travis.MainController = Em.Controller.extend()
Travis.StatsLayoutController = Em.Controller.extend()
Travis.ProfileLayoutController = Em.Controller.extend()
Travis.AuthLayoutController = Em.Controller.extend()
Travis.AccountsInfoController = Em.Controller.extend
needs: ['currentUser', 'repos']
userBinding: 'controllers.currentUser'
Travis.FirstSyncController = Em.Controller.extend
needs: ['currentUser']
user: Ember.computed.alias('controllers.currentUser')
isSyncing: Ember.computed.alias('user.isSyncing')
Travis.MainErrorController = Em.Controller.extend()
Travis.BuildsItemController = Em.ObjectController.extend(Travis.GithubUrlProperties,
needs: ['builds']
@ -57,35 +21,17 @@ Travis.RunningJobsController = Em.ArrayController.extend
Travis.Job.running()
).property()
Travis.SidebarController = Em.ArrayController.extend
init: ->
@_super.apply this, arguments
@tickables = []
tips: [
"Did you know that you can parallelize tests on Travis CI? <a href=\"http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM?utm_source=tips\">Learn more</a>"
"Did you know that you can split a build into several smaller pieces? <a href=\"http://docs.travis-ci.com/user/speeding-up-the-build/#Parallelizing-your-builds-across-virtual-machines?utm_source=tips\">Learn more</a>"
"Did you know that you can skip a build? <a href=\"http://docs.travis-ci.com/user/how-to-skip-a-build/?utm_source=tips\">Learn more</a>"
]
tip: (->
if tips = @get('tips')
tips[Math.floor(Math.random()*tips.length)]
).property().volatile()
require 'controllers/accounts'
require 'controllers/auth'
require 'controllers/account'
require 'controllers/build'
require 'controllers/builds'
require 'controllers/flash'
require 'controllers/home'
require 'controllers/job'
require 'controllers/profile'
require 'controllers/repos'
require 'controllers/repo'
require 'controllers/settings'
require 'controllers/stats'
require 'controllers/current_user'
require 'controllers/request'
require 'controllers/requests'
@ -94,3 +40,6 @@ require 'controllers/env_var'
require 'controllers/env_vars'
require 'controllers/env_var_new'
require 'controllers/ssh_key'
require 'controllers/sidebar'
require 'controllers/top'
require 'controllers/first_sync'

View File

@ -1 +1 @@
Travis.AuthController = Travis.Controller.extend()
Travis.AuthController = Ember.Controller.extend()

View File

@ -1,6 +1,9 @@
require 'travis/validations'
Travis.EnvVarsNewController = Travis.Controller.extend Travis.Validations,
Validations = Travis.Validations
EnvVar = Travis.EnvVar
Travis.EnvVarsNewController = Ember.Controller.extend Validations,
needs: ['repo']
repo: Ember.computed.alias('controllers.repo.repo')
@ -23,7 +26,7 @@ Travis.EnvVarsNewController = Travis.Controller.extend Travis.Validations,
@set('isSaving', true)
if @isValid()
env_var = Travis.EnvVar.create(
env_var = EnvVar.create(
name: @get('name')
value: @get('value')
public: @get('public')

View File

@ -0,0 +1,7 @@
Controller = Em.Controller.extend
needs: ['currentUser']
user: Ember.computed.alias('controllers.currentUser')
isSyncing: Ember.computed.alias('user.isSyncing')
Travis.FirstSyncController = Controller

View File

@ -1 +0,0 @@
Travis.HomeLayoutController = Travis.Controller.extend()

View File

@ -1,4 +1,4 @@
Travis.ProfileController = Travis.Controller.extend
Travis.ProfileController = Ember.Controller.extend
name: 'profile'
needs: ['currentUser', 'accounts', 'account']
@ -16,14 +16,9 @@ Travis.ProfileController = Travis.Controller.extend
@connectTab('user')
connectTab: (tab) ->
if tab == 'user'
view = 'AccountsInfoView'
else
view = "#{$.camelize(tab)}View"
viewClass = Travis[view]
@set('tab', tab)
billingUrl: (->
id = if @get('account.type') == 'user' then 'user' else @get('account.login')
"#{Travis.config.billing_endpoint}/subscriptions/#{id}"
"#{@get('config').billing_endpoint}/subscriptions/#{id}"
).property('account.login', 'account.type')

View File

@ -1,4 +1,4 @@
Travis.RepoController = Travis.Controller.extend
Travis.RepoController = Ember.Controller.extend
needs: ['repos', 'currentUser', 'build', 'request', 'job']
currentUserBinding: 'controllers.currentUser'

View File

@ -0,0 +1,17 @@
Controller = Em.ArrayController.extend
init: ->
@_super.apply this, arguments
@tickables = []
tips: [
"Did you know that you can parallelize tests on Travis CI? <a href=\"http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM?utm_source=tips\">Learn more</a>"
"Did you know that you can split a build into several smaller pieces? <a href=\"http://docs.travis-ci.com/user/speeding-up-the-build/#Parallelizing-your-builds-across-virtual-machines?utm_source=tips\">Learn more</a>"
"Did you know that you can skip a build? <a href=\"http://docs.travis-ci.com/user/how-to-skip-a-build/?utm_source=tips\">Learn more</a>"
]
tip: (->
if tips = @get('tips')
tips[Math.floor(Math.random()*tips.length)]
).property().volatile()
Travis.SidebarController = Controller

View File

@ -1,9 +0,0 @@
Travis.StatsController = Travis.Controller.extend
name: 'stats'
init: ->
@_super.apply this, arguments
#@connectOutlet(outletName: 'main', controller: this, viewClass: Travis.StatsView)
activate: (action, params) ->
# noop

View File

@ -0,0 +1,13 @@
Controller = Em.Controller.extend
needs: ['currentUser']
userBinding: 'controllers.currentUser'
userName: (->
@get('user.name') || @get('user.login')
).property('user.login', 'user.name')
gravatarUrl: (->
"#{location.protocol}//www.gravatar.com/avatar/#{@get('user.gravatarId')}?s=48&d=mm"
).property('user.gravatarId')
Travis.TopController = Controller

View File

@ -35,7 +35,6 @@ Travis.Router.map ->
@route 'first_sync'
@route 'insufficient_oauth_permissions'
@route 'stats', path: '/stats'
@route 'auth', path: '/auth'
@resource 'profile', path: '/profile', ->
@ -80,5 +79,4 @@ require 'routes/settings/index'
require 'routes/settings'
require 'routes/simple_layout'
require 'routes/ssh_key'
require 'routes/stats'
require 'routes/dashboard'

View File

@ -1,12 +0,0 @@
require 'routes/route'
TravisRoute = Travis.Route
Route = TravisRoute.extend
renderTemplate: ->
$('body').attr('id', 'stats')
@render 'stats'
Travis.StatsRoute = Route