mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
dc9c812d9c
issue https://github.com/TryGhost/Team/issues/857 - The goal is to avoid testing for the owner role only is cases where we should be testing for the owner or admin role - `isOwner` => `isOwnerOnly` - `isAdmin` => `isAdminOnly` - `isOwnerOrAdmin` => `isAdmin` (concerns now both Owner and Admins)
57 lines
1.4 KiB
JavaScript
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.setBillingWindowOpen(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.setBillingWindowOpen(isBillingTransition);
|
|
}
|
|
},
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Ghost(Pro)'
|
|
};
|
|
}
|
|
});
|