Skip to content

Commit fd7c1ef

Browse files
katinthehatsiteKateryna Kodonenkosejas
authored
Studio: Pass custom domain to WP.com onboarding flow (#2184)
* This PR passes the custom domain to WP.com onboarding flow if the user uses the custom domain. * If not, we pass the Studio site name. --------- Co-authored-by: Kateryna Kodonenko <kateryna@automattic.com> Co-authored-by: Antonio Sejas <antonio@sejas.es>
1 parent d34bf28 commit fd7c1ef

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

common/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ export const LOCKFILE_WAIT_TIME = 5000;
1717
export const PLAYGROUND_CLI_INACTIVITY_TIMEOUT = 2 * 60 * 1000; // 2 minutes of no output = timeout
1818
export const PLAYGROUND_CLI_MAX_TIMEOUT = 10 * 60 * 1000; // 10 minutes absolute maximum
1919
export const PLAYGROUND_CLI_ACTIVITY_CHECK_INTERVAL = 5 * 1000; // Check for inactivity every 5 seconds
20+
21+
// Custom domains
22+
export const DEFAULT_CUSTOM_DOMAIN_SUFFIX = '.wp.local';

common/lib/domains.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { __ } from '@wordpress/i18n';
2+
import { DEFAULT_CUSTOM_DOMAIN_SUFFIX } from 'common/constants';
23
import { sanitizeFolderName } from './sanitize-folder-name';
34

45
const DOMAIN_PATTERN =
@@ -10,7 +11,7 @@ const DOMAIN_PATTERN =
1011
export const generateCustomDomainFromSiteName = ( siteName: string ): string => {
1112
const domainBase = sanitizeFolderName( siteName );
1213

13-
return `${ domainBase }.wp.local`;
14+
return `${ domainBase }${ DEFAULT_CUSTOM_DOMAIN_SUFFIX }`;
1415
};
1516

1617
export const getDomainNameValidationError = (

src/modules/sync/components/create-button.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { __ } from '@wordpress/i18n';
2+
import { DEFAULT_CUSTOM_DOMAIN_SUFFIX } from 'common/constants';
23
import { ArrowIcon } from 'src/components/arrow-icon';
34
import Button, { ButtonVariant } from 'src/components/button';
45
import offlineIcon from 'src/components/offline-icon';
@@ -33,10 +34,13 @@ export const CreateButton = ( {
3334
<Button
3435
onClick={ () => {
3536
onClick?.();
37+
const suggestedName = selectedSite.customDomain
38+
? selectedSite.customDomain.replace( DEFAULT_CUSTOM_DOMAIN_SUFFIX, '' )
39+
: selectedSite.name;
3640
getIpcApi().openURL(
3741
`https://wordpress.com/setup/new-hosted-site?ref=studio&section=studio-sync&showDomainStep&studioSiteId=${
3842
selectedSite.id
39-
}&new=${ encodeURIComponent( selectedSite.name ) }`
43+
}&new=${ encodeURIComponent( suggestedName ) }`
4044
);
4145
} }
4246
variant={ variant }

0 commit comments

Comments
 (0)