Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses TLD to check for subdomain status for Mapping #98864

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
stepsHeading,
stepSlug,
} from 'calypso/components/domains/connect-domain-step/constants';
import { isSubdomain } from 'calypso/lib/domains';
import { domainManagementDns } from 'calypso/my-sites/domains/paths';
import { getSelectedSite } from 'calypso/state/ui/selectors';
import ConnectDomainStepWrapper from './connect-domain-step-wrapper';
Expand All @@ -26,16 +25,18 @@ export default function ConnectDomainStepSuggestedStart( {
onNextStep,
progressStepList,
setPage,
domainSetupInfo,
} ) {
const { __ } = useI18n();
const { data } = domainSetupInfo;
const selectedSite = useSelector( getSelectedSite );
const goToDnsRecordsPage = () => page( domainManagementDns( selectedSite?.slug, domain ) );
const firstStep = isSubdomain( domain )
const firstStep = data?.is_subdomain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would data be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically never, since the state is initialized with the default object

const [ domainSetupInfo, setDomainSetupInfo ] = useState( defaultDomainSetupInfo );

In cases like this I lean towards generous with safety checks like ?., since it has no impact on the logic or performance, but if it was implemented differently, not having the ?. could throw an error.

Would you rather it be a more strict check?

? stepSlug.SUBDOMAIN_ADVANCED_START
: stepSlug.ADVANCED_START;
const switchToAdvancedSetup = () => setPage( firstStep );

const message = isSubdomain( domain )
const message = data?.is_subdomain
? __(
'The easiest way to connect your subdomain is by changing NS records. But if you are unable to do this, then switch to our <a>advanced setup</a>, using A & CNAME records.'
)
Expand Down Expand Up @@ -130,4 +131,5 @@ ConnectDomainStepSuggestedStart.propTypes = {
onNextStep: PropTypes.func.isRequired,
progressStepList: PropTypes.object.isRequired,
setPage: PropTypes.func.isRequired,
domainSetupInfo: PropTypes.object.isRequired,
};
1 change: 1 addition & 0 deletions client/components/domains/connect-domain-step/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const defaultDomainSetupInfo = {
data: {
default_ip_addresses: [ '192.0.78.24', '192.0.78.25' ],
wpcom_name_servers: [ 'ns1.wordpress.com', 'ns2.wordpress.com', 'ns3.wordpress.com' ],
is_subdomain: false,
},
} as const;

Expand Down