-
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
Site settings: prevent console price formatting warnings #99046
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~42 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. 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. |
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 this fix and the review request, @ciampo.
The proposed changes look good to me. I can confirm the warning isn't displaying.
I haven't noticed any regressions when testing with either non-A4A or A4A sites. The modal is loading price correctly and the buttons work as expected:
The code in this page is quite messy, mixing logic about "untangled"/"tangled" sites, a4a and non-a4a site, and other forks in the logic. I tried to keep the scope of this PR as focused as possible on solving the warnings, but this file would definitely benefit from a refactor.
I remember it wasn't fun indeed when we worked on the A4A-related changes on this page. It caters to many different cases. I suspect that could have contributed to us missing the warning before.
9215dec
to
1b20e75
Compare
Thank you for testing, @ivan-ottinger ! I pushed a couple of commits to address feedback, could you take another look to make sure everything keeps working as expected? |
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 LGTM from my perspective 👍
Thanks for improving the price logic, looks so much cleaner now!
I have reviewed the latest changes and tested the PR again and haven't noticed any issues. 👌🏼🙂 (tested with Simple, Atomic A4A, Atomic non-A4A sites) |
* Site settings: refactor agencyBillingMessage to prevent price formatting warnings * Move undefined check inside createAgencyBillingMessage function * Add price/currency check, refactor from ternary to early return
Proposed Changes
Why are these changes being made?
Currently, the
price
(that is displayed in the agency billing message) is compute every render.When there's no agency associated to the site, this causes the browser console to be flooded with warnings.
Those warnings should pollute the browser console and should actually only be shown when the price needs to be calculated/displayed.
Note
The code in this page is quite messy, mixing logic about "untangled"/"tangled" sites, a4a and non-a4a site, and other forks in the logic. I tried to keep the scope of this PR as focused as possible on solving the warnings, but this file would definitely benefit from a refactor.
Testing Instructions
/settings/general/{SITE_SLUG}
, make sure that:settings/general/{A4A_DEV_SITE_SLUG}
Pre-merge Checklist