wp-calypso icon indicating copy to clipboard operation
wp-calypso copied to clipboard

Fix the Plan grid downgrade/upgrade buttons

Open valterlorran opened this issue 8 months ago • 12 comments

Related to:

  • https://github.com/Automattic/wp-calypso/pull/83775
  • https://github.com/Automattic/wp-calypso/pull/83785

Proposed Changes

  • Following @jeyip's idea, I removed the code that was setting the selectedSiteID and passed down the site ID to the useCheckPlanAvailabilityForPurchase hook. This way, we can use the site ID as fallback if we don't have the selectedSiteID property.

Why are these changes being made?

  • We were getting a bug because the selectedSiteId was being persisted when the user accessed the plan grid having a siteSlug, then when they accessed the plan grid again without a site it would reproduce the state for the previous accessed site. This caused the purchase buttons to be disabled and display the "Please contact support to downgrade your plan" message.

Testing Instructions

  • Go to /setup/newsletter/plans?siteSlug=A_PAID_SITE_SLUG.
  • The plans grid won't let you pick a plan because you already have a paid plan.
  • Visit /setup/newsletter/plans (without the siteSlug).
  • The plans grid should no longer be disabled

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-aUh-p2)?

valterlorran avatar Jun 18 '24 12:06 valterlorran