Email management: read the raw Purchase instead of the assembled one - #113959
Draft
sirbrillig wants to merge 1 commit into
Draft
Email management: read the raw Purchase instead of the assembled one#113959sirbrillig wants to merge 1 commit into
sirbrillig wants to merge 1 commit into
Conversation
Replaces the getEmailPurchaseByDomain Redux selector with a useEmailPurchaseByDomain hook backed by purchaseQuery, and converts EmailPlanHeader, EmailPlanSubscription, EmailPlan, TitanManageMailboxes and the shared RenewButton to the raw api-core Purchase. RenewButton's two remaining camelCase callers (registered-domain-details and the domain security page) bridge with purchase.rawPurchase until the domain settings cluster migrates. Part of SHILL-2256.
|
WordPress.com
Automattic for Agencies
|
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~92 bytes removed 📉 [gzipped]) Details
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. 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. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to https://linear.app/a8c/issue/SHILL-2256
Proposed changes
Moves the email management pages off the camelCase
Purchaseproduced by the data-stores assembler and onto the raw snake_casePurchasefrom@automattic/api-core, fetched with TanStack Query instead of Redux.RenewButtoncomes along because the email subscription card feeds it — leaving it camelCase would have relocated a bridge rather than removed one.getEmailPurchaseByDomainRedux selector with a newuseEmailPurchaseByDomain( domain )hook backed bypurchaseQuery. The domain object already carries the email subscription id, so this fetches the one purchase directly rather than the whole site's purchases.EmailPlanHeaderand drop itspurchase/isLoadingPurchaseprops. Both callers only passed the value straight through, and this lets the still-class-basedTitanManageMailboxesdrop purchases frommapStateToPropsentirely instead of gaining a container component.EmailPlanSubscription,EmailPlanandRenewButtonto the raw shape (expiry_date,currency_code,is_auto_renew_enabled,ID), inlining the renewal price assale_amount || amountand sourcingisExpiredOrRemovedfromclient/dashboard/utils/purchase.<QuerySitePurchases />fetch triggers from both email pages — nothing else underclient/my-sites/emailreads the Redux purchase selectors.purchase.rawPurchasebridges (the email renew handler, theAutoRenewTogglein the subscription card, andRenewButton's own).RenewButton's two remaining camelCase callers —registered-domain-detailsand the domainsecuritypage — bridge withpurchase?.rawPurchase ?? nulluntil the domain settings cluster migrates.Why are these changes being made?
The data-stores assembler (
createPurchaseObject) exists only to rename the API's snake_case purchase fields into camelCase, which means every purchase-rendering surface in Calypso carries a duplicatePurchasetype and an extra transformation the backend never asked for. SHILL-2256 removes it; the assembler stays alive until the last consumer migrates, so the work is landing page by page.Email management is a self-contained cluster: a single selector fed three consumers, all of which passed the purchase into the same header component. That made it possible to delete the selector outright and let the component that actually renders the subscription fetch its own data, which removes a layer of prop drilling as a side effect.
RenewButtonwas pulled in deliberately rather than bridged — it is the direct child of the email subscription card, so converting only the card would have moved acreatePurchaseObjectcall intoclient/my-sites/emailinstead of deleting one.The
<QuerySitePurchases />removals are safe because these pages fetched the entire site's purchase list purely to look up one subscription by id;purchaseQueryasks the API for exactly that purchase.Testing instructions
No test files exist for any of the touched components, so no new coverage was added. The surrounding suites confirm nothing regressed:
TC:
Manual testing:
RenewButton: on Domains → {domain} → Settings, confirm the renew button shows the correct price and starts a renewal; and on an expired domain's Security page (HTTPS disabled notice), confirm the reactivate/renew button still shows the correct price.Pre-merge Checklist