2017-08-22 10:53:26 +03:00
|
|
|
import Route from '@ember/routing/route';
|
2022-11-03 14:14:36 +03:00
|
|
|
import {inject} from 'ghost-admin/decorators/inject';
|
2021-10-22 13:29:55 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2016-06-30 17:45:02 +03:00
|
|
|
|
|
|
|
Route.reopen({
|
2021-10-22 13:29:55 +03:00
|
|
|
billing: service(),
|
|
|
|
router: service(),
|
2022-11-03 14:14:36 +03:00
|
|
|
config: inject(),
|
2021-10-22 13:29:55 +03:00
|
|
|
|
2016-06-30 17:45:02 +03:00
|
|
|
actions: {
|
|
|
|
willTransition(transition) {
|
|
|
|
if (this.get('upgradeStatus.isRequired')) {
|
|
|
|
transition.abort();
|
2019-03-06 16:53:54 +03:00
|
|
|
this.upgradeStatus.requireUpgrade();
|
2016-06-30 17:45:02 +03:00
|
|
|
return false;
|
2022-10-07 17:24:03 +03:00
|
|
|
} else if (this.config.hostSettings?.forceUpgrade) {
|
2021-10-28 13:10:17 +03:00
|
|
|
// Do not prevent transitions to the BMA or to signout
|
|
|
|
if (transition.to?.name === 'pro.index' || transition.to?.name === 'signout') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-10-22 13:29:55 +03:00
|
|
|
transition.abort();
|
|
|
|
// Catch and redirect every route in a force upgrade state
|
|
|
|
this.billing.openBillingWindow(this.router.currentURL, '/pro');
|
|
|
|
return false;
|
2016-06-30 17:45:02 +03:00
|
|
|
} else {
|
2017-10-31 18:27:25 +03:00
|
|
|
return true;
|
2016-06-30 17:45:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|