Merge pull request #394 from travis-ci/owner-route-error-handling
Add error handling for the owner route
This commit is contained in:
commit
06c579c453
5
app/controllers/error.coffee
Normal file
5
app/controllers/error.coffee
Normal file
|
@ -0,0 +1,5 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
Controller = Ember.Controller.extend()
|
||||
|
||||
`export default Controller`
|
|
@ -2,6 +2,11 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
Route = Ember.Route.extend
|
||||
activate: ->
|
||||
if @routeName != 'error'
|
||||
@controllerFor('error').set('layoutName', null)
|
||||
return @_super.apply(this, arguments)
|
||||
|
||||
beforeModel: (transition) ->
|
||||
@auth.autoSignIn() unless @signedIn()
|
||||
|
||||
|
|
10
app/routes/error.js
Normal file
10
app/routes/error.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import TravisRoute from 'travis/routes/basic';
|
||||
|
||||
export default TravisRoute.extend({
|
||||
resetController(controller, isExiting, transition) {
|
||||
if (isExiting) {
|
||||
controller.set('message', null);
|
||||
controller.set('layoutName', null);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -4,7 +4,6 @@
|
|||
`import config from 'travis/config/environment'`
|
||||
|
||||
Route = TravisRoute.extend
|
||||
|
||||
deactivate: ->
|
||||
@controllerFor('loading').set('layoutName', null)
|
||||
|
||||
|
@ -19,4 +18,17 @@ Route = TravisRoute.extend
|
|||
|
||||
@_super.apply(this, arguments)
|
||||
|
||||
actions:
|
||||
error: (error, transition, originRoute) ->
|
||||
login = transition.params.owner.owner
|
||||
message = if error.status == 404
|
||||
"Couldn't find an owner with login \"#{login}\""
|
||||
else
|
||||
"There was an error while loading data, please try again."
|
||||
|
||||
@controllerFor('error').set('layoutName', 'simple')
|
||||
@controllerFor('error').set('message', message)
|
||||
|
||||
return true
|
||||
|
||||
`export default Route`
|
||||
|
|
5
app/templates/error.hbs
Normal file
5
app/templates/error.hbs
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{#if message}}
|
||||
{{message}}
|
||||
{{else}}
|
||||
There was an error, please try again.
|
||||
{{/if}}
|
1
app/templates/owner/error.hbs
Normal file
1
app/templates/owner/error.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
foo
|
9
app/views/error.coffee
Normal file
9
app/views/error.coffee
Normal file
|
@ -0,0 +1,9 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
View = Ember.View.extend
|
||||
layoutName: (->
|
||||
if name = @get('controller.layoutName')
|
||||
'layouts/' + name
|
||||
).property('controller.layoutName')
|
||||
|
||||
`export default View`
|
Loading…
Reference in New Issue
Block a user