2021-03-02 11:50:56 +03:00
|
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
2022-01-17 12:34:55 +03:00
|
|
|
import {action} from '@ember/object';
|
2020-04-22 06:35:56 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
2022-01-17 12:34:55 +03:00
|
|
|
export default class ProRoute extends AuthenticatedRoute {
|
|
|
|
@service billing;
|
|
|
|
@service session;
|
|
|
|
@service config;
|
2020-04-22 06:35:56 +03:00
|
|
|
|
2022-01-17 12:34:55 +03:00
|
|
|
queryParams = {
|
2020-04-22 06:35:56 +03:00
|
|
|
action: {refreshModel: true}
|
2022-01-17 12:34:55 +03:00
|
|
|
};
|
2020-04-22 06:35:56 +03:00
|
|
|
|
2020-05-22 05:44:37 +03:00
|
|
|
beforeModel(transition) {
|
2022-01-17 12:34:55 +03:00
|
|
|
super.beforeModel(...arguments);
|
2021-03-15 12:11:36 +03:00
|
|
|
|
2021-10-22 13:29:55 +03:00
|
|
|
// allow non-owner users to access the BMA when we're in a force upgrade state
|
|
|
|
if (!this.session.user.isOwnerOnly && !this.config.get('hostSettings.forceUpgrade')) {
|
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);
|
2022-01-17 12:34:55 +03:00
|
|
|
}
|
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);
|
2022-01-17 12:34:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
willTransition(transition) {
|
|
|
|
let isBillingTransition = false;
|
2020-05-22 05:44:37 +03:00
|
|
|
|
2022-01-17 12:34:55 +03:00
|
|
|
if (transition) {
|
|
|
|
let destinationUrl = (typeof transition.to === 'string')
|
|
|
|
? transition.to
|
|
|
|
: (transition.intent
|
|
|
|
? transition.intent.url
|
|
|
|
: '');
|
|
|
|
|
|
|
|
if (destinationUrl?.includes('/pro')) {
|
|
|
|
isBillingTransition = true;
|
|
|
|
}
|
2020-05-22 05:44:37 +03:00
|
|
|
}
|
2022-01-17 12:34:55 +03:00
|
|
|
|
|
|
|
this.billing.toggleProWindow(isBillingTransition);
|
|
|
|
}
|
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
|
|
|
}
|
2022-01-17 12:34:55 +03:00
|
|
|
}
|