Move settings out of the profile page
This commit is contained in:
parent
ac6b394ec4
commit
8482c4c286
|
@ -48,18 +48,16 @@ Travis.FirstSyncController = Em.Controller.extend
|
||||||
|
|
||||||
isSyncing: Ember.computed.alias('user.isSyncing')
|
isSyncing: Ember.computed.alias('user.isSyncing')
|
||||||
|
|
||||||
Travis.ProfileRepoController = Em.ObjectController.extend()
|
Travis.RepoSettingsTabController = Em.ObjectController.extend()
|
||||||
Travis.ProfileRepoSettingsTabController = Em.ObjectController.extend()
|
Travis.RepoSettingsController = Em.ObjectController.extend
|
||||||
|
needs: ['repoSettingsTab']
|
||||||
Travis.ProfileRepoSettingsController = Em.Controller.extend
|
tab: Ember.computed.alias('controllers.repoSettingsTab.model.tab')
|
||||||
needs: ['profileRepoSettingsTab', 'profileRepo']
|
settings: Ember.computed.alias('model.settings')
|
||||||
tab: Ember.computed.alias('controllers.profileRepoSettingsTab.model.tab')
|
|
||||||
repo: Ember.computed.alias('controllers.profileRepo.content')
|
|
||||||
|
|
||||||
submit: ->
|
submit: ->
|
||||||
@set('saving', true)
|
@set('saving', true)
|
||||||
self = this
|
self = this
|
||||||
@get('repo').saveSettings(@get('settings')).then ->
|
@get('model').saveSettings(@get('settings')).then ->
|
||||||
self.set('saving', false)
|
self.set('saving', false)
|
||||||
Travis.flash(success: 'Settings were saved successfully')
|
Travis.flash(success: 'Settings were saved successfully')
|
||||||
, ->
|
, ->
|
||||||
|
|
|
@ -34,11 +34,12 @@ Travis.TabsView = Ember.View.extend
|
||||||
|
|
||||||
tab.show() unless tab.get('visible')
|
tab.show() unless tab.get('visible')
|
||||||
|
|
||||||
|
# TODO: remove hardcoded link
|
||||||
layout: Ember.Handlebars.compile(
|
layout: Ember.Handlebars.compile(
|
||||||
'<ul class="tabs">' +
|
'<ul class="tabs">' +
|
||||||
' {{#each tab in tabs}}' +
|
' {{#each tab in tabs}}' +
|
||||||
' <li {{bindAttr class="tab.visible:active"}}>' +
|
' <li {{bindAttr class="tab.visible:active"}}>' +
|
||||||
' <h5>{{#linkTo "profile.repo.settings.tab" tab.id}}{{tab.name}}{{/linkTo}}</h5>' +
|
' <h5>{{#linkTo "repo.settings.tab" tab.id}}{{tab.name}}{{/linkTo}}</h5>' +
|
||||||
' </li>' +
|
' </li>' +
|
||||||
' {{/each}}' +
|
' {{/each}}' +
|
||||||
'</ul>' +
|
'</ul>' +
|
||||||
|
|
|
@ -99,16 +99,17 @@ Travis.Router.map ->
|
||||||
@resource 'pullRequests', path: '/pull_requests'
|
@resource 'pullRequests', path: '/pull_requests'
|
||||||
@resource 'branches', path: '/branches'
|
@resource 'branches', path: '/branches'
|
||||||
|
|
||||||
|
# this can't be nested in repo, because we want a set of different
|
||||||
|
# templates rendered for settings (for example no "current", "builds", ... tabs)
|
||||||
|
@resource 'repo.settings', path: '/:owner/:name/settings', ->
|
||||||
|
@route 'tab', path: ':tab'
|
||||||
|
|
||||||
@route 'getting_started'
|
@route 'getting_started'
|
||||||
@route 'first_sync'
|
@route 'first_sync'
|
||||||
@route 'stats', path: '/stats'
|
@route 'stats', path: '/stats'
|
||||||
@route 'auth', path: '/auth'
|
@route 'auth', path: '/auth'
|
||||||
@route 'notFound', path: '/not-found'
|
@route 'notFound', path: '/not-found'
|
||||||
|
|
||||||
@resource 'profile.repo', path: '/profile/:owner/:name', ->
|
|
||||||
@resource 'profile.repo.settings', path: 'settings', ->
|
|
||||||
@route 'tab', path: ':tab'
|
|
||||||
|
|
||||||
@resource 'profile', path: '/profile', ->
|
@resource 'profile', path: '/profile', ->
|
||||||
@route 'index', path: '/'
|
@route 'index', path: '/'
|
||||||
@resource 'account', path: '/:login', ->
|
@resource 'account', path: '/:login', ->
|
||||||
|
@ -398,15 +399,13 @@ Travis.AuthRoute = Ember.Route.extend
|
||||||
deactivate: ->
|
deactivate: ->
|
||||||
@controllerFor('auth').set('redirected', false)
|
@controllerFor('auth').set('redirected', false)
|
||||||
|
|
||||||
Travis.ProfileRepoRoute = Travis.ProfileRoute.extend
|
Travis.RepoSettingsRoute = Ember.Route.extend
|
||||||
setupController: (controller, model) ->
|
setupController: (controller, model) ->
|
||||||
# TODO: if repo is just a data hash with id and slug load it
|
# TODO: if repo is just a data hash with id and slug load it
|
||||||
# as incomplete record
|
# as incomplete record
|
||||||
model = Travis.Repo.find(model.id) if model && !model.get
|
model = Travis.Repo.find(model.id) if model && !model.get
|
||||||
@_super(controller, model)
|
@_super(controller, model)
|
||||||
|
|
||||||
controller.set('content', model)
|
|
||||||
|
|
||||||
serialize: (repo) ->
|
serialize: (repo) ->
|
||||||
slug = if repo.get then repo.get('slug') else repo.slug
|
slug = if repo.get then repo.get('slug') else repo.slug
|
||||||
[owner, name] = slug.split('/')
|
[owner, name] = slug.split('/')
|
||||||
|
@ -416,10 +415,8 @@ Travis.ProfileRepoRoute = Travis.ProfileRoute.extend
|
||||||
slug = "#{params.owner}/#{params.name}"
|
slug = "#{params.owner}/#{params.name}"
|
||||||
Travis.Repo.fetchBySlug(slug)
|
Travis.Repo.fetchBySlug(slug)
|
||||||
|
|
||||||
Travis.ProfileRepoSettingsRoute = Ember.Route.extend
|
afterModel: (repo) ->
|
||||||
setupController: (controller, model) ->
|
# I'm using afterModel to fetch settings, because model is not always called.
|
||||||
controller.set('settings', model)
|
# If link-to already provides a model, it will be just set as a route context.
|
||||||
|
repo.fetchSettings().then (settings) ->
|
||||||
model: ->
|
repo.set('settings', settings)
|
||||||
repo = @modelFor('profileRepo')
|
|
||||||
repo.fetchSettings()
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<h1>Settings: {{slug}}</h1>
|
||||||
|
|
||||||
{{#travis-tabs}}
|
{{#travis-tabs}}
|
||||||
{{#travis-tab "general" "General Settings"}}
|
{{#travis-tab "general" "General Settings"}}
|
||||||
{{#settings-form}}
|
{{#settings-form}}
|
|
@ -24,4 +24,3 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if view.displaySettingsLink}}
|
{{#if view.displaySettingsLink}}
|
||||||
<li>
|
<li>
|
||||||
{{#linkTo "profile.repo.settings" view.repo}}Settings{{/linkTo}}
|
{{#linkTo "repo.settings" view.repo}}Settings{{/linkTo}}
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user