Skip to content

Commit

Permalink
Add domain management restrictions for Gravatar domains
Browse files Browse the repository at this point in the history
  • Loading branch information
gius80 committed May 10, 2024
1 parent 4ba0909 commit 5a7afdf
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useTranslate } from 'i18n-calypso';
import { GravatarDomainCardProps } from './types';

const GravatarDomainCard = ( props: GravatarDomainCardProps ) => {
const translate = useTranslate();
const { selectedDomainName } = props;

return (
<div>
<div>
<p>{ translate( 'Placeholder text for Gravatar domain card.' ) }</p>
<p>{ selectedDomainName }</p>
</div>
</div>
);
};

export default GravatarDomainCard;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type GravatarDomainCardProps = {
selectedDomainName: string;
};
47 changes: 35 additions & 12 deletions client/my-sites/domains/domain-management/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import DomainDiagnosticsCard from './cards/domain-diagnostics-card';
import DomainForwardingCard from './cards/domain-forwarding-card';
import DomainOnlyConnectCard from './cards/domain-only-connect';
import DomainSecurityDetails from './cards/domain-security-details';
import GravatarDomainCard from './cards/gravatar-domain';
import NameServersCard from './cards/name-servers-card';
import RegisteredDomainDetails from './cards/registered-domain-details';
import SiteRedirectCard from './cards/site-redirect-card';
Expand Down Expand Up @@ -176,7 +177,8 @@ const Settings = ( {
const renderStatusSection = () => {
if (
! ( domain && selectedSite?.options?.is_domain_only ) ||
domain.type === domainTypes.TRANSFER
domain.type === domainTypes.TRANSFER ||
domain.isGravatarDomain
) {
return null;
}
Expand All @@ -197,6 +199,22 @@ const Settings = ( {
);
};

const renderGravatarSection = () => {
if ( ! ( domain && domain.isGravatarDomain ) ) {
return null;
}

return (
<Accordion
title={ translate( 'Gravatar domain card', { textOnly: true } ) }
key="status"
expanded
>
<GravatarDomainCard selectedDomainName={ domain.domain } />
</Accordion>
);
};

const renderDetailsSection = () => {
if ( ! domain ) {
return null;
Expand Down Expand Up @@ -295,10 +313,7 @@ const Settings = ( {
};

const renderNameServersSection = () => {
if ( ! domain ) {
return null;
}
if ( domain.type !== domainTypes.REGISTERED ) {
if ( ! domain || domain.type !== domainTypes.REGISTERED || domain.isGravatarDomain ) {
return null;
}

Expand Down Expand Up @@ -408,7 +423,8 @@ const Settings = ( {
domain.type === domainTypes.SITE_REDIRECT ||
domain.transferStatus === transferStatus.PENDING_ASYNC ||
! domain.canManageDnsRecords ||
! domains
! domains ||
domain.isGravatarDomain
) {
return null;
}
Expand Down Expand Up @@ -449,7 +465,8 @@ const Settings = ( {
! domain ||
domain.type === domainTypes.SITE_REDIRECT ||
domain.transferStatus === transferStatus.PENDING_ASYNC ||
! domain.canManageDnsRecords
! domain.canManageDnsRecords ||
domain.isGravatarDomain
) {
return null;
}
Expand Down Expand Up @@ -481,7 +498,7 @@ const Settings = ( {
};

const renderSetAsPrimaryDomainSection = () => {
if ( ! domain ) {
if ( ! domain || domain.isGravatarDomain ) {
return null;
}
return <SetAsPrimary domain={ domain } selectedSite={ selectedSite } key="set-as-primary" />;
Expand Down Expand Up @@ -681,7 +698,8 @@ const Settings = ( {
! domain ||
domain.type !== domainTypes.REGISTERED ||
domain.registrar !== 'KS_RAM' ||
! domain.canManageDnsRecords
! domain.canManageDnsRecords ||
domain.isGravatarDomain
) {
return null;
}
Expand All @@ -706,6 +724,7 @@ const Settings = ( {
<>
{ renderUnverifiedEmailNotice() }
{ renderStatusSection() }
{ renderGravatarSection() }
{ renderDetailsSection() }
{ renderTranferInMappedDomainSection() }
{ renderDiagnosticsSection() }
Expand All @@ -723,14 +742,18 @@ const Settings = ( {

const renderSettingsCards = () => {
if ( ! domain ) {
return undefined;
return null;
}
return (
<>
<DomainEmailInfoCard selectedSite={ selectedSite } domain={ domain } />
{ ! domain.isGravatarDomain && (
<DomainEmailInfoCard selectedSite={ selectedSite } domain={ domain } />
) }
<DomainTransferInfoCard selectedSite={ selectedSite } domain={ domain } />
<DomainDeleteInfoCard selectedSite={ selectedSite } domain={ domain } />
<DomainDisconnectCard selectedSite={ selectedSite } domain={ domain } />
{ ! domain.isGravatarDomain && (
<DomainDisconnectCard selectedSite={ selectedSite } domain={ domain } />
) }
</>
);
};
Expand Down

0 comments on commit 5a7afdf

Please sign in to comment.