-
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
Domain Management: Finish replacing CartData with ShoppingCartProvider #48202
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~166 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 (~35 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. |
@@ -74,7 +73,6 @@ export default { | |||
analyticsTitle="Domain Management > Edit" | |||
component={ DomainManagement.Edit } | |||
context={ pageContext } | |||
needsCart |
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.
From what I can tell, none of these actually use a cart
prop apart from DomainManagement.List
, which only used it for HeaderCart
and that has been converted to use withShoppingCart
already.
Since this potentially touches a lot of files and I'm not sure how to test them all just yet, I've extracted the bug fix itself into #48285 |
485ff3a
to
8cb1740
Compare
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.
Looks good. The only thing that I was unable to verify is if addProductsToCart( [ fillInSingleCartItemAttributes( item ) ] )
is really the right replacement of addItem( item )
🙂
The API may not be as elegant 😅 (and it can be improved in the future), but it is the right replacement. The differences are:
Eventually it would be nice to improve the process of getting the |
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 verified that the Manage > Domains
page works as expected, but I'm also not sure how to test the other domain pages.
524786f
to
5275a0f
Compare
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.
Thanks for the PR! Love to see the flux CartStore go away ❤️
However, I've noticed on this branch a possible regression:
Screen.Recording.2020-12-21.at.16.02.22.mov
First of all, after you select a domain (press the Select
button), we put it in busy
mode (as expected). We're double-checking the availability of the domain in the background - however, once that is done, there seems to be a noticeable pause where the Select
button becomes active again and nothing seemingly is happening. Then the G Suite upsell finally shows up.
However, a bigger issue is that if you come back to the domain management page, remove the domain, select another (or the same), it goes to the cart, but we're no longer taken to the upsell/checkout. Note also the whole list refresh - that's not me, that was automatic (I'm guessing a page navigation was triggered?).
I have not tested if this is specific to this order of events, but it seemed quite "unstable". I'm also not sure if one of the other pending PRs is not perhaps addressing this already, but wanted to mention it in case it's a new issue 😅 🙇♂️ (I've checked and cannot reproduce it on production)
Good point! This delay is because, unlike the previous version, the code here waits for the cart update to finish before redirecting to the next page. This is to prevent race conditions where the next page might fetch the cart before the update completes. From what I can tell, the "busy" state is actually only triggered by the call to I've pushed a commit to do that by adding a
Wow, that's very interesting... I was able to reproduce pretty easily. It's not obvious from the video, but the URL does change to the google apps upsell correctly. The issue appears to be that that URL is loading the domain search page instead. I didn't change anything in this PR about how the redirect works ( |
Ah hah. The issue is that the Because of this strong dependency that both components use the same cart data, it's probably best to include that PR here. I've pulled those commits into this PR and updated the testing instructions. |
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.
Other than the UX quirk (which hopefully should be an easy fix), this LGTM. Tested a few cases, including existing shopping cart items, upgrading with a plan and everyone's favourite: /domains
;)
@@ -173,6 +174,9 @@ class DomainRegistrationSuggestion extends React.Component { | |||
buttonStyles = { ...buttonStyles, disabled: true }; | |||
} | |||
} | |||
if ( this.props.isCartPendingUpdate ) { | |||
buttonStyles = { ...buttonStyles, busy: true }; |
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 think this check should go higher, to line 170 and simply be } else if ( pendingCheckSuggestion || this.props.isCartPendingUpdate ) {
. Otherwise, this causes a weird UX where suddenly the suggestions Select
buttons go from disabled to suddenly busy and clickable. So, you can actually select another domain while you're waiting to be redirected to the cart. Which is not an error in itself, but I can imagine could cause some confusion (and possibly unwanted domains being bought).
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.
That's a good suggestion; I didn't realize that if busy
is set, the button remains clickable!
In that case, we'll need to decide what to do about the existing if ( pendingCheckSuggestion )
clause. With your suggestion, that clause will never activate, which makes me think that you're saying we should replace line 170 with the condition. But if we do that, then the button will not display as busy
when adding the product to the cart, it will be disabled
instead because pendingCheckSuggestion
will not be set. I wonder if you mean removing the nested if
entirely like:
} else if ( pendingCheckSuggestion || this.props.isCartPendingUpdate ) {
buttonStyles = { ...buttonStyles, busy: true, disabled: true };
}
It's already provided by withShoppingCart
8c8008b
to
8c48bc5
Compare
Rebased and hopefully fixed the UX issue where the button jumps from disabled to busy. |
Changes proposed in this Pull Request
In #47605 we updated PopoverCart to replace the
CartData
wrapper with theShoppingCartProvider
within the domains management components (this will help us eventually removeCartData
; see #24019), but there were some things that were missed.First, although
HeaderCart
(a parent ofPopoverCart
) was changed to usewithShoppingCart
to provide itscart
prop, that prop was still being explicitly passed in by the parents of that component. This PR removes those props in case they might cause confusion or bugs.Second, the
DomainSearch
component uses cart actions to add and remove products from the cart, but those actions still useCartStore
. This PR converts that component to use theShoppingCartProvider
functions for manipulating the cart.Third, the
DomainManagementData
wrapper has aneedsCart
property that fetches the cart from theCartStore
. This PR removes that property. Many of the pages under the domain management section had that property enabled, but from what I can tell, almost none of them used it, so this does not addwithShoppingCart
to any of the children (but if any of them need the cart, that would be an easy solution).This also updates
GSuiteUpgrade
to useuseShoppingCart
from@automattic/shopping-cart
in place ofCartData
. This is similar to the upgrade toGSuiteNudge
from #48438. We had to include this here because otherwise either the domain that was added by the domain search page will not have finished updating the cart by the time we hit the G Suite page, causing the G Suite submission to overwrite it (which will probably fail since it will be in a cart without a domain), or the G Suite page will redirect back to the domain search page because it can't see the domain in the cart.Testing instructions
We should also verify that the other domain management pages still work as expected since the cart data has been removed from them. I'm not 100% sure how to test each of these but it may be enough to look at each one and verify that they don't use the
cart
prop.DomainManagement.Edit
DomainManagement.SiteRedirect
DomainManagement.TransferIn
DomainManagement.ManageConsent
Testing instructions for the G Suite nudge