From db3f7ac3aef7f75dd8745ea2b7d436ea643f6452 Mon Sep 17 00:00:00 2001 From: Drew Blaisdell Date: Fri, 24 Feb 2017 15:33:24 -0800 Subject: [PATCH 1/3] Signup: Provide `reduxStore` through parameter instead of context --- client/lib/signup/flow-controller.js | 4 ++-- client/lib/signup/step-actions.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/lib/signup/flow-controller.js b/client/lib/signup/flow-controller.js index a47397d53e4553..033b14c04eaeb3 100644 --- a/client/lib/signup/flow-controller.js +++ b/client/lib/signup/flow-controller.js @@ -204,12 +204,12 @@ assign( SignupFlowController.prototype, { SignupActions.processSignupStep( step ); - const apiFunction = steps[ step.stepName ].apiRequestFunction.bind( this ); + const apiFunction = steps[ step.stepName ].apiRequestFunction; apiFunction( ( errors, providedDependencies ) => { this._processingSteps[ step.stepName ] = false; SignupActions.processedSignupStep( step, errors, providedDependencies ); - }, dependenciesFound, step ); + }, dependenciesFound, step, this._reduxStore ); } }, diff --git a/client/lib/signup/step-actions.js b/client/lib/signup/step-actions.js index 1773ba1ff14aff..5d86592cfd0d6e 100644 --- a/client/lib/signup/step-actions.js +++ b/client/lib/signup/step-actions.js @@ -28,7 +28,7 @@ import { import { getSiteTitle } from 'state/signup/steps/site-title/selectors'; import { getSurveyVertical, getSurveySiteType } from 'state/signup/steps/survey/selectors'; -function createCart( callback, dependencies, data ) { +function createCart( callback, dependencies, data, reduxStore ) { const { designType } = dependencies; const { domainItem, themeItem } = data; @@ -43,7 +43,7 @@ function createCart( callback, dependencies, data ) { SignupCart.addToCart( cartKey, [ domainItem ], error => callback( error, providedDependencies ) ); } else { - createSiteWithCart( callback, dependencies, data ); + createSiteWithCart( callback, dependencies, data, reduxStore ); } } @@ -55,9 +55,9 @@ function createSiteWithCart( callback, dependencies, { siteUrl, themeSlugWithRepo, themeItem -} ) { - const siteTitle = getSiteTitle( this._reduxStore.getState() ).trim(); - const surveyVertical = getSurveyVertical( this._reduxStore.getState() ).trim(); +}, reduxStore ) { + const siteTitle = getSiteTitle( reduxStore.getState() ).trim(); + const surveyVertical = getSurveyVertical( reduxStore.getState() ).trim(); wpcom.undocumented().sitesNew( { blog_name: siteUrl, @@ -109,7 +109,7 @@ function createSiteWithCart( callback, dependencies, { if ( ! user.get() && isFreeThemePreselected ) { setThemeOnSite( addToCartAndProceed, { siteSlug, themeSlugWithRepo } ); } else if ( user.get() && isFreeThemePreselected ) { - fetchSitesAndUser( siteSlug, setThemeOnSite.bind( this, addToCartAndProceed, { siteSlug, themeSlugWithRepo } ) ); + fetchSitesAndUser( siteSlug, setThemeOnSite.bind( null, addToCartAndProceed, { siteSlug, themeSlugWithRepo } ) ); } else if ( user.get() ) { fetchSitesAndUser( siteSlug, addToCartAndProceed ); } else { @@ -266,9 +266,9 @@ module.exports = { SignupCart.addToCart( siteId, newCartItems, callback ); }, - createAccount( callback, dependencies, { userData, flowName, queryArgs } ) { - const surveyVertical = getSurveyVertical( this._reduxStore.getState() ).trim(); - const surveySiteType = getSurveySiteType( this._reduxStore.getState() ).trim(); + createAccount( callback, dependencies, { userData, flowName, queryArgs }, reduxStore ) { + const surveyVertical = getSurveyVertical( reduxStore.getState() ).trim(); + const surveySiteType = getSurveySiteType( reduxStore.getState() ).trim(); wpcom.undocumented().usersNew( assign( {}, userData, { From 7ceae43de4bd76a19ec017ff3ba70c6f520dde9a Mon Sep 17 00:00:00 2001 From: Drew Blaisdell Date: Mon, 27 Feb 2017 11:24:55 -0800 Subject: [PATCH 2/3] Checkout: Only set selected site once the sites have been fetched in `CartStore` --- client/lib/cart/store/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/lib/cart/store/index.js b/client/lib/cart/store/index.js index d38ae5359aa4a8..99584e2d90ff11 100644 --- a/client/lib/cart/store/index.js +++ b/client/lib/cart/store/index.js @@ -134,6 +134,9 @@ CartStore.dispatchToken = Dispatcher.register( ( payload ) => { } ); sites.on( 'change', setSelectedSite ); -setSelectedSite(); + +if ( sites.fetched ) { + setSelectedSite(); +} module.exports = CartStore; From 5a69d5f578253274f8aae50b77d76ac2fd520d01 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Tue, 28 Feb 2017 10:31:17 +0100 Subject: [PATCH 3/3] Remove unused step domains-with-plan --- client/lib/signup/step-actions.js | 32 ------------------------- client/signup/config/step-components.js | 1 - client/signup/config/steps.js | 11 --------- 3 files changed, 44 deletions(-) diff --git a/client/lib/signup/step-actions.js b/client/lib/signup/step-actions.js index 5d86592cfd0d6e..265bb87e36fc78 100644 --- a/client/lib/signup/step-actions.js +++ b/client/lib/signup/step-actions.js @@ -11,14 +11,11 @@ import { startsWith } from 'lodash'; /** * Internal dependencies */ -import { cartItems } from 'lib/cart-values'; import wpcom from 'lib/wp' ; const sites = require( 'lib/sites-list' )(); const user = require( 'lib/user' )(); import { getSavedVariations } from 'lib/abtest'; import SignupCart from 'lib/signup/cart'; -import { startFreeTrial } from 'lib/upgrades/actions'; -import { PLAN_PREMIUM } from 'lib/plans/constants'; import analytics from 'lib/analytics'; import { @@ -118,25 +115,6 @@ function createSiteWithCart( callback, dependencies, { } ); } -/** - * Adds a Premium with free trial to the shopping cart. - * - * @param {function} callback - function to execute when action completes - * @param {object} dependencies - data provided to the current step - * @param {object} data - additional data provided by the current step - */ -function startFreePremiumTrial( callback, dependencies, data ) { - const { siteId } = dependencies; - - startFreeTrial( siteId, cartItems.planItem( PLAN_PREMIUM ), ( error ) => { - if ( error ) { - callback( error, dependencies ); - } else { - callback( error, dependencies, data ); - } - } ); -} - function fetchSitesUntilSiteAppears( siteSlug, callback ) { if ( sites.select( siteSlug ) ) { callback(); @@ -243,16 +221,6 @@ module.exports = { createSiteWithCart, - createSiteWithCartAndStartFreeTrial( callback, dependencies, data ) { - createSiteWithCart( ( error, providedDependencies ) => { - if ( error ) { - callback( error, providedDependencies ); - } else { - startFreePremiumTrial( callback, providedDependencies, data ); - } - }, dependencies, data ); - }, - addPlanToCart( callback, { siteId }, { cartItem, privacyItem } ) { if ( isEmpty( cartItem ) ) { // the user selected the free plan diff --git a/client/signup/config/step-components.js b/client/signup/config/step-components.js index b5da563d96aef5..4f5e5c5a480097 100644 --- a/client/signup/config/step-components.js +++ b/client/signup/config/step-components.js @@ -20,7 +20,6 @@ module.exports = { 'design-type': DesignTypeComponent, 'design-type-with-store': DesignTypeWithStoreComponent, domains: DomainsStepComponent, - 'domains-with-plan': DomainsStepComponent, 'domain-only': DomainsStepComponent, 'domains-theme-preselected': DomainsStepComponent, 'jetpack-user': UserSignupComponent, diff --git a/client/signup/config/steps.js b/client/signup/config/steps.js index bdf4a28d39b1eb..02d5ae515044c8 100644 --- a/client/signup/config/steps.js +++ b/client/signup/config/steps.js @@ -91,17 +91,6 @@ module.exports = { delayApiRequestUntilComplete: true }, - 'domains-with-plan': { - stepName: 'domains-with-plan', - apiRequestFunction: stepActions.createSiteWithCartAndStartFreeTrial, - providesDependencies: [ 'siteId', 'siteSlug', 'domainItem', 'themeItem' ], - dependencies: [ 'themeSlugWithRepo' ], - props: { - isDomainOnly: false - }, - delayApiRequestUntilComplete: true - }, - 'domains-theme-preselected': { stepName: 'domains-theme-preselected', apiRequestFunction: stepActions.createSiteWithCart,