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

Theme Showcase: Update Controllers for an "All Sites" View #87000

Merged
merged 3 commits into from
Feb 14, 2024

Conversation

Copons
Copy link
Contributor

@Copons Copons commented Jan 30, 2024

Fixes https://github.com/Automattic/dotcom-forge/issues/5383

Proposed Changes

  • Add a new selectSiteIfLoggedInWithOneSite routing callback to be used in logged-in /themes and /theme.

The new callback allows for a new "All Sites" view, accessible to users owning multiple sites, that defers the site selection to the latest possible moment, rather than before opening the Theme Showcase.

This change's purpose is to let users browse themes immediately instead of having to select a site first, using the old and unappealing site selector.

The new selectSiteIfLoggedInWithOneSite callback practically replaces the previous selectSiteIfLoggedInWithSites, introduced in #82917 in support of a "no sites" view. The old callback remains available, but it's currently not used anywhere.

After the change, we'll have the following routing situation:

Sites Before After Notes
0 Screenshot 2024-02-05 at 13 18 45 Screenshot 2024-02-05 at 13 18 45 No changes
1 Screenshot 2024-02-05 at 13 21 07 Screenshot 2024-02-05 at 13 21 07 No changes
2+ Screenshot 2024-02-05 at 13 21 55 Screenshot 2024-02-05 at 13 19 17 "Pick theme" actions trigger a start/with-theme flow.

About Theme Actions and the with-theme Flow

This is only the first step of a larger project.

This PR is only responsible for changing routing.
Another PR will introduce a deferred site selection modal integrated with the various "Pick theme" (and similar) actions.

Testing Instructions

  • Use a test user with zero sites.
    • Open /themes or /theme/bedrock (or any other Theme Details page) without site fragment in URL.
    • Ensure both pages open without additional steps.
  • Use a test user with exactly one site.
    • Open /themes or /theme/bedrock (or any other Theme Details page) without site fragment in URL.
    • Ensure the routing automatically selects the only site, and both pages open without additional steps.
  • Use a test user with two or more sites.
    • Open /themes or /theme/bedrock (or any other Theme Details page) without site fragment in URL.
    • Ensure both pages open without additional steps.
    • Try clicking on various theme links.
    • Ensure they start a new onboarding flow (just like the zero sites example).

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • https://wpcalypso.wordpress.com/devdocs/docs/testing/index.md 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)?

@Copons Copons added [Status] In Progress [Feature] Theme Showcase The theme showcase screen in Calypso in Appearance > Themes. labels Jan 30, 2024
@Copons Copons self-assigned this Jan 30, 2024
Copy link

github-actions bot commented Jan 30, 2024

@matticbot
Copy link
Contributor

matticbot commented Jan 31, 2024

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

Sections (~157 bytes added 📈 [gzipped])

name                               parsed_size           gzip_size
woocommerce-installation                 +67 B  (+0.0%)      +38 B  (+0.0%)
woocommerce                              +67 B  (+0.0%)      +38 B  (+0.0%)
themes                                   +67 B  (+0.0%)      +16 B  (+0.0%)
theme                                    +67 B  (+0.0%)      +16 B  (+0.0%)
subscribers                              +67 B  (+0.0%)      +18 B  (+0.0%)
stats                                    +67 B  (+0.0%)      +17 B  (+0.0%)
site-purchases                           +67 B  (+0.0%)      +19 B  (+0.0%)
site-monitoring                          +67 B  (+0.0%)      +38 B  (+0.0%)
settings-writing                         +67 B  (+0.0%)      +38 B  (+0.0%)
settings-security                        +67 B  (+0.0%)      +38 B  (+0.0%)
settings-reading                         +67 B  (+0.0%)      +38 B  (+0.0%)
settings-podcast                         +67 B  (+0.0%)      +38 B  (+0.0%)
settings-performance                     +67 B  (+0.0%)      +38 B  (+0.0%)
settings-newsletter                      +67 B  (+0.0%)      +38 B  (+0.0%)
settings-jetpack                         +67 B  (+0.0%)      +38 B  (+0.0%)
settings-discussion                      +67 B  (+0.0%)      +38 B  (+0.0%)
settings                                 +67 B  (+0.0%)      +17 B  (+0.0%)
scan                                     +67 B  (+0.0%)      +38 B  (+0.0%)
purchases                                +67 B  (+0.0%)      +19 B  (+0.0%)
promote-post-i2                          +67 B  (+0.0%)      +38 B  (+0.0%)
preview                                  +67 B  (+0.0%)      +38 B  (+0.0%)
posts-custom                             +67 B  (+0.0%)      +38 B  (+0.0%)
posts                                    +67 B  (+0.0%)      +38 B  (+0.0%)
plugins                                  +67 B  (+0.0%)      +17 B  (+0.0%)
plans                                    +67 B  (+0.0%)      +15 B  (+0.0%)
people                                   +67 B  (+0.0%)      +17 B  (+0.0%)
pages                                    +67 B  (+0.0%)      +38 B  (+0.0%)
migrate                                  +67 B  (+0.0%)      +38 B  (+0.0%)
media                                    +67 B  (+0.0%)      +18 B  (+0.0%)
marketplace                              +67 B  (+0.0%)      +17 B  (+0.0%)
marketing                                +67 B  (+0.0%)      +38 B  (+0.0%)
jetpack-social                           +67 B  (+0.0%)      +38 B  (+0.0%)
jetpack-search                           +67 B  (+0.0%)      +38 B  (+0.0%)
jetpack-connect                          +67 B  (+0.0%)      +38 B  (+0.0%)
jetpack-cloud-settings                   +67 B  (+0.0%)      +38 B  (+0.0%)
jetpack-cloud-pricing                    +67 B  (+0.0%)      +38 B  (+0.0%)
jetpack-cloud-plugin-management          +67 B  (+0.0%)      +17 B  (+0.0%)
jetpack-cloud-overview                   +67 B  (+0.0%)      +38 B  (+0.0%)
jetpack-cloud-features-comparison        +67 B  (+0.0%)      +38 B  (+0.0%)
jetpack-cloud                            +67 B  (+0.0%)      +38 B  (+0.0%)
import                                   +67 B  (+0.0%)      +38 B  (+0.0%)
hosting                                  +67 B  (+0.0%)      +17 B  (+0.0%)
home                                     +67 B  (+0.0%)      +15 B  (+0.0%)
gutenberg-editor                         +67 B  (+0.0%)      +38 B  (+0.0%)
google-my-business                       +67 B  (+0.0%)      +38 B  (+0.0%)
github-deployments                       +67 B  (+0.0%)      +38 B  (+0.0%)
export                                   +67 B  (+0.0%)      +38 B  (+0.0%)
email                                    +67 B  (+0.0%)      +38 B  (+0.0%)
earn                                     +67 B  (+0.0%)      +18 B  (+0.0%)
domains                                  +67 B  (+0.0%)      +19 B  (+0.0%)
customize                                +67 B  (+0.0%)      +38 B  (+0.0%)
concierge                                +67 B  (+0.0%)      +38 B  (+0.0%)
comments                                 +67 B  (+0.0%)      +38 B  (+0.0%)
checkout                                 +67 B  (+0.0%)      +19 B  (+0.0%)
backup                                   +67 B  (+0.0%)      +17 B  (+0.0%)
add-ons                                  +67 B  (+0.0%)      +38 B  (+0.0%)
activity                                 +67 B  (+0.0%)      +38 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.

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.

@Copons Copons force-pushed the update/themes-controller-all-sites branch 2 times, most recently from 95af80d to d818654 Compare February 5, 2024 13:00
@Copons Copons requested review from arthur791004 and a team February 5, 2024 13:32
@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, 2024
Comment on lines +903 to +898
// If the user is logged out, has 0 sites, or the path contains a site fragment,
// proceed with the regular site selection.
if ( ! isLoggedIn || ! siteCount || !! siteFragment ) {
siteSelection( context, next );
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this matches with the name of the function. From the name I was expecting this to select the site if only one site was available or to proceed with the chain, and right now the function is doing 2 different things or proceeding the chain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm not very happy with both naming and flow, but I couldn't find a better idea. 🤔

Do you have a suggestion for making this cleaner?

Copy link
Contributor

Choose a reason for hiding this comment

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

We could extract this to a new command (maybe called selectSiteIfLoggedIn) that we will add to the chain after the selectSiteIfLoggedInWithOneSite command. That would make things cleaner.

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, we could just rename this to something more generic like handleSiteSelection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've renamed it as selectSiteOrSkipIfLoggedInWithMultipleSites.
It's a mouthful, but it's also descriptive of what it does. 🙂

Copy link
Member

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

I think selectSiteIfLoggedInWithSites is no longer used after these changes, can we remove it?

Comment on lines +903 to +898
// If the user is logged out, has 0 sites, or the path contains a site fragment,
// proceed with the regular site selection.
if ( ! isLoggedIn || ! siteCount || !! siteFragment ) {
siteSelection( context, next );
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, we could just rename this to something more generic like handleSiteSelection.

@Copons Copons force-pushed the update/themes-controller-all-sites branch from d818654 to 7e4bf1f Compare February 7, 2024 11:53
Copy link
Contributor

@xavier-lc xavier-lc left a comment

Choose a reason for hiding this comment

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

Works as described

@xavier-lc xavier-lc force-pushed the update/themes-controller-all-sites branch from 551efda to 3a7f0fe Compare February 14, 2024 12:05
@matticbot
Copy link
Contributor

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

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

  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug update/themes-controller-all-sites on your sandbox.

@xavier-lc xavier-lc merged commit 47b8a69 into trunk Feb 14, 2024
11 checks passed
@xavier-lc xavier-lc deleted the update/themes-controller-all-sites branch February 14, 2024 12:19
@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 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Theme Showcase The theme showcase screen in Calypso in Appearance > Themes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants