-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signup: Fix site
path through domain-first
flow
#11601
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -28,7 +25,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 +40,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 +52,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 +106,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 } ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of using an arrow function here?
This may be just me but I find it more readable :). |
||
} else if ( user.get() ) { | ||
fetchSitesAndUser( siteSlug, addToCartAndProceed ); | ||
} else { | ||
|
@@ -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 | ||
|
@@ -266,9 +234,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, { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we also have
createSiteWithCartAndStartFreeTrial
function that callscreateSiteWithCart
butreduxStore
param is not passed. I have no idea if that is required, but we should double check if it doesn't break anything.