mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 10:53:34 +03:00
c5f75f52c1
no issue - when overriding route hooks it's necessary to call `_super` so the extended class hooks will also run, in this case the unauthenticated->signin redirect in the `beforeModel` hook
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default AuthenticatedRoute.extend({
|
|
billing: service(),
|
|
|
|
queryParams: {
|
|
action: {refreshModel: true}
|
|
},
|
|
|
|
beforeModel(transition) {
|
|
this._super(...arguments);
|
|
this.billing.set('previousTransition', transition);
|
|
},
|
|
|
|
model(params) {
|
|
if (params.action) {
|
|
this.billing.set('action', params.action);
|
|
}
|
|
|
|
this.billing.setBillingWindowOpen(true);
|
|
},
|
|
|
|
actions: {
|
|
willTransition(transition) {
|
|
let isBillingTransition = false;
|
|
|
|
if (transition) {
|
|
let destinationUrl = (typeof transition.to === 'string')
|
|
? transition.to
|
|
: (transition.intent
|
|
? transition.intent.url
|
|
: '');
|
|
|
|
if (destinationUrl?.includes('/billing')) {
|
|
isBillingTransition = true;
|
|
}
|
|
}
|
|
|
|
this.billing.setBillingWindowOpen(isBillingTransition);
|
|
}
|
|
},
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Billing'
|
|
};
|
|
}
|
|
});
|