-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~157 bytes added 📈 [gzipped])
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. Generated by performance advisor bot at iscalypsofastyet.com. |
95af80d
to
d818654
Compare
// 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; | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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. 🙂
There was a problem hiding this 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?
// 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; | ||
} |
There was a problem hiding this comment.
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
.
d818654
to
7e4bf1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as described
551efda
to
3a7f0fe
Compare
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Fixes https://github.com/Automattic/dotcom-forge/issues/5383
Proposed Changes
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 previousselectSiteIfLoggedInWithSites
, 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:
start/with-theme
flow.About Theme Actions and the
with-theme
FlowThis 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
/themes
or/theme/bedrock
(or any other Theme Details page) without site fragment in URL./themes
or/theme/bedrock
(or any other Theme Details page) without site fragment in URL./themes
or/theme/bedrock
(or any other Theme Details page) without site fragment in URL.Pre-merge Checklist