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-23 14:59:52 +03:00
|
|
|
// TODO: rename billing route and service to /pro
|
2021-03-02 11:50:56 +03:00
|
|
|
export default AuthenticatedRoute.extend({
|
2020-04-22 06:35:56 +03:00
|
|
|
billing: service(),
|
2021-03-15 12:11:36 +03:00
|
|
|
session: service(),
|
2020-04-22 06:35:56 +03:00
|
|
|
|
|
|
|
queryParams: {
|
|
|
|
action: {refreshModel: true}
|
|
|
|
},
|
|
|
|
|
2020-05-22 05:44:37 +03:00
|
|
|
beforeModel(transition) {
|
2021-03-03 11:32:19 +03:00
|
|
|
this._super(...arguments);
|
2021-03-15 12:11:36 +03:00
|
|
|
|
2021-07-12 15:55:56 +03:00
|
|
|
if (!this.session.user.isOwnerOnly) {
|
2021-07-08 16:37:31 +03:00
|
|
|
return this.transitionTo('home');
|
|
|
|
}
|
2021-03-15 12:11:36 +03:00
|
|
|
|
2021-07-08 16:37:31 +03:00
|
|
|
this.billing.set('previousTransition', transition);
|
2020-05-22 05:44:37 +03:00
|
|
|
},
|
|
|
|
|
2020-04-22 06:35:56 +03:00
|
|
|
model(params) {
|
|
|
|
if (params.action) {
|
|
|
|
this.billing.set('action', params.action);
|
|
|
|
}
|
|
|
|
|
2021-09-10 17:22:52 +03:00
|
|
|
this.billing.toggleProWindow(true);
|
2020-05-22 05:44:37 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
willTransition(transition) {
|
|
|
|
let isBillingTransition = false;
|
|
|
|
|
|
|
|
if (transition) {
|
|
|
|
let destinationUrl = (typeof transition.to === 'string')
|
|
|
|
? transition.to
|
|
|
|
: (transition.intent
|
|
|
|
? transition.intent.url
|
|
|
|
: '');
|
|
|
|
|
2021-03-23 14:59:52 +03:00
|
|
|
if (destinationUrl?.includes('/pro')) {
|
2020-05-22 05:44:37 +03:00
|
|
|
isBillingTransition = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-10 17:22:52 +03:00
|
|
|
this.billing.toggleProWindow(isBillingTransition);
|
2020-05-22 05:44:37 +03:00
|
|
|
}
|
|
|
|
},
|
2020-04-22 06:35:56 +03:00
|
|
|
|
2020-05-22 05:44:37 +03:00
|
|
|
buildRouteInfoMetadata() {
|
|
|
|
return {
|
2021-03-23 14:59:52 +03:00
|
|
|
titleToken: 'Ghost(Pro)'
|
2020-05-22 05:44:37 +03:00
|
|
|
};
|
2020-04-22 06:35:56 +03:00
|
|
|
}
|
|
|
|
});
|