Ghost/ghost/admin/app/routes/pro.js
Kevin Ansfield 75abe76346 Migrated route objects to native class syntax
no issue

- ran the `ember-native-class-codemod` codemod to convert just the route classes to native class syntax and performed some minor manual cleanup
  - modern Ember uses native classes rather than EmberObject-based objects, this brings us closer to normalizing our code style across the codebase
- skipped the Application route as that requires deeper testing with a replacement for the `ShortcutsRoute` mixin
2022-01-17 10:06:57 +00:00

58 lines
1.5 KiB
JavaScript

import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
export default class ProRoute extends AuthenticatedRoute {
@service billing;
@service session;
@service config;
queryParams = {
action: {refreshModel: true}
};
beforeModel(transition) {
super.beforeModel(...arguments);
// 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')) {
return this.transitionTo('home');
}
this.billing.set('previousTransition', transition);
}
model(params) {
if (params.action) {
this.billing.set('action', params.action);
}
this.billing.toggleProWindow(true);
}
@action
willTransition(transition) {
let isBillingTransition = false;
if (transition) {
let destinationUrl = (typeof transition.to === 'string')
? transition.to
: (transition.intent
? transition.intent.url
: '');
if (destinationUrl?.includes('/pro')) {
isBillingTransition = true;
}
}
this.billing.toggleProWindow(isBillingTransition);
}
buildRouteInfoMetadata() {
return {
titleToken: 'Ghost(Pro)'
};
}
}