Skip to content

Commit

Permalink
Domains: Fix second-level domains in some domain availability error n…
Browse files Browse the repository at this point in the history
…otices (#79200)

* Fix second-level domains in some domain availability notices

* Add missing parameter in `getAvailabilityNotice` call

* Remove unnecessary code
  • Loading branch information
leonardost authored and timur987 committed Jul 20, 2023
1 parent d9dec0b commit 2d008b1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions client/components/domains/domain-search-results/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import FeaturedDomainSuggestions from 'calypso/components/domains/featured-domai
import MaterialIcon from 'calypso/components/material-icon';
import Notice from 'calypso/components/notice';
import { isDomainMappingFree, isNextDomainFree } from 'calypso/lib/cart-values/cart-items';
import { getTld } from 'calypso/lib/domains';
import { domainAvailability } from 'calypso/lib/domains/constants';
import { DESIGN_TYPE_STORE } from 'calypso/signup/constants';
import { getDesignType } from 'calypso/state/signup/steps/design-type/selectors';
Expand Down Expand Up @@ -65,6 +64,7 @@ class DomainSearchResults extends Component {
lastDomainIsTransferrable,
lastDomainStatus,
lastDomainSearched,
lastDomainTld,
selectedSite,
translate,
isDomainOnly,
Expand Down Expand Up @@ -138,7 +138,7 @@ class DomainSearchResults extends Component {
? translate(
'{{strong}}.%(tld)s{{/strong}} domains are not available for registration on WordPress.com.',
{
args: { tld: getTld( domain ) },
args: { tld: lastDomainTld },
components: {
strong: <strong />,
},
Expand Down Expand Up @@ -179,7 +179,7 @@ class DomainSearchResults extends Component {
'{{strong}}.%(tld)s{{/strong}} domains are temporarily not offered on WordPress.com. ' +
'Please try again later or choose a different extension.',
{
args: { tld: getTld( domain ) },
args: { tld: lastDomainTld },
components: { strong: <strong /> },
}
);
Expand Down
3 changes: 3 additions & 0 deletions client/components/domains/register-domain-step/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ class RegisterDomainStep extends Component {

this.setState( {
exactMatchDomain: domainChecked,
lastDomainTld: result.tld,
lastDomainStatus: availabilityStatus,
lastDomainIsTransferrable: isDomainTransferrable,
} );
Expand Down Expand Up @@ -1390,6 +1391,7 @@ class RegisterDomainStep extends Component {
lastDomainIsTransferrable,
lastDomainSearched,
lastDomainStatus,
lastDomainTld,
premiumDomains,
} = this.state;

Expand Down Expand Up @@ -1426,6 +1428,7 @@ class RegisterDomainStep extends Component {
isDomainOnly={ this.props.isDomainOnly }
lastDomainSearched={ lastDomainSearched }
lastDomainStatus={ lastDomainStatus }
lastDomainTld={ lastDomainTld }
lastDomainIsTransferrable={ lastDomainIsTransferrable }
onAddMapping={ onAddMapping }
onClickResult={ this.onAddDomain }
Expand Down
5 changes: 1 addition & 4 deletions client/components/domains/transfer-domain-step/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ class TransferDomainStep extends Component {
{ domainName: domain, blogId: get( this.props, 'selectedSite.ID', null ) },
( error, result ) => {
const status = get( result, 'status', error );
const tld = result.tld || getTld( domain );
switch ( status ) {
case domainAvailability.AVAILABLE:
this.setState( { suggestion: result } );
Expand All @@ -542,8 +543,6 @@ class TransferDomainStep extends Component {
} );
break;
case domainAvailability.TLD_NOT_SUPPORTED: {
const tld = getTld( domain );

this.setState( {
notice: this.props.translate(
'This domain appears to be available for registration, however we do not offer registrations or accept transfers for domains ending in {{strong}}.%(tld)s{{/strong}}. ' +
Expand All @@ -563,8 +562,6 @@ class TransferDomainStep extends Component {
case domainAvailability.MAPPABLE:
case domainAvailability.TLD_NOT_SUPPORTED_TEMPORARILY:
case domainAvailability.TLD_NOT_SUPPORTED_AND_DOMAIN_NOT_AVAILABLE: {
const tld = getTld( domain );

this.setState( {
notice: this.props.translate(
"We don't support transfers for domains ending with {{strong}}.%(tld)s{{/strong}}, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function getOptionInfo( {
__(
"We don't support transfers for domains ending with <strong>.%s</strong>, but you can connect it instead."
),
getTld( domain )
availability.tld || getTld( domain )
),
{ strong: createElement( 'strong' ) }
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export function useValidationMessage( domain: string, auth: string, hasDuplicate
validationResult?.status,
null,
true,
'_blank'
'_blank',
validationResult?.tld
);

// final success
Expand Down
2 changes: 2 additions & 0 deletions client/landing/stepper/hooks/use-is-domain-code-valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type DomainLockResponse = {
raw_price?: number;
sale_cost?: number;
currency_code?: string;
tld?: string;
};

type DomainCodePair = { domain: string; auth: string };
Expand All @@ -59,6 +60,7 @@ export function useIsDomainCodeValid( pair: DomainCodePair, queryOptions = {} )
if ( ! isUnlocked ) {
return {
domain: pair.domain,
tld: availability.tld,
status: availability.status,
unlocked: false,
};
Expand Down
5 changes: 3 additions & 2 deletions client/lib/domains/registration/availability-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ function getAvailabilityNotice(
error,
errorData,
isForTransferOnly = false,
linksTarget = '_self'
linksTarget = '_self',
domainTld = ''
) {
const tld = domain ? getTld( domain ) : null;
const tld = domainTld || ( domain ? getTld( domain ) : null );
const { site, maintenanceEndTime, availabilityPreCheck } = errorData || {};

// The message is set only when there is a valid error
Expand Down

0 comments on commit 2d008b1

Please sign in to comment.