Skip to content

Commit

Permalink
Move importer types into clientlib importer (#91690)
Browse files Browse the repository at this point in the history
This is the last piece of moving all of the importer definitions into a single area
  • Loading branch information
markbiek authored Jun 12, 2024
1 parent e5577a0 commit 27fa228
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion client/blocks/import/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
type ImporterConfigPriority,
} from 'calypso/lib/importer/importer-config';
import ImporterLogo from 'calypso/my-sites/importer/importer-logo';
import type { ImporterPlatform } from '../types';
import type { ImporterPlatform } from 'calypso/lib/importer/types';
import './style.scss';

const trackEventName = 'calypso_signup_step_start';
Expand Down
3 changes: 2 additions & 1 deletion client/blocks/import/ready/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { sprintf } from '@wordpress/i18n';
import { useI18n } from '@wordpress/react-i18n';
import React, { useEffect, useState } from 'react';
import { ONBOARD_STORE } from 'calypso/landing/stepper/stores';
import { UrlData, GoToStep, RecordTracksEvent, ImporterPlatform } from '../types';
import { UrlData, GoToStep, RecordTracksEvent } from '../types';
import { convertPlatformName, convertToFriendlyWebsiteName } from '../util';
import ImportPlatformDetails, { coveredPlatforms } from './platform-details';
import ImportPreview from './preview';
import type { OnboardSelect } from '@automattic/data-stores';
import type { ImporterPlatform } from 'calypso/lib/importer/types';
import './style.scss';

const trackEventName = 'calypso_signup_step_start';
Expand Down
3 changes: 2 additions & 1 deletion client/blocks/import/ready/platform-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { createElement, createInterpolateElement } from '@wordpress/element';
import { sprintf } from '@wordpress/i18n';
import { Icon, close, check } from '@wordpress/icons';
import { useI18n } from '@wordpress/react-i18n';
import { FeatureName, FeatureList, ImporterPlatform, UrlData } from '../types';
import { FeatureName, FeatureList, UrlData } from '../types';
import type { ImporterPlatform } from 'calypso/lib/importer/types';
import type * as React from 'react';

/* eslint-disable wpcalypso/jsx-classname-namespace */
Expand Down
26 changes: 2 additions & 24 deletions client/blocks/import/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { type ImporterPlatform } from 'calypso/lib/importer/types';

export type GoToStep = (
stepName: string,
stepSectionName?: string,
Expand Down Expand Up @@ -45,27 +47,3 @@ export type FeatureName =
| 'plugins';

export type FeatureList = { [ key in FeatureName ]: string };

// List of supported importer platforms (most important)
export type ImporterMainPlatform =
| 'blogger'
| 'medium'
| 'squarespace'
| 'wordpress'
| 'wix'
| ImporterPlatformOther;
// List of supported importer platforms (others)
export type ImporterPlatformOther =
| 'blogroll'
| 'ghost'
| 'livejournal'
| 'movabletype'
| 'tumblr'
| 'xanga'
| 'substack';
export type ImporterPlatformExtra = 'godaddy-central';
export type ImporterPlatform =
| ImporterMainPlatform
| ImporterPlatformOther
| ImporterPlatformExtra
| 'unknown';
2 changes: 1 addition & 1 deletion client/blocks/import/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { capitalize } from 'lodash';
import { ImporterPlatform } from './types';
import type { ImporterPlatform } from 'calypso/lib/importer/types';

export const CAPTURE_URL_RGX =
/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.][a-z0-9]+)*\.[a-z]{2,63}(:[0-9]{1,5})?(\/.*)?$/i;
Expand Down
2 changes: 1 addition & 1 deletion client/landing/stepper/declarative-flow/import-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Design, isAssemblerDesign, isAssemblerSupported } from '@automattic/des
import { IMPORT_FOCUSED_FLOW } from '@automattic/onboarding';
import { useDispatch, useSelect } from '@wordpress/data';
import { useEffect } from 'react';
import { ImporterMainPlatform } from 'calypso/blocks/import/types';
import { isTargetSitePlanCompatible } from 'calypso/blocks/importer/util';
import useAddTempSiteToSourceOptionMutation from 'calypso/data/site-migration/use-add-temp-site-mutation';
import { useSourceMigrationStatusQuery } from 'calypso/data/site-migration/use-source-migration-status-query';
Expand All @@ -13,6 +12,7 @@ import { useQuery } from 'calypso/landing/stepper/hooks/use-query';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { useSiteSlugParam } from 'calypso/landing/stepper/hooks/use-site-slug-param';
import { ONBOARD_STORE } from 'calypso/landing/stepper/stores';
import { ImporterMainPlatform } from 'calypso/lib/importer/types';
import CreateSite from './internals/steps-repository/create-site';
import DesignSetup from './internals/steps-repository/design-setup';
import ImportStep from './internals/steps-repository/import';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { IMPORT_HOSTED_SITE_FLOW } from '@automattic/onboarding';
import { useDispatch, useSelect } from '@wordpress/data';
import { useEffect, useLayoutEffect } from 'react';
import localStorageHelper from 'store';
import { ImporterMainPlatform } from 'calypso/blocks/import/types';
import { isTargetSitePlanCompatible } from 'calypso/blocks/importer/util';
import CreateSite from 'calypso/landing/stepper/declarative-flow/internals/steps-repository/create-site';
import MigrationError from 'calypso/landing/stepper/declarative-flow/internals/steps-repository/migration-error';
Expand All @@ -11,6 +10,7 @@ import { useIsSiteAdmin } from 'calypso/landing/stepper/hooks/use-is-site-admin'
import { useQuery } from 'calypso/landing/stepper/hooks/use-query';
import { useSiteSlugParam } from 'calypso/landing/stepper/hooks/use-site-slug-param';
import { ONBOARD_STORE, USER_STORE } from 'calypso/landing/stepper/stores';
import { ImporterMainPlatform } from 'calypso/lib/importer/types';
import { useSite } from '../hooks/use-site';
import { useLoginUrl } from '../utils/path';
import Import from './internals/steps-repository/import';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { isEnabled } from '@automattic/calypso-config';
import { addQueryArgs } from '@wordpress/url';
import { camelCase } from 'lodash';
import { ImporterPlatform } from 'calypso/blocks/import/types';
import {
getImporterUrl,
getWpComOnboardingUrl,
getWpOrgImporterUrl,
} from 'calypso/blocks/import/util';
import { WPImportOption } from 'calypso/blocks/importer/wordpress/types';
import { getImporterEngines } from 'calypso/lib/importer/importer-config';
import { ImporterPlatform } from 'calypso/lib/importer/types';
import { BASE_ROUTE } from './config';

export function getFinalImporterUrl(
Expand Down
2 changes: 1 addition & 1 deletion client/landing/stepper/declarative-flow/site-setup-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Design, isAssemblerDesign, isAssemblerSupported } from '@automattic/des
import { useSelect, useDispatch } from '@wordpress/data';
import { useEffect } from 'react';
import wpcomRequest from 'wpcom-proxy-request';
import { ImporterMainPlatform } from 'calypso/blocks/import/types';
import { isTargetSitePlanCompatible } from 'calypso/blocks/importer/util';
import { useQuery } from 'calypso/landing/stepper/hooks/use-query';
import { ImporterMainPlatform } from 'calypso/lib/importer/types';
import { addQueryArgs } from 'calypso/lib/route';
import { useDispatch as reduxDispatch, useSelector } from 'calypso/state';
import { recordTracksEvent } from 'calypso/state/analytics/actions';
Expand Down
2 changes: 1 addition & 1 deletion client/lib/importer/importer-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import config from '@automattic/calypso-config';
import { TranslateResult, translate } from 'i18n-calypso';
import { filter, orderBy, values } from 'lodash';
import { type ImporterOption } from 'calypso/blocks/import/list';
import { type ImporterPlatform } from 'calypso/blocks/import/types';
import InlineSupportLink from 'calypso/components/inline-support-link';
import { appStates } from 'calypso/state/imports/constants';
import type { ImporterPlatform } from 'calypso/lib/importer/types';

export interface ImporterOptionalURL {
title: TranslateResult;
Expand Down
23 changes: 23 additions & 0 deletions client/lib/importer/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// List of supported importer platforms (most important)
export type ImporterMainPlatform =
| 'blogger'
| 'medium'
| 'squarespace'
| 'wordpress'
| 'wix'
| ImporterPlatformOther;
// List of supported importer platforms (others)
export type ImporterPlatformOther =
| 'blogroll'
| 'ghost'
| 'livejournal'
| 'movabletype'
| 'tumblr'
| 'xanga'
| 'substack';
export type ImporterPlatformExtra = 'godaddy-central';
export type ImporterPlatform =
| ImporterMainPlatform
| ImporterPlatformOther
| ImporterPlatformExtra
| 'unknown';

0 comments on commit 27fa228

Please sign in to comment.