-
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
Refactor the bundle installation to be generic #84886
Changes from all commits
afafd12
cb51bbe
5efd51a
4575b6a
14a7768
3fc713d
fa5ba4f
c666534
19af71c
f17fd99
bd2c819
c753658
cb77c6f
23f01f8
6edb309
01791a9
49f24dd
f3c61f7
f448108
d5d0eea
bbc6c0b
9bf0212
2add0ab
efdefa1
f227e86
a689fc4
11555fd
9b6355d
3e9eff8
7834689
691a7d7
3b65a42
739f2f9
4184b93
894db61
1b69050
cd6f5da
f7791a0
15cee75
59878f2
99dfe64
fb98dbe
b5fa4e0
67f5a17
c08ac45
00a7551
77bca35
6698d00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { ProductsList } from '@automattic/data-stores'; | ||
import { StepContainer } from '@automattic/onboarding'; | ||
import { StepContainer, NextButton } from '@automattic/onboarding'; | ||
import styled from '@emotion/styled'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { useI18n } from '@wordpress/react-i18n'; | ||
|
@@ -11,21 +11,41 @@ import FormattedHeader from 'calypso/components/formatted-header'; | |
import { LoadingEllipsis } from 'calypso/components/loading-ellipsis'; | ||
import WarningCard from 'calypso/components/warning-card'; | ||
import { useSite } from 'calypso/landing/stepper/hooks/use-site'; | ||
import { useSitePluginSlug } from 'calypso/landing/stepper/hooks/use-site-plugin-slug'; | ||
import { | ||
AUTOMATED_ELIGIBILITY_STORE, | ||
SITE_STORE, | ||
ONBOARD_STORE, | ||
} from 'calypso/landing/stepper/stores'; | ||
import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; | ||
import { addQueryArgs } from 'calypso/lib/url'; | ||
import { ActionSection, StyledNextButton } from 'calypso/signup/steps/woocommerce-install'; | ||
import { eligibilityHolds as eligibilityHoldsConstants } from 'calypso/state/automated-transfer/constants'; | ||
import SupportCard from '../store-address/support-card'; | ||
import type { Step } from '../../types'; | ||
import type { OnboardSelect, SiteSelect } from '@automattic/data-stores'; | ||
import type { TransferEligibilityError } from '@automattic/data-stores/src/automated-transfer-eligibility/types'; | ||
import './style.scss'; | ||
|
||
const ActionSection = styled.div` | ||
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. I moved these styles directly to this final instead of importing it from |
||
display: flex; | ||
justify-content: space-between; | ||
align-items: baseline; | ||
flex-wrap: wrap; | ||
margin-top: 40px; | ||
gap: 4%; | ||
|
||
@media ( max-width: 320px ) { | ||
align-items: center; | ||
} | ||
`; | ||
|
||
const StyledNextButton = styled( NextButton )` | ||
@media ( max-width: 320px ) { | ||
width: 100%; | ||
margin-bottom: 20px; | ||
} | ||
`; | ||
|
||
const Divider = styled.hr` | ||
border-top: 1px solid #eee; | ||
background: none; | ||
|
@@ -41,11 +61,12 @@ const TRANSFERRING_NOT_BLOCKERS = [ | |
eligibilityHoldsConstants.TRANSFER_ALREADY_EXISTS, // Already Atomic sites are handled in the install flow. | ||
]; | ||
|
||
const WooConfirm: Step = function WooCommerceConfirm( { navigation } ) { | ||
const BundleConfirm: Step = function BundleConfirm( { navigation } ) { | ||
const { goBack, submit } = navigation; | ||
const { __ } = useI18n(); | ||
const site = useSite(); | ||
const siteId = site && site?.ID; | ||
const pluginSlug = useSitePluginSlug(); | ||
const isAtomicSite = useSelect( | ||
( select ) => siteId && ( select( SITE_STORE ) as SiteSelect ).isSiteAtomic( siteId ), | ||
[ siteId ] | ||
|
@@ -179,8 +200,8 @@ const WooConfirm: Step = function WooCommerceConfirm( { navigation } ) { | |
required: requiresUpgrade, | ||
checkoutUrl: addQueryArgs( | ||
{ | ||
redirect_to: addQueryArgs( queryArgs, '/setup/plugin-bundle/wooTransfer' ), | ||
cancel_to: addQueryArgs( queryArgs, '/setup/plugin-bundle/wooConfirm' ), | ||
redirect_to: addQueryArgs( queryArgs, '/setup/plugin-bundle/bundleTransfer' ), | ||
cancel_to: addQueryArgs( queryArgs, '/setup/plugin-bundle/bundleConfirm' ), | ||
}, | ||
`/checkout/${ wpcomDomain }/${ upgradingPlan?.product_slug ?? '' }` | ||
), | ||
|
@@ -206,7 +227,7 @@ const WooConfirm: Step = function WooCommerceConfirm( { navigation } ) { | |
} | ||
|
||
return ( | ||
<div className="woo-confirm__upgrade-required"> | ||
<div className="bundle-confirm__upgrade-required"> | ||
<PlanWarning title={ __( 'Plan upgrade required' ) }> | ||
{ siteUpgrading.description } | ||
</PlanWarning> | ||
|
@@ -242,8 +263,8 @@ const WooConfirm: Step = function WooCommerceConfirm( { navigation } ) { | |
function getContent() { | ||
return ( | ||
<> | ||
<div className="woo-confirm__info-section" /> | ||
<div className="woo-confirm__instructions-container"> | ||
<div className="bundle-confirm__info-section" /> | ||
<div className="bundle-confirm__instructions-container"> | ||
{ getWPComSubdomainWarningContent() } | ||
{ getCheckoutContent() } | ||
{ getWarningsOrHoldsSection() } | ||
|
@@ -252,11 +273,24 @@ const WooConfirm: Step = function WooCommerceConfirm( { navigation } ) { | |
<StyledNextButton | ||
disabled={ isTransferringBlocked || ! isDataReady } | ||
onClick={ () => { | ||
recordTracksEvent( 'calypso_woocommerce_dashboard_confirm_submit', { | ||
const eventProperties = { | ||
site: wpcomDomain, | ||
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. it'd be good to add a property here for the bundle slug, that way we can create bundle specific funnels and stats later if necessary 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 point! Added in 59878f2. |
||
upgrade_required: siteUpgrading.required, | ||
}; | ||
|
||
recordTracksEvent( 'calypso_bundle_dashboard_confirm_submit', { | ||
...eventProperties, | ||
software_set: pluginSlug, | ||
} ); | ||
|
||
// For backward compatibility with existing event. When it's not used anymore, it can be removed. | ||
if ( 'woo-on-plans' === pluginSlug ) { | ||
recordTracksEvent( | ||
'calypso_woocommerce_dashboard_confirm_submit', | ||
eventProperties | ||
); | ||
} | ||
|
||
const providedDependencies = { | ||
checkoutUrl: siteUpgrading.checkoutUrl, | ||
}; | ||
|
@@ -276,7 +310,7 @@ const WooConfirm: Step = function WooCommerceConfirm( { navigation } ) { | |
|
||
if ( site === null || ! site.ID || ! isDataReady || isReadyToStart ) { | ||
return ( | ||
<div className="woo-confirm__loading-container"> | ||
<div className="bundle-confirm__loading-container"> | ||
<LoadingEllipsis /> | ||
</div> | ||
); | ||
|
@@ -289,13 +323,13 @@ const WooConfirm: Step = function WooCommerceConfirm( { navigation } ) { | |
|
||
return ( | ||
<StepContainer | ||
stepName="woo-confirm" | ||
stepName="bundle-confirm" | ||
goBack={ goBack } | ||
hideSkip | ||
isHorizontalLayout={ true } | ||
formattedHeader={ | ||
<FormattedHeader | ||
id="woo-confirm-title-header" | ||
id="bundle-confirm-title-header" | ||
headerText={ headerText } | ||
subHeaderText={ subHeaderText } | ||
align="left" | ||
|
@@ -308,4 +342,4 @@ const WooConfirm: Step = function WooCommerceConfirm( { navigation } ) { | |
); | ||
}; | ||
|
||
export default WooConfirm; | ||
export default BundleConfirm; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
/* eslint-disable no-console */ | ||
import config from '@automattic/calypso-config'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { useEffect } from 'react'; | ||
import { useSite } from 'calypso/landing/stepper/hooks/use-site'; | ||
import { useSitePluginSlug } from 'calypso/landing/stepper/hooks/use-site-plugin-slug'; | ||
import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; | ||
import { logToLogstash } from 'calypso/lib/logstash'; | ||
import { useBundleSettings } from 'calypso/my-sites/theme/hooks/use-bundle-settings'; | ||
import { ONBOARD_STORE, SITE_STORE } from '../../../../stores'; | ||
import type { Step } from '../../types'; | ||
import type { AtomicSoftwareStatus, OnboardSelect, SiteSelect } from '@automattic/data-stores'; | ||
|
@@ -17,38 +20,63 @@ export interface FailureInfo { | |
error: string; | ||
} | ||
|
||
const WooInstallPlugins: Step = function WooInstallPlugins( { navigation } ) { | ||
const BundleInstallPlugins: Step = function BundleInstallPlugins( { navigation } ) { | ||
const { submit } = navigation; | ||
const { setPendingAction, setProgressTitle, setProgress } = useDispatch( ONBOARD_STORE ); | ||
const { initiateSoftwareInstall, requestAtomicSoftwareStatus } = useDispatch( SITE_STORE ); | ||
const { getAtomicSoftwareInstallError, getAtomicSoftwareStatus, getAtomicSoftwareError } = | ||
useSelect( ( select ) => select( SITE_STORE ) as SiteSelect, [] ); | ||
const site = useSite(); | ||
const softwareSet = 'woo-on-plans'; | ||
const softwareSet = useSitePluginSlug(); | ||
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. In some cases, you will see |
||
const bundleSettings = useBundleSettings( softwareSet ); | ||
const translate = useTranslate(); | ||
const { getIntent } = useSelect( ( select ) => select( ONBOARD_STORE ) as OnboardSelect, [] ); | ||
|
||
const handleTransferFailure = ( failureInfo: FailureInfo ) => { | ||
recordTracksEvent( 'calypso_woocommerce_dashboard_snag_error', { | ||
const eventProperties = { | ||
action: failureInfo.type, | ||
site: site?.URL, | ||
code: failureInfo.code, | ||
error: failureInfo.error, | ||
intent: getIntent(), | ||
} ); | ||
}; | ||
|
||
logToLogstash( { | ||
feature: 'calypso_client', | ||
const logstashProperties = { | ||
feature: 'calypso_client' as 'calypso_client' | 'calypso_ssr', | ||
message: failureInfo.error, | ||
severity: config( 'env_id' ) === 'production' ? 'error' : 'debug', | ||
blog_id: site?.ID, | ||
properties: { | ||
env: config( 'env_id' ), | ||
type: 'calypso_woocommerce_dashboard_snag_error', | ||
type: 'calypso_bundle_dashboard_snag_error', | ||
action: failureInfo.type, | ||
site: site?.URL, | ||
code: failureInfo.code, | ||
}, | ||
}; | ||
|
||
recordTracksEvent( 'calypso_bundle_dashboard_snag_error', { | ||
...eventProperties, | ||
software_set: softwareSet, | ||
} ); | ||
|
||
logToLogstash( { | ||
...logstashProperties, | ||
properties: { ...logstashProperties.properties, software_set: softwareSet }, | ||
} ); | ||
|
||
// For backward compatibility with existing event. When it's not used anymore, it can be removed. | ||
if ( 'woo-on-plans' === softwareSet ) { | ||
recordTracksEvent( 'calypso_woocommerce_dashboard_snag_error', eventProperties ); | ||
|
||
logToLogstash( { | ||
...logstashProperties, | ||
properties: { | ||
...logstashProperties.properties, | ||
type: 'calypso_woocommerce_dashboard_snag_error', | ||
}, | ||
} ); | ||
} | ||
}; | ||
|
||
useEffect( () => { | ||
|
@@ -57,7 +85,14 @@ const WooInstallPlugins: Step = function WooInstallPlugins( { navigation } ) { | |
} | ||
|
||
setPendingAction( async () => { | ||
setProgressTitle( 'Installing WooCommerce' ); | ||
// translators: %(softwareName)s is the software name that is being installed. | ||
const title = translate( 'Installing %(softwareName)s', { | ||
args: { | ||
softwareName: bundleSettings?.softwareName || '', | ||
}, | ||
} ); | ||
|
||
setProgressTitle( title ); | ||
setProgress( 0 ); | ||
initiateSoftwareInstall( site.ID, softwareSet ); | ||
|
||
|
@@ -111,4 +146,4 @@ const WooInstallPlugins: Step = function WooInstallPlugins( { navigation } ) { | |
return null; | ||
}; | ||
|
||
export default WooInstallPlugins; | ||
export default BundleInstallPlugins; |
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 added the
steps
argument here.It seems when it was created, the type already had the steps argument, but it was never used.