Skip to content

Commit

Permalink
Improve Points to WPCOM logics
Browse files Browse the repository at this point in the history
  • Loading branch information
gius80 committed Dec 19, 2024
1 parent a7e9ab9 commit abf2452
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 31 deletions.
4 changes: 4 additions & 0 deletions client/components/inline-support-link/context-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ const contextLinks = {
link: 'https://wordpress.com/support/menus/',
post_id: 59580,
},
nameservers: {
link: 'https://wordpress.com/support/domains/change-name-servers/#changing-name-servers-to-point-to-word-press-com',
post_id: 41383,
},
pages: {
link: 'https://wordpress.com/support/pages/',
post_id: 86,
Expand Down
62 changes: 60 additions & 2 deletions client/my-sites/domains/domain-management/dns/dns-records.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,63 @@ class DnsRecords extends Component {
} );
};

renderNotice = () => {
renderDefaultARecordsNotice = () => {
const { translate } = this.props;

if ( ! this.hasWpcomNameservers() ) {
return null;
}

if ( this.hasDefaultARecords() ) {
return null;
}

return (
<div className="dns-records-notice">
<Icon
icon={ info }
size={ 18 }
className="dns-records-notice__icon gridicon"
viewBox="2 2 20 20"
/>
<div className="dns-records-notice__message">
{ translate(
'Your domain is not using default A records. This means it may not be pointing to your WordPress.com site correctly. To restore default A records, click on the three dots menu and select "Restore default A records".'
) }
</div>
</div>
);
};

renderDefaultCNameRecordNotice = () => {
const { translate } = this.props;

if ( ! this.hasWpcomNameservers() ) {
return null;
}

if ( this.hasDefaultCnameRecord() ) {
return null;
}

return (
<div className="dns-records-notice">
<Icon
icon={ info }
size={ 18 }
className="dns-records-notice__icon gridicon"
viewBox="2 2 20 20"
/>
<div className="dns-records-notice__message">
{ translate(
'Your domain is not using the default WWW CNAME record. This means your WordPress.com may not be reached correctly using the www prefix. To restore the default WWW CNAME record, click on the three dots menu and select "Restore default CNAME record".'
) }
</div>
</div>
);
};

renderExternalNameserversNotice = () => {
const { translate, selectedSite, currentRoute, selectedDomainName, nameservers, domains } =
this.props;

Expand Down Expand Up @@ -267,7 +323,9 @@ class DnsRecords extends Component {
{ selectedDomain?.canManageDnsRecords ? (
<>
<DnsDetails />
{ this.renderNotice() }
{ this.renderExternalNameserversNotice() }
{ this.renderDefaultARecordsNotice() }
{ this.renderDefaultCNameRecordNotice() }
<DnsRecordsList
dns={ dns }
selectedSite={ selectedSite }
Expand Down
19 changes: 1 addition & 18 deletions packages/domains-table/src/domains-table/domains-table-row.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import config from '@automattic/calypso-config';
import { FEATURE_SET_PRIMARY_CUSTOM_DOMAIN } from '@automattic/calypso-products';
import page from '@automattic/calypso-router';
import { PartialDomainData } from '@automattic/data-stores';
import { CheckboxControl } from '@wordpress/components';
import { sprintf } from '@wordpress/i18n';
Expand Down Expand Up @@ -90,23 +88,8 @@ export function DomainsTableRow( { domain }: DomainsTableRowProps ) {
return currentDomainData.owner.replace( / \((?!.*\().+\)$/, '' );
};

const handleSelect = () => {
const isAllDomainManagementEnabled = config.isEnabled( 'calypso/all-domain-management' );

if ( isAllDomainManagementEnabled && isAllSitesView ) {
page.show( domainManagementLink );
return;
}

window.location.href = domainManagementLink;
};

return (
<tr
key={ domain.domain }
className="domains-table__row"
onClick={ domainManagementLink ? handleSelect : undefined }
>
<tr key={ domain.domain } className="domains-table__row">
{ canSelectAnyDomains && (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
<td
Expand Down
1 change: 0 additions & 1 deletion packages/domains-table/src/domains-table/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@

.domains-table__row {
&:has(a.domains-table__domain-name) {
cursor: pointer;

&:hover td {
background-color: #f7faff;
Expand Down
23 changes: 13 additions & 10 deletions packages/domains-table/src/utils/resolve-domain-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DOMAIN_EXPIRATION_AUCTION,
} from '@automattic/urls';
import moment from 'moment';
import InlineSupportLink from 'calypso/components/inline-support-link'; //eslint-disable-line no-restricted-imports
import {
gdprConsentStatus,
transferStatus,
Expand Down Expand Up @@ -503,29 +504,31 @@ export function resolveDomainStatus(
}

if ( domain.transferStatus === transferStatus.COMPLETED && ! domain.pointsToWpcom ) {
const ctaLink = domain.hasWpcomNameservers
? domainMagementDNS( siteSlug as string, domain.domain )
: domainManagementEdit( siteSlug as string, domain.domain, currentRoute, {
nameservers: true,
} );

return {
statusText: translate( 'Action required' ),
statusClass: 'status-success',
status: translate( 'Active' ),
icon: 'info',
noticeText: translate(
'{{strong}}Transfer successful!{{/strong}} To make this domain work with your WordPress.com site you need to {{a}}point it to WordPress.com name servers.{{/a}}',
'{{strong}}Transfer successful!{{/strong}} To make this domain work with your WordPress.com site you need to {{cta}}point it to WordPress.com servers.{{/cta}}',
{
components: {
strong: <strong />,
a: <a href={ ctaLink } onClick={ ( e ) => e.stopPropagation() } />,
cta: domain.hasWpcomNameservers ? (
<InlineSupportLink
supportContext="nameservers"
showSupportModal
showIcon={ false }
/>
) : (
<a href={ domainMagementDNS( siteSlug as string, domain.domain ) } />
),
},
}
),
callToAction: domain.hasWpcomNameservers
? editDNSRecordsCallToAction
: editNameserversCallToAction,
? editNameserversCallToAction
: editDNSRecordsCallToAction,
listStatusWeight: 600,
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/urls/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const DOMAIN_EXPIRATION_REDEMPTION = `${ root }/domains/domain-expiration
export const DOMAIN_RECENTLY_REGISTERED = `${ root }/domains/register-domain/#waiting-for-domain-changes`;
export const DOMAIN_PRICING_AND_AVAILABLE_TLDS = `${ root }/domains/domain-pricing-and-available-tlds/`;
export const DOMAIN_PROMOTIONAL_PRICING_POLICY = `${ root }/domains/domain-pricing-and-available-tlds/#domain-name-promotional-pricing-policy`;
export const DOMAIN_CHANGE_NAME_SERVERS = `${ root }/domains/change-name-servers/#changing-name-servers-to-point-to-word-press-com`;
export const DNS_RECORDS_ADD = `${ root }/domains/custom-dns/add-a-new-dns-record/`;
export const DNS_RECORDS_EDITING_OR_DELETING = `${ root }/domains/custom-dns/edit-or-delete-dns-records/`;
export const DNS_RECORDS_DEFAULT = `${ root }/domains/custom-dns/view-or-restore-default-dns-records/`;
Expand Down

0 comments on commit abf2452

Please sign in to comment.