diff --git a/client/my-sites/domains/domain-management/list/bulk-all-domains.tsx b/client/my-sites/domains/domain-management/list/bulk-all-domains.tsx index 419b679677a220..a1fd609dcff70b 100644 --- a/client/my-sites/domains/domain-management/list/bulk-all-domains.tsx +++ b/client/my-sites/domains/domain-management/list/bulk-all-domains.tsx @@ -427,6 +427,7 @@ export default function BulkAllDomains( props: BulkAllDomainsProps ) { { ! isLoading && ! isDomainsEmpty && } { ! isDomainsEmpty ? ( { { const { __, _n } = useI18n(); @@ -64,7 +67,7 @@ export const DomainsTableEmailIndicator = ( { return ( e.stopPropagation() } > { message } @@ -79,7 +82,7 @@ export const DomainsTableEmailIndicator = ( { return ( e.stopPropagation() } > { __( '+ Add email' ) } diff --git a/packages/domains-table/src/domains-table/domains-table-row-actions.tsx b/packages/domains-table/src/domains-table/domains-table-row-actions.tsx index fe3fffb6f5385f..27f16776e4f5b9 100644 --- a/packages/domains-table/src/domains-table/domains-table-row-actions.tsx +++ b/packages/domains-table/src/domains-table/domains-table-row-actions.tsx @@ -18,7 +18,7 @@ import { } from '../utils/paths'; import { shouldUpgradeToMakeDomainPrimary } from '../utils/should-upgrade-to-make-domain-primary'; import { ResponseDomain } from '../utils/types'; -import { useDomainsTable } from './domains-table'; +import { useDomainsTable, DomainsTableContext } from './domains-table'; export type DomainAction = 'change-site-address' | 'manage-dns-settings' | 'set-primary-address'; @@ -36,6 +36,7 @@ interface DomainsTableRowActionsProps { isSiteOnFreePlan: boolean; isSimpleSite: boolean; isHostingOverview?: boolean; + context?: DomainsTableContext; } export const DomainsTableRowActions = ( { @@ -46,6 +47,7 @@ export const DomainsTableRowActions = ( { isSiteOnFreePlan, isSimpleSite, isHostingOverview, + context, }: DomainsTableRowActionsProps ) => { const { onDomainAction, @@ -86,7 +88,13 @@ export const DomainsTableRowActions = ( { canViewDetails && ( { domain.type === domainTypes.TRANSFER ? __( 'View transfer' ) : __( 'View settings' ) } @@ -95,7 +103,7 @@ export const DomainsTableRowActions = ( { onDomainAction?.( 'manage-dns-settings', domain ) } - href={ domainManagementDNS( siteSlug, domain.name, isHostingOverview ) } + href={ domainManagementDNS( siteSlug, domain.name, context ) } > { __( 'Manage DNS' ) } @@ -103,7 +111,7 @@ export const DomainsTableRowActions = ( { canManageContactInfo && ( { __( 'Manage contact information' ) } diff --git a/packages/domains-table/src/domains-table/domains-table-row.tsx b/packages/domains-table/src/domains-table/domains-table-row.tsx index 077a6ab4152bb5..2aefc32bbc4651 100644 --- a/packages/domains-table/src/domains-table/domains-table-row.tsx +++ b/packages/domains-table/src/domains-table/domains-table-row.tsx @@ -51,6 +51,7 @@ export function DomainsTableRow( { domain }: DomainsTableRowProps ) { hasWpcomManagedSslCert, } = useDomainRow( domain ); const { + context, canSelectAnyDomains, domainsTableColumns, isCompact, @@ -223,7 +224,11 @@ export function DomainsTableRow( { domain }: DomainsTableRowProps ) { if ( column.name === 'email' ) { return ( - + ); } @@ -259,6 +264,7 @@ export function DomainsTableRow( { domain }: DomainsTableRowProps ) { isSiteOnFreePlan={ site?.plan?.is_free ?? true } isSimpleSite={ ! site?.is_wpcom_atomic } isHostingOverview={ isHostingOverview } + context={ context } /> ) } diff --git a/packages/domains-table/src/domains-table/domains-table.tsx b/packages/domains-table/src/domains-table/domains-table.tsx index ba0803b260624b..396c70750ac05e 100644 --- a/packages/domains-table/src/domains-table/domains-table.tsx +++ b/packages/domains-table/src/domains-table/domains-table.tsx @@ -72,8 +72,10 @@ interface BaseDomainsTableProps { selectedDomainName?: string; selectedFeature?: string; isHostingOverview?: boolean; + context?: DomainsTableContext; } +export type DomainsTableContext = 'site' | 'domains' | string; export type DomainsTableProps = | ( BaseDomainsTableProps & { isAllSitesView: true } ) | ( BaseDomainsTableProps & { isAllSitesView: false; siteSlug: string | null } ); @@ -130,6 +132,7 @@ type Value = { currentlySelectedDomainName?: string; selectedFeature?: string; isHostingOverview?: boolean; + context?: DomainsTableContext; }; export const DomainsTableStateContext = createContext< Value | undefined >( undefined ); @@ -155,6 +158,7 @@ export const useGenerateDomainsTableState = ( props: DomainsTableProps ) => { selectedDomainName, selectedFeature, isHostingOverview = false, + context, } = props; const [ { sortKey, sortDirection }, setSort ] = useState< { @@ -458,6 +462,7 @@ export const useGenerateDomainsTableState = ( props: DomainsTableProps ) => { currentlySelectedDomainName: selectedDomainName, selectedFeature, isHostingOverview, + context, }; return value; diff --git a/packages/domains-table/src/utils/paths.ts b/packages/domains-table/src/utils/paths.ts index 314c4355392e9a..5d1efc141d93b9 100644 --- a/packages/domains-table/src/utils/paths.ts +++ b/packages/domains-table/src/utils/paths.ts @@ -2,6 +2,7 @@ import config from '@automattic/calypso-config'; import { addQueryArgs } from '@wordpress/url'; import { stringify } from 'qs'; import { ResponseDomain } from './types'; +import type { DomainsTableContext } from '../domains-table/domains-table'; export const emailManagementAllSitesPrefix = '/email/all'; @@ -116,9 +117,17 @@ export function domainManagementAllRoot() { export function domainManagementEditContactInfo( siteName: string, domainName: string, - relativeTo: string | null = null + relativeTo: string | null = null, + context?: DomainsTableContext ) { - return domainManagementEditBase( siteName, domainName, 'edit-contact-info', relativeTo ); + switch ( context ) { + case 'site': + return `/overview/site-domain/contact-info/edit/${ domainName }/${ siteName }`; + case 'domains': + return `${ domainManagementAllRoot() }/contact-info/edit/${ domainName }/${ siteName }`; + default: + return domainManagementEditBase( siteName, domainName, 'edit-contact-info', relativeTo ); + } } export function domainMappingSetup( @@ -193,16 +202,23 @@ export function isUnderEmailManagementAll( path: string ) { export function domainManagementDNS( siteName: string, domainName: string, - isHostingOverview?: boolean + context?: DomainsTableContext ) { - if ( isHostingOverview ) { - return `/overview/site-domain/domain/${ domainName }/dns/${ siteName }`; + switch ( context ) { + case 'site': + return `/overview/site-domain/domain/${ domainName }/dns/${ siteName }`; + case 'domains': + return `${ domainManagementAllRoot() }/overview/${ domainName }/dns/${ siteName }`; + default: + return domainManagementEditBase( siteName, domainName, 'dns' ); } - - return domainManagementEditBase( siteName, domainName, 'dns' ); } -export function emailManagementEdit( siteSlug: string, domainName: string ) { +export function emailManagementEdit( + siteSlug: string, + domainName: string, + context?: DomainsTableContext +) { // Encodes only real domain names and not parameter placeholders if ( domainName && ! String( domainName ).startsWith( ':' ) ) { // Encodes domain names so addresses with slashes in the path (e.g. used in site redirects) don't break routing. @@ -210,5 +226,12 @@ export function emailManagementEdit( siteSlug: string, domainName: string ) { domainName = encodeURIComponent( encodeURIComponent( domainName ) ); } - return '/email/' + domainName + '/manage/' + siteSlug; + switch ( context ) { + case 'site': + return `/overview/site-domain/email/${ domainName }/${ siteSlug }`; + case 'domains': + return `${ domainManagementAllRoot() }/email/${ domainName }/${ siteSlug }`; + default: + return '/email/' + domainName + '/manage/' + siteSlug; + } }