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

First iteration of plans store #41856

Merged
merged 4 commits into from
May 7, 2020
Merged

First iteration of plans store #41856

merged 4 commits into from
May 7, 2020

Conversation

alshakero
Copy link
Member

@alshakero alshakero commented May 6, 2020

Changes proposed in this Pull Request

This PR is the first iteration for the store of our plans in Gutenboarding.

Note: I put the files under stores dir as opposed to gutenboarding/lib/plans.ts for consistency. Files under gutenboarding/lib/plans.ts can be removed after this.

Related to #41787.

@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented May 6, 2020

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

App Entrypoints (~1 bytes removed 📉 [gzipped])

name                 parsed_size           gzip_size
entry-gutenboarding        -25 B  (-0.0%)       -1 B  (-0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

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.

Copy link

@razvanpapadopol razvanpapadopol left a comment

Choose a reason for hiding this comment

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

This seems like a good start to have proper selectors and state handling for the plan selection feature. We just need to preserve the existing functionality so the domain could be set, in the order of importance, from:

  • selecting from PlansGrid
  • having the plan slug in the URL
  • selecting a paid domain


const hasPaidDomain = useSelect( ( select ) => select( ONBOARD_STORE ).hasPaidDomain() );
const planPath = usePlanRouteParam();
const plan = getPlanSlugByPath( planPath ) || ( hasPaidDomain ? defaultPaidPlan : freePlan );
Copy link

@razvanpapadopol razvanpapadopol May 6, 2020

Choose a reason for hiding this comment

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

By removing this, we are breaking 2 existing functionalities (detailed in #41471 and #41679):

  • getting plan from URL.
  • replacing Free plan (shown by default) with a paid default version (eg: Personal) when the user picks a paid domain.

I suggest:

  1. creating a selector for defaultPlan
  2. calling useEffect with planPath and hasPaidDomain as dependencies to dispatch setPlan only when there is no selected plan.


const DEFAUlT_STATE: { selectedPlan: Plan; supportedPlans: Array< Plan > } = {
supportedPlans,
selectedPlan: getPlan( supportedPlanSlugs[ 0 ] ),

Choose a reason for hiding this comment

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

We should leave it undefined unless there is explicitly set by using /beginner route or using the PlansGrid.

@simison simison mentioned this pull request May 6, 2020
6 tasks
@alshakero alshakero force-pushed the add/plan-store branch 2 times, most recently from ffd845b to 52817a6 Compare May 7, 2020 12:41
Copy link

@razvanpapadopol razvanpapadopol left a comment

Choose a reason for hiding this comment

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

🚀

@razvanpapadopol razvanpapadopol marked this pull request as ready for review May 7, 2020 13:05
@razvanpapadopol razvanpapadopol requested a review from a team as a code owner May 7, 2020 13:05
@razvanpapadopol razvanpapadopol added the [Goal] New Onboarding previously called Gutenboarding label May 7, 2020
@alshakero alshakero marked this pull request as ready for review May 7, 2020 13:07
@alshakero alshakero added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 7, 2020
@alshakero alshakero merged commit 2fbe423 into master May 7, 2020
@alshakero alshakero deleted the add/plan-store branch May 7, 2020 13:58
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] New Onboarding previously called Gutenboarding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants