-
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
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~195 bytes removed 📉 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~8246 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~81 bytes removed 📉 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
6755a5c
to
ed39003
Compare
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
daad2b8
to
0a4f76f
Compare
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 comment
The reason will be displayed to describe this comment to others. Learn more.
In some cases, you will see softwareSet
vs pluginSlug
.
They are the same thing. They just have different names because in different places they were called differently, and making everything generic, they are getting mixed in some parts.
I didn't want to rename all functions and variables to not make it even bigger, but it's something that could be done in the future.
c6fd676
to
1b8a773
Compare
|
||
export default pluginBundleSteps; | ||
export type BundledPlugin = keyof typeof bundleStepsSettings & string; |
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 don't have much experience with TypeScript, so I'd appreciate help here if any reviewer has a suggestion.
BundledPlugin
type is currently accepting any string
.
If I remove the type BundleStepsSettings
from the bundleStepsSettings
it works properly, accepting only "woo-on-plans"
. The same happens with the previous version of this object (trunk
).
Any idea on how to solve it? The best resource I could find about this is https://stackoverflow.com/questions/51808160/keyof-inferring-string-number-when-key-is-only-a-string
const stepNavigation = flow.useStepNavigation( | ||
currentStepRoute, | ||
_navigate, | ||
flowSteps.map( ( step ) => step.slug ) |
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.
c050e84
to
d449f0b
Compare
recordTracksEvent( 'calypso_woocommerce_dashboard_confirm_submit', { | ||
let eventName = 'calypso_bundle_dashboard_confirm_submit'; | ||
|
||
if ( 'woo-on-plans' === pluginSlug ) { |
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.
This logic was applied in some different places as part of this commit: 4d32095
Do you think it makes sense? So we keep the same event and log when it's the woo-on-plans
, but we use a generic name for the others. Or maybe should we register one event and log for woo-on-plans
, and always register the generic one (having 2 registers for woo-on-plans
)?
Personally, I thought the ideal would be to just rename it for every case (the calypso_woocommerce_dashboard_confirm_submit
wouldn't exist anymore), but I'm afraid that it could break existing reports, and so on.
Also, should I document this somewhere?
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.
There's a tool for documenting new tracks events, more info: PCYsg-mUj-p2
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'd be tempted to have both events, one for woo-on-plans
specifically, so as not to break any existing reports (though it doesn't look oft used tbh) and the generic one that's more future-proof
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.
Done in: 59878f2. I wasn't very sure about the logstash, so I did the same there, just in case.
I'll take a look about the documentation! Thank you!
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.
Events are also registered.
The previous ones (WooCommerce events) weren't registered, and I didn't register them because we probably don't want them to be used anymore.
https://github.com/Automattic/tracks-events-registration/pull/2054
https://github.com/Automattic/tracks-events-registration/pull/2055
* Hook to get the bundle settings for a given theme. | ||
* If the theme doesn't have a sotfware set defined, it returns `null`. | ||
*/ | ||
const useBundleSettings = ( themeId: string ): BundleSettings | null => { |
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.
Now we have hooks to get the settings by software or theme (through useBundleSettingsByTheme
) now.
4d32095
to
a87c1e0
Compare
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 comment
The 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 woocommerce-install
to not have it tied to woocommerce components, and following the approach used in other components. Ideally, in the future, it could be in a central place and replace all the occurrences.
…make-bundle-installation-generic
Update to match changes from conflicting PR. See #85013 and #84886 (comment). Co-authored-by: okmttdhr <okmttdhr@users.noreply.github.com>
373f83e
to
15cee75
Compare
…make-bundle-installation-generic
…make-bundle-installation-generic
…make-bundle-installation-generic
intent, | ||
storeType, | ||
adminUrl, | ||
dispatch, | ||
exitFlow, | ||
} ); | ||
if ( false !== endReturn ) { | ||
if ( settings?.endFlow && false !== endReturn ) { |
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.
7b251e7
to
c08ac45
Compare
…make-bundle-installation-generic
…make-bundle-installation-generic
…make-bundle-installation-generic
* Refactor check for plugins to be generic * Update bundle settings hook to allow getting settings by theme software * Move array of plugins to check to the bundle settings * Update feature flag to a generic name * Rename woo confirm to bundle confirm * Add new hook to get site bundle settings * Add TODO comment to review later * Rename woo transfer to bundle transfer * Make bundle transfer step generic * Rename woo install plugins to bundle install plugins * Make install plugins generic * Translate message that was not translated * Get software name dynamically from bundle settings * Remove a not necessary hook * Refactor hooks to be named exports, following the standards of the existing ones * Use hook to get plugin slug * Remove Woo Verify Email not used feature * Reorganize bundle steps array * Add comments to make the steps more clear * Move custom back to settings * Move flow settings to bundleStepsSettings * Move steps to settings So only one object from this file needs to be customized for bundles. * Make end of flow generic * Make custom functions optional * Add comments to the custom functions * Rename the variable to follow the same standard of the other file * Force type to be a string * Add steps as argument to the useStepNavigation * Make the navigation to the next step generic for the submit * Refactor submit * Update log and event name * Update import to the new function * Remove unused code This logic is part of plugin-bundle-flow. * Move the styles to the file Following the approach applied in other files * Remove comment Keeping it as a customization inside the step, as exception. * Update logic to upgrade site when installing free theme with bundle * Make `ThemeUpgradeModal` Calypso-State-free Update to match changes from conflicting PR. See #85013 and #84886 (comment). Co-authored-by: okmttdhr <okmttdhr@users.noreply.github.com> * Add event for all the cases, and keep the current one for backward compatibility * Fix case when endFlow is not set * Add Sensei bundle settings * Update string to match new updates from rebase * Redirect to Sensei Setup Wizard after the WPCOM flow * Remove step from URL It automattically redirects to the first step of the wizard. * Update string for bundled plugin messages * Fix logic to display activate or upgrade button --------- Co-authored-by: okmttdhr <okmttdhr@users.noreply.github.com>
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/10448936 Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday. Hi @renatho, could you please edit the description of this PR and add a screenshot for our translators? Ideally it'd include this string: Thank you in advance! |
Translation for this Pull Request has now been finished. |
( ( ! isThemeAllowedOnSite || isPremium ) && | ||
! isThemePurchased && | ||
! isExternallyManagedTheme ) || | ||
( isBundledSoftwareSet && ! canInstallPlugins ) |
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.
Hey, @renatho!
This particular change may have unintentionally caused a bug in Woo Express, where themes like tsubaki
and tazza
now requires an upgrade. This is because a free trial site can't activate plugins, and I believe woocommerce
themes are marked as "bundled software set".
May I know what was the intended themes to be matched with this logic?
To reproduce:
- Create a Woo Express free trial site by going to https://woo.com/start and follow through the NUX process
- Go to Appearance > Themes
- Search for
tazza
- Select Tazza theme
- Observe you can't activate it now
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.
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.
Thank you for catching it and quickly raising a PR with the fix!
May I know what was the intended themes to be matched with this logic?
It was supposed to match the paid themes (previous logic) + bundled themes. But I was assuming that any bundled theme would need to be upgraded to a plan where the user can install plugins because it will install a plugin along with the theme. But I missed this use case that you mentioned.
I've made a PR to fix this, #85890.
I'll take a look now.
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.
May I know what was the intended themes to be matched with this logic?
The new theme we are considering outside of WooCommerce is the Course theme, which installs the Sensei LMS.
Related to Automattic/themes#7498
First part of this refactor: #84483
Proposed Changes
site-setup-flow
.Testing Instructions
The following tests are just to make sure everything continues working as previously. Nothing should change and anything new was introduced. Also, please test other different scenarios that you can think of.
Flow starting with free plan and selecting a WooCommerce theme
http://calypso.localhost:3000/start
.Flow starting with business plan and selecting a WooCommerce theme
http://calypso.localhost:3000/start
.Flow starting with free plan and free theme changing to WooCommerce theme later
http://calypso.localhost:3000/start
.Flow starting with business plan and free theme, and changing to WooCommerce theme later
http://calypso.localhost:3000/start
.Known issues
trunk
and staging). When I completed the flow with a WooCommerce bundle (woo-on-plans
), the "Customize this design" button inhttp://calypso.localhost:3000/marketplace/thank-you/{DOMAIN}
was always a link to the site editor. But sometimes when clicked, it was redirecting to WooCommerce home (/wp-admin/admin.php?page=wc-admin
), and others it was just navigating to the site editor without the redirect. I didn't find where this redirect logic lives (I suspect it's not in Calypso), and I couldn't reproduce it anymore, so I'm ignoring it. If you are testing it, and see the same behavior, I can open an issue for that.Pre-merge Checklist