Skip to content

Commit

Permalink
Domain management: Update generate path logic (#98620)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogiii authored and Jess Boctor committed Jan 22, 2025
1 parent a16d015 commit 693a3cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Button } from '@wordpress/components';
import { useTranslate } from 'i18n-calypso';
import { useSelector } from 'react-redux';
import ThankYouProduct from 'calypso/components/thank-you-v2/product';
import { getEmailManagementPath } from 'calypso/my-sites/email/paths';
import getCurrentRoute from 'calypso/state/selectors/get-current-route';

export type ThankYouGoogleWorkspaceProductProps = {
productFamily: string;
Expand All @@ -17,7 +19,8 @@ export function ThankYouGoogleWorkspaceProduct( {
siteSlug,
}: ThankYouGoogleWorkspaceProductProps ) {
const translate = useTranslate();
const emailManagementPath = getEmailManagementPath( siteSlug, domainName );
const currentRoute = useSelector( getCurrentRoute );
const emailManagementPath = getEmailManagementPath( siteSlug, domainName, currentRoute );

let details;
if ( numberOfMailboxesPurchased && numberOfMailboxesPurchased > 1 ) {
Expand Down
11 changes: 10 additions & 1 deletion client/my-sites/email/paths.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isEnabled } from '@automattic/calypso-config';
import { stringify } from 'qs';
import {
isUnderDomainManagementAll,
Expand Down Expand Up @@ -25,6 +26,10 @@ export function isUnderEmailManagementAll( path?: string | null ) {
return path?.startsWith( emailManagementAllSitesPrefix + '/' );
}

export function isUnderCheckoutRoute( path?: string | null ) {
return path?.startsWith( '/checkout' );
}

// Builds a URL query string from an object. Handles null values.
const buildQueryString = ( parameters?: QueryStringParameters ) =>
parameters ? stringify( parameters, { addQueryPrefix: true, skipNulls: true } ) : '';
Expand Down Expand Up @@ -173,7 +178,11 @@ export const getEmailManagementPath: EmailPathUtilityFunction = (
urlParameters = {},
inSiteContext = false
) => {
if ( inSiteContext || isUnderDomainManagementAll( relativeTo ) ) {
if (
inSiteContext ||
isUnderDomainManagementAll( relativeTo ) ||
( isUnderCheckoutRoute( relativeTo ) && isEnabled( 'calypso/all-domain-management' ) )
) {
const prefix =
inSiteContext || isUnderDomainSiteContext( relativeTo )
? emailSiteContextPrefix
Expand Down

0 comments on commit 693a3cd

Please sign in to comment.