Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
phcp committed Jan 10, 2025
1 parent dfab8a9 commit e6e8336
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 45 deletions.
10 changes: 10 additions & 0 deletions client/hosting/overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
DOMAIN_OVERVIEW,
EMAIL_MANAGEMENT,
} from 'calypso/my-sites/domains/domain-management/domain-overview-pane/constants';
import { EDIT_CONTACT_INFO } from 'calypso/my-sites/domains/domain-management/subpage-wrapper/subpages';
import emailController from 'calypso/my-sites/email/controller';
import {
DOTCOM_HOSTING_CONFIG,
Expand Down Expand Up @@ -117,4 +118,13 @@ export default function () {
domainManagementController.domainManagementPaneView( EMAIL_MANAGEMENT ),
],
} );

registerSiteDomainPage( {
path: '/overview/site-domain/contact-info/edit/:domain/:site',
controllers: [
domainManagementController.domainManagementSubpageParams( EDIT_CONTACT_INFO ),
domainManagementController.domainManagementEditContactInfo,
domainManagementController.domainManagementSubpageView,
],
} );
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import { useMergeRefs } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';
import { useTranslate } from 'i18n-calypso';
import { useMemo, useRef } from 'react';
import SiteFavicon from 'calypso/blocks/site-favicon';
import NavigationHeader from 'calypso/components/navigation-header';
import ItemView from 'calypso/layout/hosting-dashboard/item-view';
import * as paths from 'calypso/my-sites/domains/paths';
import { getMigrationStatus } from 'calypso/sites-dashboard/utils';
import SiteIcon from 'calypso/sites/components/sites-dataviews/site-icon';
import { useSiteAdminInterfaceData } from 'calypso/state/sites/hooks';
import {
FEATURE_TO_ROUTE_MAP,
Expand Down Expand Up @@ -145,9 +144,6 @@ const DomainOverviewPane = ( {
} );
}, [ selectedFeature, selectedDomainPreview, inSiteContext, selectedDomain, siteSlug ] );

const isMigrationPending = getMigrationStatus( site ) === 'pending';
const faviconFallback = isMigrationPending ? 'migration' : 'first-grapheme';

return (
<>
{ inSiteContext && (
Expand All @@ -157,7 +153,7 @@ const DomainOverviewPane = ( {
{
label: site.name || selectedDomain,
href: `/overview/${ siteSlug }`,
icon: <SiteFavicon blogId={ site.ID } size={ 24 } fallback={ faviconFallback } />,
icon: <SiteIcon site={ site } viewType="breadcrumb" disableClick />,
},
{
label: selectedDomain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const EditContactInfoPageContent = ( {
}

const backUrl = isUnderDomainManagementAll( currentRoute )
? domainManagementAllOverview( selectedSite?.slug ?? '', selectedDomainName )
? domainManagementAllOverview( selectedSite?.slug ?? '', selectedDomainName, currentRoute )
: domainManagementEdit( selectedSite?.slug ?? '', selectedDomainName, currentRoute );

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import page from '@automattic/calypso-router';
import { Card } from '@automattic/components';
import { localizeUrl } from '@automattic/i18n-utils';
import { useTranslate } from 'i18n-calypso';
import { useEffect, useMemo } from 'react';
import { useEffect } from 'react';
import { connect } from 'react-redux';
import TwoColumnsLayout from 'calypso/components/domains/layout/two-columns-layout';
import ExternalLink from 'calypso/components/external-link';
Expand All @@ -12,11 +12,7 @@ import BodySectionCssClass from 'calypso/layout/body-section-css-class';
import { getSelectedDomain } from 'calypso/lib/domains';
import DomainMainPlaceholder from 'calypso/my-sites/domains/domain-management/components/domain/main-placeholder';
import DomainHeader from 'calypso/my-sites/domains/domain-management/components/domain-header';
import {
domainManagementEdit,
domainManagementList,
isUnderDomainManagementAll,
} from 'calypso/my-sites/domains/paths';
import { domainManagementEdit, domainManagementList } from 'calypso/my-sites/domains/paths';
import getCurrentRoute from 'calypso/state/selectors/get-current-route';
import isRequestingWhois from 'calypso/state/selectors/is-requesting-whois';
import { IAppState } from 'calypso/state/types';
Expand All @@ -31,6 +27,7 @@ const EditContactInfoPage = ( {
isRequestingWhois,
selectedDomainName,
selectedSite,
context = { showPageHeader: true },
}: EditContactInfoPageProps ) => {
const translate = useTranslate();

Expand All @@ -47,13 +44,8 @@ const EditContactInfoPage = ( {
return ! getSelectedDomain( { domains, selectedDomainName } ) || isRequestingWhois;
};

const isAllDomainManagementScreen = useMemo(
() => isUnderDomainManagementAll( currentRoute ),
[ currentRoute ]
);

const renderHeader = () => {
if ( ! selectedSite || isAllDomainManagementScreen ) {
if ( ! selectedSite ) {
return null;
}

Expand All @@ -65,7 +57,7 @@ const EditContactInfoPage = ( {

const items = [
{
label: isAllDomainManagementScreen ? translate( 'All Domains' ) : translate( 'Domains' ),
label: translate( 'Domains' ),
href: domainManagementList(
selectedSite?.slug,
currentRoute,
Expand Down Expand Up @@ -101,7 +93,7 @@ const EditContactInfoPage = ( {
/>
);

return isAllDomainManagementScreen ? <Card>{ pageContent }</Card> : pageContent;
return <Card>{ pageContent }</Card>;
};

const renderSidebar = () => {
Expand Down Expand Up @@ -162,7 +154,7 @@ const EditContactInfoPage = ( {
return (
<Main className="edit-contact-info-page" wideLayout>
<BodySectionCssClass bodyClass={ [ 'edit__body-white' ] } />
{ renderHeader() }
{ context?.showPageHeader && renderHeader() }
<TwoColumnsLayout content={ renderContent() } sidebar={ renderSidebar() } />
</Main>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export type EditContactInfoPageProps = {
isRequestingWhois: boolean;
selectedDomainName: string;
selectedSite: SiteDetails | null;
context?: {
showPageHeader?: boolean;
};
};

export type EditContactInfoPageContentProps = {
Expand Down
3 changes: 2 additions & 1 deletion client/my-sites/domains/domain-management/list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@

// The `/domains/manage` page
// Generic domains table styles should go in `packages/domains-table/src/domains-table/style.scss`
.is-bulk-all-domains-page .layout__content {
.is-bulk-all-domains-page .layout__content,
.is-domain-in-site-context .layout__content {
overflow: auto;
.main {
.navigation-header {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { SiteExcerptData } from '@automattic/sites';
import { useTranslate } from 'i18n-calypso';
import { useMemo } from 'react';
import NavigationHeader from 'calypso/components/navigation-header';
import { domainManagementOverviewRoot } from 'calypso/my-sites/domains/paths';
import { domainManagementAllOverview } from 'calypso/my-sites/domains/paths';
import SiteIcon from 'calypso/sites/components/sites-dataviews/site-icon';
import { useSelector } from 'calypso/state';
import { getSite } from 'calypso/state/sites/selectors';
import { CustomHeaderComponentType } from './custom-header-component-type';
Expand All @@ -12,13 +14,18 @@ const ContactInformationHeader: CustomHeaderComponentType = ( {
inSiteContext,
} ) => {
const translate = useTranslate();
const site = useSelector( ( state ) => getSite( state, selectedSiteSlug ) );
const site = useSelector( ( state ) => getSite( state, selectedSiteSlug ) as SiteExcerptData );

const navigationItems = useMemo( () => {
const baseNavigationItems = [
{
label: selectedDomainName,
href: `${ domainManagementOverviewRoot() }/${ selectedDomainName }/${ selectedSiteSlug }`,
href: domainManagementAllOverview(
selectedSiteSlug,
selectedDomainName,
null,
inSiteContext
),
},
{
label: translate( 'Contact information' ),
Expand All @@ -30,6 +37,7 @@ const ContactInformationHeader: CustomHeaderComponentType = ( {
{
label: site?.name || selectedDomainName,
href: `/overview/${ selectedSiteSlug }`,
icon: <SiteIcon site={ site } viewType="breadcrumb" disableClick />,
},
...baseNavigationItems,
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import clsx from 'clsx';
import NavigationHeader from 'calypso/components/navigation-header';
import BodySectionCssClass from 'calypso/layout/body-section-css-class';
import { domainManagementAllOverview } from 'calypso/my-sites/domains/paths';
import { getSubpageParams } from './subpages';
import './style.scss';
Expand All @@ -24,6 +25,7 @@ const SubpageWrapper = ( {
if ( CustomHeader ) {
return (
<div className={ clsx( 'subpage-wrapper', `subpage-wrapper--${ subpageKey }` ) }>
<BodySectionCssClass bodyClass={ [ 'is-domain-in-site-context' ] } />
<CustomHeader
selectedDomainName={ domainName }
selectedSiteSlug={ siteName }
Expand All @@ -48,6 +50,7 @@ const SubpageWrapper = ( {

return (
<div className={ clsx( 'subpage-wrapper', `subpage-wrapper--${ subpageKey }` ) }>
<BodySectionCssClass bodyClass={ [ 'is-domain-in-site-context' ] } />
<NavigationHeader
className="subpage-wrapper__header"
navigationItems={ breadcrumbItems }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
}
}


.email-forwards-add,
.edit-contact-info-page {
.button {
padding: 10px 24px;
border-radius: 4px;
}
}

.email-forwards-add {
.card {
border-radius: 4px;
Expand All @@ -50,11 +59,6 @@
margin-top: 0;
margin-bottom: 16px;
}

.button {
padding: 10px 24px;
border-radius: 4px;
}
}

.edit-contact-info-page {
Expand All @@ -66,6 +70,10 @@
.contact-details-form-fields {
padding: 0;
}

.contact-details-form-fields__submit-button {
margin-right: 16px;
}
}

.dns-records {
Expand Down Expand Up @@ -194,14 +202,17 @@
}
}

.is-bulk-all-domains-page .layout__content .main {
.is-bulk-all-domains-page .layout__content .main,
.is-domain-in-site-context .layout__content .main {
.navigation-header {
&__breadcrumb,
&__title {
border-block-end: none;
}

&__breadcrumb {
padding-top: 24px;

@media ( max-width: $break-medium ) {
padding-top: 16px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const SUBPAGE_TO_PARAMS_MAP: Record< string, SubpageWrapperParamsType > = {
},
[ EDIT_CONTACT_INFO ]: {
CustomHeader: ContactInformationHeader,
showPageHeader: false,
},
[ ADD_DNS_RECORD ]: {
CustomHeader: DnsRecordHeader,
Expand Down
32 changes: 23 additions & 9 deletions client/my-sites/domains/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@ function domainManagementTransferBase(
}

export function isUnderDomainManagementAll( path ) {
return path?.startsWith( domainManagementAllRoot() + '/' );
return (
path?.startsWith( domainManagementAllRoot() + '/' ) ||
path?.startsWith( domainSiteContextRoot() + '/' )
);
}

export function isUnderDomainManagementOverview( path ) {
return (
path?.startsWith( domainManagementOverviewRoot() + '/' ) ||
path?.startsWith( domainSiteContextBasePath() + '/' )
path?.startsWith( domainSiteContextRoot() + '/domain/' )
);
}

export function isUnderDomainSiteContext( path ) {
return path?.startsWith( domainSiteContextBasePath() + '/' );
return path?.startsWith( domainSiteContextRoot() + '/' );
}

export function domainAddNew( siteName, searchTerm ) {
Expand Down Expand Up @@ -97,7 +100,7 @@ export function domainManagementOverviewRoot() {
return domainManagementAllRoot() + '/overview';
}

export function domainSiteContextBasePath() {
export function domainSiteContextRoot() {
return '/overview/site-domain';
}

Expand Down Expand Up @@ -153,8 +156,17 @@ export function domainManagementEditContactInfo( siteName, domainName, relativeT
* @param {string} siteName
* @param {string} domainName
*/
export function domainManagementAllOverview( siteName, domainName ) {
return domainManagementOverviewRoot() + '/' + domainName + '/' + siteName;
export function domainManagementAllOverview(
siteName,
domainName,
relativeTo = null,
inSiteContext = false
) {
if ( inSiteContext || isUnderDomainSiteContext( relativeTo ) ) {
return `${ domainSiteContextRoot() }/domain/${ domainName }/${ siteName }`;
}

return `${ domainManagementOverviewRoot() }/${ domainName }/${ siteName }`;
}

/**
Expand All @@ -164,9 +176,11 @@ export function domainManagementAllOverview( siteName, domainName ) {
*/
export function domainManagementAllEditContactInfo( siteName, domainName, relativeTo = null ) {
const pathSegment = `contact-info/edit/${ domainName }/${ siteName }`;
return isUnderDomainSiteContext( relativeTo )
? `${ domainSiteContextBasePath() }/${ domainManagementAllRoot() }/${ pathSegment }`
: `${ domainManagementAllRoot() }/${ pathSegment }`;
const rootPath = isUnderDomainSiteContext( relativeTo )
? domainSiteContextRoot()
: domainManagementAllRoot();

return `${ rootPath }/${ pathSegment }`;
}

export function domainManagementAllEditSelectedContactInfo() {
Expand Down
Loading

0 comments on commit e6e8336

Please sign in to comment.