Ghost/ghost/admin/app/mixins/404-handler.js
Austin Burdine 9d333533ac fix 404 error handling in editor, tags, and team routes
closes #6094
- adds 404-handler mixin
- applies mixin to settings/tags/tag, editor/edit and team/user routes
- adds adapter-error test helper to override the default adapter error
2015-12-03 16:37:23 -06:00

24 lines
756 B
JavaScript

import Ember from 'ember';
export default Ember.Mixin.create({
actions: {
error(error, transition) {
if (error.errors[0].errorType === 'NotFoundError') {
transition.abort();
let routeInfo = transition.handlerInfos[transition.handlerInfos.length - 1];
let router = this.get('router');
let params = [];
for (const key of Object.keys(routeInfo.params)) {
params.push(routeInfo.params[key]);
}
return this.transitionTo('error404', router.generate(routeInfo.name, ...params).replace('/ghost/', '').replace(/^\//g, ''));
}
return this._super(...arguments);
}
}
});