-
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
Implement the dotlink version of Link in Bio flow on Stepper #71204
Merged
Merged
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
aaaf9be
Start scalfolding the dotlink version of Link in Bio flow.
southp 4923180
Accompany several occurences of LINK_IN_BIO_FLOW with the TLD sibling.
southp b0860cf
Define the flow progress data for LINK_IN_BIO_TLD flow
southp 5200abb
Include `link-in-bio-tld` in the global style sheet.
southp e8fbb39
Define the Launchpad task list for the dotlink Link in Bio flow.
southp ec55444
Derive the required `link` and `w.link` info at the domains step of the
southp 2b6b108
Fix the styling issue of the user step.
southp 9fd88cc
Add `link-in-bio-tld` class to both the patterns & the Link in Bio setup
southp b89ab34
LINK_IN_BIO_FLOW -> flow
southp 91e1ee6
Cover LINK_IN_BIO_TLD_FLOW in <PlanPill/>
southp 832dae1
Fix the plans step styling (somehow it is actually from the Launchpad
southp 8f99b1a
Define the popular plan spec for the dotlink Link in Bio flow.
southp 943f1ce
When a user is logged-in, the 2nd step should be `patterns`
southp a7cd786
Update client/landing/stepper/declarative-flow/link-in-bio-tld.ts
southp 4602855
Remove the extraneous newline caused by taking a suggested fix.
southp 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
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
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
149 changes: 149 additions & 0 deletions
149
client/landing/stepper/declarative-flow/link-in-bio-tld.ts
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 |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import { useLocale } from '@automattic/i18n-utils'; | ||
import { useFlowProgress, LINK_IN_BIO_TLD_FLOW } from '@automattic/onboarding'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { translate } from 'i18n-calypso'; | ||
import { useEffect } from 'react'; | ||
import { recordFullStoryEvent } from 'calypso/lib/analytics/fullstory'; | ||
import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; | ||
import wpcom from 'calypso/lib/wp'; | ||
import { | ||
clearSignupDestinationCookie, | ||
setSignupCompleteSlug, | ||
persistSignupDestination, | ||
setSignupCompleteFlowName, | ||
} from 'calypso/signup/storageUtils'; | ||
import { useSiteSlug } from '../hooks/use-site-slug'; | ||
import { USER_STORE, ONBOARD_STORE } from '../stores'; | ||
import { recordSubmitStep } from './internals/analytics/record-submit-step'; | ||
import DomainsStep from './internals/steps-repository/domains'; | ||
import LaunchPad from './internals/steps-repository/launchpad'; | ||
import LinkInBioSetup from './internals/steps-repository/link-in-bio-setup'; | ||
import PatternsStep from './internals/steps-repository/patterns'; | ||
import PlansStep from './internals/steps-repository/plans'; | ||
import Processing from './internals/steps-repository/processing-step'; | ||
import SiteCreationStep from './internals/steps-repository/site-creation-step'; | ||
import type { Flow, ProvidedDependencies } from './internals/types'; | ||
|
||
const linkInBio: Flow = { | ||
name: LINK_IN_BIO_TLD_FLOW, | ||
get title() { | ||
return translate( 'Link in Bio' ); | ||
}, | ||
useSteps() { | ||
useEffect( () => { | ||
recordTracksEvent( 'calypso_signup_start', { flow: this.name } ); | ||
recordFullStoryEvent( 'calypso_signup_start_link_in_bio', { flow: this.name } ); | ||
}, [] ); | ||
|
||
return [ | ||
{ slug: 'domains', component: DomainsStep }, | ||
{ slug: 'patterns', component: PatternsStep }, | ||
{ slug: 'linkInBioSetup', component: LinkInBioSetup }, | ||
{ slug: 'plans', component: PlansStep }, | ||
{ slug: 'siteCreationStep', component: SiteCreationStep }, | ||
{ slug: 'processing', component: Processing }, | ||
{ slug: 'launchpad', component: LaunchPad }, | ||
]; | ||
}, | ||
|
||
useStepNavigation( _currentStepSlug, navigate ) { | ||
const flowName = this.name; | ||
const { setStepProgress } = useDispatch( ONBOARD_STORE ); | ||
const flowProgress = useFlowProgress( { stepName: _currentStepSlug, flowName } ); | ||
const siteSlug = useSiteSlug(); | ||
const userIsLoggedIn = useSelect( ( select ) => select( USER_STORE ).isCurrentUserLoggedIn() ); | ||
const locale = useLocale(); | ||
|
||
setStepProgress( flowProgress ); | ||
|
||
// trigger guides on step movement, we don't care about failures or response | ||
wpcom.req.post( | ||
'guides/trigger', | ||
{ | ||
apiNamespace: 'wpcom/v2/', | ||
}, | ||
{ | ||
flow: flowName, | ||
step: _currentStepSlug, | ||
} | ||
); | ||
|
||
const logInUrl = | ||
locale && locale !== 'en' | ||
? `/start/account/user/${ locale }?variationName=${ flowName }&pageTitle=Link%20in%20Bio&redirect_to=/setup/${ flowName }/patterns` | ||
: `/start/account/user?variationName=${ flowName }&pageTitle=Link%20in%20Bio&redirect_to=/setup/${ flowName }/patterns`; | ||
|
||
// for the standard Link in Bio flow | ||
southp marked this conversation as resolved.
Show resolved
Hide resolved
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. Only a minor thing, I think you can change/remove this comment here 👍 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. Good catch. The suggested fix has been taken :D |
||
const submit = ( providedDependencies: ProvidedDependencies = {} ) => { | ||
recordSubmitStep( providedDependencies, '', flowName, _currentStepSlug ); | ||
|
||
switch ( _currentStepSlug ) { | ||
case 'domains': | ||
clearSignupDestinationCookie(); | ||
|
||
if ( userIsLoggedIn ) { | ||
return navigate( 'plans' ); | ||
} | ||
|
||
return window.location.assign( logInUrl ); | ||
|
||
case 'patterns': | ||
return navigate( 'linkInBioSetup' ); | ||
|
||
case 'linkInBioSetup': | ||
return navigate( 'plans' ); | ||
|
||
case 'plans': | ||
return navigate( 'siteCreationStep' ); | ||
|
||
case 'siteCreationStep': | ||
return navigate( 'processing' ); | ||
|
||
case 'processing': | ||
if ( providedDependencies?.goToCheckout ) { | ||
const destination = `/setup/${ flowName }/launchpad?siteSlug=${ providedDependencies.siteSlug }`; | ||
persistSignupDestination( destination ); | ||
setSignupCompleteSlug( providedDependencies?.siteSlug ); | ||
setSignupCompleteFlowName( flowName ); | ||
const returnUrl = encodeURIComponent( | ||
`/setup/${ flowName }/launchpad?siteSlug=${ providedDependencies?.siteSlug }` | ||
); | ||
|
||
return window.location.assign( | ||
`/checkout/${ encodeURIComponent( | ||
( providedDependencies?.siteSlug as string ) ?? '' | ||
) }?redirect_to=${ returnUrl }&signup=1` | ||
); | ||
} | ||
return navigate( `launchpad?siteSlug=${ providedDependencies?.siteSlug }` ); | ||
|
||
case 'launchpad': { | ||
return navigate( 'processing' ); | ||
} | ||
} | ||
return providedDependencies; | ||
}; | ||
|
||
const goBack = () => { | ||
return; | ||
}; | ||
|
||
const goNext = () => { | ||
switch ( _currentStepSlug ) { | ||
case 'launchpad': | ||
return window.location.assign( `/view/${ siteSlug }` ); | ||
|
||
default: | ||
return navigate( 'intro' ); | ||
} | ||
}; | ||
|
||
const goToStep = ( step: string ) => { | ||
navigate( step ); | ||
}; | ||
|
||
return { goNext, goBack, goToStep, submit }; | ||
}, | ||
}; | ||
|
||
export default linkInBio; |
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.
Do we need to do this manually?
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 suppose we don't. This PR focuses on making the flow work first, so I simply refer to how
link-in-bio.ts
does it for now. It can be improved as a separate PR for sure :)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.
Yes @alshakero, this is how we are doing in the LiB flow as well, I think it can be good here for this PR :)