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

Plans Grid: fix default state of storage dropdown when an addon is purchased #99310

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

aneeshd16
Copy link
Contributor

Related to #

Proposed Changes

  • Fixes the default option shown in the storage dropdown when a storage add-on has already been purchased for that site.

Before

Kapture.2025-02-04.at.17.28.57.mp4

After

Kapture.2025-02-04.at.17.29.33.mp4

Why are these changes being made?

  • When a storage add-on has already been purchased, the default option in the dropdown should represent the purchased storage add-on. However, it currently represents the plan storage.

Testing Instructions

  • Go to /add-ons/<site slug> for a site a site on the Business plan and purchase a storage add-on.

  • Go to /plans/<site slug> for the same site.

  • Confirm that the default value in the storage dropdown in the spotlight card is the (plan storage (50GB) + the purchased storage add-on quantity).

  • Confirm that selecting a different option changes the CTA text to "Upgrade".

  • Confirm that selecting the default option changes the CTA text to "Manage Plan".

  • Go to /setup/onboarding/plans and confirm that the dropdown works as intended.

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 UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • 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-aUh-p2)?

@aneeshd16 aneeshd16 self-assigned this Feb 5, 2025
@aneeshd16 aneeshd16 requested a review from a team as a code owner February 5, 2025 01:35
@aneeshd16 aneeshd16 requested a review from oswian February 5, 2025 01:35
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 5, 2025
@matticbot
Copy link
Contributor

matticbot commented Feb 5, 2025

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

Sections (~11 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
update-design-flow          +19 B  (+0.0%)      +11 B  (+0.0%)
plugins                     +19 B  (+0.0%)      +11 B  (+0.0%)
plans                       +19 B  (+0.0%)      +11 B  (+0.0%)
link-in-bio-tld-flow        +19 B  (+0.0%)      +11 B  (+0.0%)
jetpack-app                 +19 B  (+0.0%)      +11 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 (~11 bytes added 📈 [gzipped])

name                                             parsed_size           gzip_size
async-load-signup-steps-plans-theme-preselected        +19 B  (+0.0%)      +11 B  (+0.0%)
async-load-signup-steps-plans                          +19 B  (+0.0%)      +11 B  (+0.0%)

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.

@matticbot
Copy link
Contributor

matticbot commented Feb 5, 2025

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • command-palette-wp-admin
  • help-center
  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/storage-addon-default-state on your sandbox.

@jeyip
Copy link
Contributor

jeyip commented Feb 5, 2025

Testing

Requirements

  • Confirm that the default value in the storage dropdown in the spotlight card is the (plan storage (50GB) + the purchased storage add-on quantity).
  • Confirm that selecting a different option changes the CTA text to "Upgrade".
  • Confirm that selecting the default option changes the CTA text to "Manage Plan".
  • Smoke test /setup/onboarding/plans storage add-on dropdown

Browsers

  • Chrome

const selectControlOptions = [ defaultStorageItem ].concat(
availableStorageAddOns?.map( ( addOn ) => {
const addOnStorage = addOn.quantity ?? 0;
return [ defaultStorageAddOnMeta, ...availableStorageAddOns ]?.map( ( addOn ) => {
Copy link
Contributor

@jeyip jeyip Feb 5, 2025

Choose a reason for hiding this comment

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

NB:

A little confusing for me to read the destructuring of AddOnMeta with AddOns. Not a strong opinion, but thoughts about renaming to defaultStorageAddOnMeta to defaultStorageAddOn?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I named it because getSelectedStorageAddOn returns AddOnMeta. 🤔 It is a bit confusing because the value of defaultStorageAddOnMeta can also be { addOnSlug: defaultStorageOptionSlug, prices: null, quantity: 0 }, which is clearly not AddOnMeta. I'll try to refactor this to make it clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done via 4cfe287! Hope it's clearer now.

@aneeshd16 aneeshd16 merged commit bb95ced into trunk Feb 6, 2025
13 checks passed
@aneeshd16 aneeshd16 deleted the fix/storage-addon-default-state branch February 6, 2025 00:24
@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 Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants