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

Fix: Filtered plans comparison grid features #75424

Merged
merged 4 commits into from
Apr 7, 2023

Conversation

claudiucelfilip
Copy link
Contributor

@claudiucelfilip claudiucelfilip commented Apr 7, 2023

Related to #1464

Proposed Changes

The features for each plan in the Comparison grid found in the Onboarding Flows and the Plans pages are constructed by appending to the previous plan features. If a lower-tier plan is filtered-out, then its features never get inherited by the other plans.

Screenshot 2023-04-07 at 13 32 33

Testing Instructions

  • Checkout and run this branch locally

  • Go to /start/plans and /plans/{SITE_ID}

  • Try out multiple screen widths

  • The plans grid and comparison table below should be unchanged

  • Go to this line and manipulate the visiblePlans array to show fewer plans (ex. visiblePlans.splice( 0, 1 ) )

  • The plans grid and comparison table below should only show the remaining plans

  • Make sure the correct features are shown in the comparison table

Screenshot 2023-04-07 at 13 53 40

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

@claudiucelfilip claudiucelfilip self-assigned this Apr 7, 2023
@github-actions
Copy link

github-actions bot commented Apr 7, 2023

@matticbot
Copy link
Contributor

matticbot commented Apr 7, 2023

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

Sections (~179 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
update-design-flow         +196 B  (+0.0%)      +43 B  (+0.0%)
plugins                    +196 B  (+0.0%)      +49 B  (+0.0%)
plans                      +196 B  (+0.0%)      +44 B  (+0.0%)
newsletter-flow            +196 B  (+0.0%)      +43 B  (+0.0%)
link-in-bio-tld-flow       +196 B  (+0.0%)      +43 B  (+0.0%)
link-in-bio-flow           +196 B  (+0.0%)      +43 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 (~15 bytes added 📈 [gzipped])

name                                                 parsed_size           gzip_size
async-load-signup-steps-plans                             +196 B  (+0.0%)      +43 B  (+0.0%)
async-load-calypso-my-sites-plan-features-2023-grid       +153 B  (+0.3%)      -28 B  (-0.2%)

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.

];
const { planProperties } = this.props;
const plansToShow = planProperties
.filter( ( { isVisible } ) => isVisible )
Copy link
Contributor Author

@claudiucelfilip claudiucelfilip Apr 7, 2023

Choose a reason for hiding this comment

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

I decided to add the .filter( ( { isVisible } ) => isVisible ) to each location to make it more visible where the filtration is happening.

This causes some indentation changes, so you might want to use Hide whitespaces to see the actually changes.

Comment on lines +669 to +672
if (
isWooExpressMediumPlan( planName ) &&
! isWooExpressMediumPlan( currentSitePlanSlug )
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No changes were made here, it just got autoformatted by the linter.

Comment on lines 1131 to 1135
let isVisible = visiblePlans.indexOf( plan ) !== -1;

if ( hideFreePlan && plan === PLAN_FREE ) {
isVisible = false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the hideFreePlan here so that all visibility computation is in one place.

Comment on lines 610 to +613
const displayedPlansProperties = useMemo(
() =>
( planProperties ?? [] ).filter(
( { planName } ) => ! ( planName === PLAN_ENTERPRISE_GRID_WPCOM )
( { planName, isVisible } ) => isVisible && ! ( planName === PLAN_ENTERPRISE_GRID_WPCOM )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

displayedPlansProperties is used to determine what plans to show in the comparison table on smaller screens and it gets changed each time swap plans by clicking on the name (or cycle between screen sizes).

@claudiucelfilip claudiucelfilip added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Apr 7, 2023
@claudiucelfilip claudiucelfilip assigned zaguiini and unassigned zaguiini Apr 7, 2023
@claudiucelfilip claudiucelfilip requested review from p-jackson, zaguiini, a team and ddc22 April 7, 2023 11:06
@zaguiini
Copy link
Contributor

zaguiini commented Apr 7, 2023

This works fine when hiding only the free plan, but on /start/hosting for example, where the free, personal, and premium plans are hidden, we're back to square one:

image

What's wrong is that some features are still said not to be included even though they are on the Business and above 😢

This is what visiblePlans look like:

image

A quick and dirty way to test the new pricing grid on /start/hosting is to make is2023PricingGridActivePage return true as the first statement in that function.

@claudiucelfilip
Copy link
Contributor Author

claudiucelfilip commented Apr 7, 2023

A quick and dirty way to test the new pricing grid on /start/hosting is to make is2023PricingGridActivePage return true as the first statement in that function.

@zaguiini Thanks for catching that!

This is caused by the plans already being filtered (ex. the personal-bundle and premium-bundle are missing from plans):
230610051-79b1c8fc-1625-4e56-8a98-ae7fef8fbce5

I pushed a fix to move the plan filtration for the 2023 pricing grid from getPlansForPlanFeatures to getVisiblePlansForPlanFeatures.

By setting is2023PricingGridActivePage to true, the comparison table on /start/hosting should look like this:

Screenshot 2023-04-07 at 16 34 15

Screenshot 2023-04-07 at 16 35 07

@zaguiini zaguiini merged commit 51cdc22 into trunk Apr 7, 2023
@zaguiini zaguiini deleted the fix/missing-plans-comparison-features branch April 7, 2023 21:40
@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 Apr 7, 2023
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