mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
9d333533ac
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
24 lines
756 B
JavaScript
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);
|
|
}
|
|
}
|
|
});
|