Skip to content
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

Storage Add Ons: Move UI state into wpcom-plans-ui data store #80158

Merged
merged 13 commits into from
Aug 17, 2023

Conversation

jeyip
Copy link
Contributor

@jeyip jeyip commented Aug 2, 2023

Follow-up to #79041 (comment)

Just want to reemphasize this a little. Our immediate next priority for the plans package is #78266, which is about breaking apart the grid components and exporting individually. This is my next issue on the queue.

So we need to keep our focus/priorities on the refactor we discussed previously on a few occassions (to remove the local selectedStorage state from PlanFeatures2023Grid and use the wpcom-plan-ui data store instead)

Proposed Changes

As part of the plans 2023 pricing page refactor, @chriskmnds is breaking apart the pricing grid components ( features grid & comparison grid ) and exporting them individually.

To prevent roadblocks to his work, we want to avoid sharing UI state locally between the features grid and the comparison grid. As a result, we're moving any storage add ons UI state away from local state management and into the wpcom-plan-ui data store.

GIF

2023-08-02 17 37 45

Testing Instructions

  • Spin up a local dev environment or use calypso live
  • Navigate to /start/plans?flags=plans/upgradeable-storage
  • Verify that selecting items in the storage add ons dropdown continues to behave as expected. To be clear, all we're checking is that dropdown selections persist. No other functionality is wired up at this point
  • Do the same for /plans

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

@jeyip jeyip requested a review from a team as a code owner August 2, 2023 23:30
@jeyip jeyip self-assigned this Aug 2, 2023
@jeyip jeyip requested a review from chriskmnds August 2, 2023 23:30
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Aug 2, 2023
@github-actions
Copy link

github-actions bot commented Aug 2, 2023

@@ -14,8 +15,19 @@ const showDomainUpsellDialog: Reducer< boolean | undefined, WpcomPlansUIAction >
return state;
};

const selectedStorageAddOnsForPlans: Reducer<
Copy link
Contributor Author

@jeyip jeyip Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

Naming this slice of state felt odd because I wasn't sure how to interpret the existing convention. A sibling reducer is called showDomainUpsellDialog. In the end, I tried to make the name as specific as possible, but I'm totally open to changing this

@jeyip jeyip changed the title Plans 2023 Storage Add Ons: Move storage add on UI state into wpcom-plans-ui Storage Add Ons: Move UI state into wpcom-plans-ui data store Aug 3, 2023
@jeyip jeyip force-pushed the update/plans-2023-storage-add-on-UI-state branch from 5f534c2 to bc451bd Compare August 3, 2023 00:56
@jeyip
Copy link
Contributor Author

jeyip commented Aug 7, 2023

@chriskmnds would you mind taking a look at this?

Copy link
Contributor

@chriskmnds chriskmnds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! Left some comments below, #80158 (comment) seems critical and merits investigation. Overall looks good to me though.

packages/data-stores/src/wpcom-plans-ui/actions.ts Outdated Show resolved Hide resolved
packages/data-stores/package.json Show resolved Hide resolved
const reducer = combineReducers( {
showDomainUpsellDialog,
selectedStorageAddOnsForPlans,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking here, so we can resolve in a thread (so not exactly related to this piece of code).

Do we expect to retrieve the selected storage from a location outside of the plans grid package (plan-features-2023-grid)? e.g. from checkout maybe? If that's the case, then we will need to set the value to persist in the data store, and possibly call an action to reset it when rendering the grid components (features table or comparison grid) in a "fire once" hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect to retrieve the selected storage from a location outside of the plans grid package (plan-features-2023-grid)? e.g. from checkout maybe?

Not for the time being. checkout already has their own state management in place for add ons

@sharpirate
Copy link
Contributor

sharpirate commented Aug 10, 2023

Testing

For http://calypso.localhost:3000/start and http://calypso.localhost:3000/start/SITE_SLUG:

✔️ The dropdown works as expected both with keyboard and mouse. The selection is persisted.
✔️ The payload of the corresponding Redux actions looks good:

• 50 GB:

type:"WPCOM_PLANS_UI_SET_STORAGE_ADD_ON_FOR_PLAN"
addOnSlug:"50gb-storage"
plan:"business-bundle"

• 100 GB:

type:"WPCOM_PLANS_UI_SET_STORAGE_ADD_ON_FOR_PLAN"
addOnSlug:"50gb-storage-add-on"
plan:"business-bundle"

• 150 GB:

type:"WPCOM_PLANS_UI_SET_STORAGE_ADD_ON_FOR_PLAN"
addOnSlug:"100gb-storage-add-on"
plan:"business-bundle"

@sharpirate
Copy link
Contributor

sharpirate commented Aug 10, 2023

Do the same for /plans

I wasn't able to test /plans because when I go to http://calypso.localhost:3000/plans I get redirected to https://wordpress.com/pricing/, not sure if I'm missing something

NVM, I realized I was supposed to go to http://calypso.localhost:3000/plans/SITE_SLUG instead of http://calypso.localhost:3000/plans

@jeyip
Copy link
Contributor Author

jeyip commented Aug 10, 2023

Thanks for all the feedback y'all! Taking a look now 👍

@jeyip jeyip force-pushed the update/plans-2023-storage-add-on-UI-state branch from bc451bd to 3be404b Compare August 10, 2023 18:28
@jeyip jeyip force-pushed the update/plans-2023-storage-add-on-UI-state branch from 6aeef7c to add4f03 Compare August 12, 2023 16:12
@matticbot
Copy link
Contributor

matticbot commented Aug 12, 2023

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~2040 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
plugins                   +5073 B  (+0.3%)    +1829 B  (+0.3%)
update-design-flow         +912 B  (+0.1%)     +100 B  (+0.0%)
link-in-bio-tld-flow       +912 B  (+0.1%)     +100 B  (+0.0%)
write-flow                 +656 B  (+0.1%)      +15 B  (+0.0%)
videopress-flow            +656 B  (+0.1%)      +15 B  (+0.0%)
signup                     +656 B  (+0.2%)      +15 B  (+0.0%)
jetpack-connect            +656 B  (+0.1%)      +15 B  (+0.0%)
home                       +656 B  (+0.0%)      +15 B  (+0.0%)
free-flow                  +656 B  (+0.1%)      +15 B  (+0.0%)
build-flow                 +656 B  (+0.1%)      +15 B  (+0.0%)
accept-invite              +656 B  (+0.2%)      +15 B  (+0.0%)
plans                      +256 B  (+0.0%)      +85 B  (+0.0%)

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 (~2169 bytes added 📈 [gzipped])

name                                             parsed_size           gzip_size
async-load-signup-steps-plans-theme-preselected      +5166 B  (+1.3%)    +2169 B  (+1.8%)
async-load-signup-steps-plans                        +5166 B  (+1.3%)    +2169 B  (+1.8%)

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.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@jeyip jeyip force-pushed the update/plans-2023-storage-add-on-UI-state branch from 36d7e45 to 09e9f0c Compare August 13, 2023 03:00
jeyip added 7 commits August 16, 2023 10:07
State doesn't initialize as undefined -- it's the substate selectedStorageAddOnsForPlans that does. We update the optional chaining of the getStorageAddOnForPlan selector to reflect this
@jeyip jeyip force-pushed the update/plans-2023-storage-add-on-UI-state branch from 309aa01 to b2fcca4 Compare August 16, 2023 17:07
Copy link
Contributor

@sharpirate sharpirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and the PR tests well after the recent changes. 👍

@jeyip
Copy link
Contributor Author

jeyip commented Aug 17, 2023

To avoid any more merge conflicts with this PR I'll be merging it shortly.

All comments have been addressed, but @chriskmnds if there's any more you'd like to add when you're back from AFK, I'll be happy to draft immediate follow-ups for any new concerns that pop up.

@jeyip jeyip merged commit 5704332 into trunk Aug 17, 2023
@jeyip jeyip deleted the update/plans-2023-storage-add-on-UI-state branch August 17, 2023 17:08
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Aug 17, 2023
dpasque pushed a commit that referenced this pull request Aug 17, 2023
dpasque pushed a commit that referenced this pull request Aug 17, 2023
…#80158)" (#80771)

This reverts commit 5704332.

It was causing a type-checking build error causing CI to fail.
@jeyip jeyip restored the update/plans-2023-storage-add-on-UI-state branch August 17, 2023 20:59
@jeyip jeyip deleted the update/plans-2023-storage-add-on-UI-state branch August 21, 2023 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants