-
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
Plans 2023: Migrate plan-properties computation and other refactors #79733
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~5763 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 (~341 bytes added 📈 [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. |
5918886
to
b70413d
Compare
Thanks for pulling this off, @chriskmnds :)
Update: The only major thing I've found is that the upgrade credit notification is gone. i.e. this notif: Also, when I tested the However, I couldn't reproduce it since, so I thought I'd just still attach it here so there is a clue to track it down :) |
Reviewer Story - aka what I understoodThis is a set of personal notes that other reviewer can find useful and possibly also thinks out loud so that any misconceptions can be clarified by the PR author as well. Examining the New Hooks Introduced
|
export interface PricedAPIPlan { | |
product_id: number; | |
product_name: string; | |
path_slug?: PlanPath; | |
product_slug: StorePlanSlug; |
/data-store/use-pricing-meta-for-grid-plans.ts Similar to above mainly exacts pricing data from usePricedAPIPlans and api returned plan price information. It lives in client due to intense coupling so it's passed as a prop for now. This utilises some existing redux selectors to structure and build the data type shown below.
wp-calypso/client/my-sites/plan-features-2023-grid/hooks/npm-ready/data-store/use-grid-plans.tsx
Lines 44 to 48 in b70413d
export interface PricingMetaForGridPlan { | |
billingPeriod?: PricedAPIPlan[ 'bill_period' ] | null; | |
currencyCode?: PricedAPIPlan[ 'currency_code' ] | null; | |
originalPrice: { | |
monthly: number | null; |
plans-features-main/hooks/use-plan-upgradeability-check.ts This is another hook that is tightly coupled to client/state which resolves if the current site plan is upgradeable to any plan. Runs the following selector on a given array of slugs.
wp-calypso/client/my-sites/plans-features-main/hooks/use-plan-upgradeability-check.ts
Lines 20 to 22 in abc79dc
[ planSlug ]: | |
!! selectedSiteId && isPlanAvailableForPurchase( state, selectedSiteId, planSlug ), | |
}; |
Hooks ready to be moved into separate package
- data-store/use-grid-plans.tsx/usePlanTypesWithIntent. - This hooks is an internal utility helper function to useGridPlan that resolves an array of related plan slugs given a specific intent and other relevant logic.
wp-calypso/client/my-sites/plan-features-2023-grid/hooks/npm-ready/data-store/use-grid-plans.tsx
Lines 186 to 194 in b70413d
case 'plans-default-wpcom': planTypes = [ TYPE_FREE, ...( isBloggerAvailable ? [ TYPE_BLOGGER ] : [] ), TYPE_PERSONAL, TYPE_PREMIUM, TYPE_BUSINESS, TYPE_ECOMMERCE, ...( isEnterpriseAvailable ? [ TYPE_ENTERPRISE_GRID_WPCOM ] : [] ),
Hooks used outside useGridPlan
useIsLargeCurrency
- use-is-large-currency.ts
This hook was previously introduced and is just refactored to use the GridPlan data structure and moved. It is wired closer near the grid.
Other Related Notes
- usePlansFromTypes Takes a set of planTypes ( Which are essentially plan slugs but for the frontend ) and a term. and provides the actual mapped
planSlugs
which are the actual plan unique identifiers in the back end.
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.
Summary for my own understanding:
Plans Properties becomes Grid Plans
- This PR focuses on
plansProperties
, a data structure that we used to build inclient/my-sites/plan-features-2023-grid/index.tsx
plansProperties
was a collection of data about each plan ( ecommerce, business, premium, etc. ). The data was used to help the features grid and comparison grid render properly in onboarding, /plans, etc. ( Ex. what storage options were available for each plan, what kind of billing was available for each plan, etc. )- This PR moves the construction of
plansProperties
into a hook, use-grid-plans.tsx - This PR also renames
plansProperties
intogridPlans
Grid Plans are made accessible through React Context
gridPlans
are retrieved from the hook and made available to components through the PlansGridContext Provider defined ingrid-context.tsx
https://github.com/Automattic/wp-calypso/pull/79733/files#diff-b4abc92980ca26396e8c6842ad40c6228bed83151e150efafe902162abb94f71R27-R33
-PlansGridContext wraps the Feature Grid and the Comparison Grid. All components that used to needplanProperties
now have access togridPlans
through theusePlansGridContext
hook
The large surface area of file changes and lines of code changed is due to the widespread usage of plansProperties.
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.
Initial Round of review comments.
client/my-sites/plan-features-2023-grid/hooks/npm-ready/data-store/use-grid-plans.tsx
Outdated
Show resolved
Hide resolved
client/my-sites/plan-features-2023-grid/hooks/npm-ready/data-store/use-grid-plans.tsx
Show resolved
Hide resolved
client/my-sites/plan-features-2023-grid/hooks/npm-ready/data-store/use-grid-plans.tsx
Show resolved
Hide resolved
client/my-sites/plan-features-2023-grid/hooks/npm-ready/data-store/use-grid-plans.tsx
Outdated
Show resolved
Hide resolved
Thanks @jeyip . Good catch. This should be fixed. missed to update the set for that intent in a rebase ^ probably worth adding test coverage for more intents (I think we only cover newsletter and wpcom-default) |
ceb42b0
to
c3d4af8
Compare
60cda02
to
6d488b8
Compare
@jeyip care to give this another round of testing pls? everything should be addressed and rebased |
Yes! I’d be happy to 🎉 Taking a look before eod. Let’s get this over the finish line |
TestingRequirements
Spot checked with production:
Also tested:
Browsers
IssuesThe transaction fees for payments appears to be incorrect for free plans in ![]() The ![]() |
After we resolve the issue in #79733 (comment) with transaction fees for payments ( whether we decide it be through a follow-up or a fix in this PR ) , the testing side of this looks good. Consider it a +1 from me when completed |
This PR modifies the release build for happy-blocks To test your changes on WordPress.com, run To deploy your changes after merging, see the documentation: PCYsg-r7r-p2 |
This PR modifies the release build for editing-toolkit To test your changes on WordPress.com, run To deploy your changes after merging, see the documentation: PCYsg-mMA-p2 |
Thanks @jeyip . I did notice this from early on but forgot about it. It should be addressed now. Thanks for being thorough :-)
I notice this too @southp, but didn't got to the bottom of it. As far as I checked, those slugs are part of the plans list, so it seemed a little weird 😕 . I will create a follow-up issue and leave it up for grabs/later, as it's not actually blocking anything. |
Can confirm it has been addressed 👍 |
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.
🚢 🚀
Thnaks @jeyip for the trusted reviews. This is obviously not the final shape. Right now we are mostly removing dependencies and separating concerns. We will iterate and improve things more. GridPlan in particular can be optimized with prospect of being easier to mock next. |
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/8692603 Hi @chriskmnds, could you please edit the description of this PR and add a screenshot for our translators? Ideally it'd include all of the following strings:
Thank you in advance! |
Translation for this Pull Request has now been finished. |
Fixes #79003, #79000
Partly addresses #79004, #79005 -- which can be deprioritized until package extraction
Proposed Changes
GridPlan
concept.GridPlan
is a more complete data structure with most data needed by the respective grid components i.e. components are now fed only the GridPlans they need to render (e.g. ComparisonGrid gets the full set of plans that features are built out from) and these include all Pricing and Features metadata.A few more:
use-grid-plan
,use-plan-features-
). Nothing final, and the calls made inplan-features-main
can potentially be reduced once everything public-facing for the plans package.client/lib/plans/features-list
(some parts are intermediate until feature definitions migrate to calypso-products). So partly addresses Plans Next: Migrate the Features list/metadata to@automattic/calypso-products
#79004 to get us closer to a packageTesting Instructions
Everything plans related:
@southp has written out a careful testing plan down below. For a more general sanity check:
/start
and tailored flows (e.g./start/hosting
,/setup/newsletter
,/setup/link-in-bio
)/plans/[ paid, free]
/plans
with WooExpress (grabbed from/setup/wooexpress
) and Newsletter sites/plans/[paid]
with a paid site to show the pro-rated credits notice)Pre-merge Checklist