Skip to content

Commit

Permalink
Fix: Plugins sidebar link on single site accounts goes to global plug…
Browse files Browse the repository at this point in the history
…ins page (#94330)
  • Loading branch information
xavier-lc authored Sep 10, 2024
1 parent 7a5bcc9 commit 2fc9408
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/my-sites/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ export function noSite( context, next ) {
return next();
}

const PATHS_EXCLUDED_FROM_SINGLE_SITE_CONTEXT_FOR_SINGLE_SITE_USERS = [ '/plugins' ];

/*
* Set up site selection based on last URL param and/or handle no-sites error cases
*/
Expand All @@ -532,6 +534,8 @@ export function siteSelection( context, next ) {
const siteFragment = context.params.site || getSiteFragment( context.path );
const currentUser = getCurrentUser( getState() );
const hasOneSite = currentUser && currentUser.visible_site_count === 1;
const isPathExcludedFromSingleSiteContext =
PATHS_EXCLUDED_FROM_SINGLE_SITE_CONTEXT_FOR_SINGLE_SITE_USERS.includes( context.path );

// Making sure non-connected users get redirected to user connection flow.
// Details: p9dueE-6Hf-p2
Expand Down Expand Up @@ -560,14 +564,14 @@ export function siteSelection( context, next ) {

/*
* If the user has only one site, redirect to the single site context instead of
* rendering the all-site views.
* rendering the all-site views. Exclude plugins page from this behavior.
*
* If the primary site is not yet available in Redux state, initiate a fetch and postpone the
* redirect until the fetch is complete. (while the primary site ID is a property of the
* current user object and therefore always available, we need to fetch the site info in order
* to convert the site ID to the site slug that will be part of the redirect URL)
*/
if ( hasOneSite && ! siteFragment ) {
if ( hasOneSite && ! siteFragment && ! isPathExcludedFromSingleSiteContext ) {
const primarySiteId = getPrimarySiteId( getState() );
const primarySiteSlug = getSiteSlug( getState(), primarySiteId );

Expand Down

0 comments on commit 2fc9408

Please sign in to comment.