Added home redirect for pricing wizard

refs https://github.com/TryGhost/Team/issues/644

In case the prices are already set for the default product, its confusing to have the launch wizard show the price setup again. We remove the wizard completely if the prices are already created for the default product.
This commit is contained in:
Rishabh 2021-05-07 14:34:43 +05:30
parent da49dc4922
commit 0cf2fc9c24
4 changed files with 26 additions and 2 deletions

View File

@ -183,7 +183,6 @@ export default class GhLaunchWizardSetPricingComponent extends Component {
...data,
product: null
});
this.args.nextStep();
}
}

View File

@ -2,6 +2,7 @@ import Controller from '@ember/controller';
import {action} from '@ember/object';
import {getSymbol} from 'ghost-admin/utils/currency';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency-decorators';
import {tracked} from '@glimmer/tracking';
export default class DashboardController extends Controller {
@ -35,6 +36,7 @@ export default class DashboardController extends Controller {
@tracked whatsNewEntries = null;
@tracked whatsNewEntriesLoading = null;
@tracked whatsNewEntriesError = null;
@tracked product = null;
get topMembersDataHasOpenRates() {
return this.topMembersData && this.topMembersData.find((member) => {
@ -47,12 +49,28 @@ export default class DashboardController extends Controller {
}
initialise() {
this.loadProducts.perform();
this.loadEvents();
this.loadTopMembers();
this.loadCharts();
this.loadWhatsNew();
}
get showLaunchWizard() {
const hasPrices = this.product && this.product.get('stripePrices').length > 0;
return !this.feature.launchComplete && !hasPrices;
}
@task({drop: true})
*loadProducts() {
try {
const products = yield this.store.query('product', {include: 'stripe_prices'});
this.product = products.firstObject;
} catch (e) {
this.product = null;
}
}
loadMRRStats() {
this.mrrStatsLoading = true;
this.membersStats.fetchMRR().then((stats) => {

View File

@ -6,10 +6,17 @@ export default class LaunchRoute extends AuthenticatedRoute {
beforeModel() {
super.beforeModel(...arguments);
return this.session.user.then((user) => {
if (!user.isOwner) {
return this.transitionTo('home');
}
this.store.query('product', {include: 'stripe_prices'}).then((products) => {
const defaultProduct = products.firstObject;
if (defaultProduct.get('stripePrices').length > 0) {
return this.transitionTo('home');
}
});
});
}
}

View File

@ -7,7 +7,7 @@
<div class="view-container gh-dashboard">
{{#if (and this.session.user.isOwner (not this.feature.launchComplete))}}
{{#if (and this.session.user.isOwner this.showLaunchWizard)}}
<section class="gh-dashboard-area lw-banner">
<div class="gh-lw-banner" style="background-image:url(assets/img/launch-wizard-bg.png);">
<h1>Select your publication style</h1>