From 0cf2fc9c24a37bfe2d1e20633e892eee36cd1712 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Fri, 7 May 2021 14:34:43 +0530 Subject: [PATCH] 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. --- .../components/gh-launch-wizard/set-pricing.js | 1 - ghost/admin/app/controllers/dashboard.js | 18 ++++++++++++++++++ ghost/admin/app/routes/launch.js | 7 +++++++ ghost/admin/app/templates/dashboard.hbs | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/components/gh-launch-wizard/set-pricing.js b/ghost/admin/app/components/gh-launch-wizard/set-pricing.js index 88af4d30ca..fb04c851e0 100644 --- a/ghost/admin/app/components/gh-launch-wizard/set-pricing.js +++ b/ghost/admin/app/components/gh-launch-wizard/set-pricing.js @@ -183,7 +183,6 @@ export default class GhLaunchWizardSetPricingComponent extends Component { ...data, product: null }); - this.args.nextStep(); } } diff --git a/ghost/admin/app/controllers/dashboard.js b/ghost/admin/app/controllers/dashboard.js index 63f734041e..06a500a5a2 100644 --- a/ghost/admin/app/controllers/dashboard.js +++ b/ghost/admin/app/controllers/dashboard.js @@ -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) => { diff --git a/ghost/admin/app/routes/launch.js b/ghost/admin/app/routes/launch.js index d2802cc24b..1e8013380e 100644 --- a/ghost/admin/app/routes/launch.js +++ b/ghost/admin/app/routes/launch.js @@ -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'); + } + }); }); } } diff --git a/ghost/admin/app/templates/dashboard.hbs b/ghost/admin/app/templates/dashboard.hbs index 3e0025c489..acb57fefd4 100644 --- a/ghost/admin/app/templates/dashboard.hbs +++ b/ghost/admin/app/templates/dashboard.hbs @@ -7,7 +7,7 @@
- {{#if (and this.session.user.isOwner (not this.feature.launchComplete))}} + {{#if (and this.session.user.isOwner this.showLaunchWizard)}}

Select your publication style