Ghost/ghost/admin/app/routes/pro.js
Aileen Nowak 101b0061b5 Avoided reloading billing iframe
no issue

- Clicking on the Ghost(Pro) item in the navigation would always reload the billing management app and enforcing to fetch all data again, even tho it has been fetched and cached before
- This commit removed loc that replaces the iframe content every time we click on the button
- Renamed `setBillingWindowOpen` to `toggleProWindow` as it's more accurate in its description
- Removed `closeBillingWindow` as it's unused throughout the app
2021-09-10 15:26:42 +01:00

57 lines
1.4 KiB
JavaScript

import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import {inject as service} from '@ember/service';
// TODO: rename billing route and service to /pro
export default AuthenticatedRoute.extend({
billing: service(),
session: service(),
queryParams: {
action: {refreshModel: true}
},
beforeModel(transition) {
this._super(...arguments);
if (!this.session.user.isOwnerOnly) {
return this.transitionTo('home');
}
this.billing.set('previousTransition', transition);
},
model(params) {
if (params.action) {
this.billing.set('action', params.action);
}
this.billing.toggleProWindow(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('/pro')) {
isBillingTransition = true;
}
}
this.billing.toggleProWindow(isBillingTransition);
}
},
buildRouteInfoMetadata() {
return {
titleToken: 'Ghost(Pro)'
};
}
});