2021-03-02 11:50:56 +03:00
|
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
2020-04-22 06:35:56 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
2021-03-02 11:50:56 +03:00
|
|
|
export default AuthenticatedRoute.extend({
|
2020-04-22 06:35:56 +03:00
|
|
|
billing: service(),
|
|
|
|
|
|
|
|
queryParams: {
|
|
|
|
action: {refreshModel: true}
|
|
|
|
},
|
|
|
|
|
2020-05-22 05:44:37 +03:00
|
|
|
beforeModel(transition) {
|
|
|
|
this.billing.set('previousTransition', transition);
|
|
|
|
},
|
|
|
|
|
2020-04-22 06:35:56 +03:00
|
|
|
model(params) {
|
|
|
|
if (params.action) {
|
|
|
|
this.billing.set('action', params.action);
|
|
|
|
}
|
|
|
|
|
2020-05-22 05:44:37 +03:00
|
|
|
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
|
|
|
|
: '');
|
|
|
|
|
2021-02-12 13:13:23 +03:00
|
|
|
if (destinationUrl?.includes('/billing')) {
|
2020-05-22 05:44:37 +03:00
|
|
|
isBillingTransition = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.billing.setBillingWindowOpen(isBillingTransition);
|
|
|
|
}
|
|
|
|
},
|
2020-04-22 06:35:56 +03:00
|
|
|
|
2020-05-22 05:44:37 +03:00
|
|
|
buildRouteInfoMetadata() {
|
|
|
|
return {
|
|
|
|
titleToken: 'Billing'
|
|
|
|
};
|
2020-04-22 06:35:56 +03:00
|
|
|
}
|
|
|
|
});
|