import { getPlan, PLAN_BUSINESS } from '@automattic/calypso-products'; import { localizeUrl } from '@automattic/i18n-utils'; import { Modal } from '@wordpress/components'; 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, UrlData } from '../types'; import type { ImporterPlatform } from 'calypso/lib/importer/types'; import type * as React from 'react'; /* eslint-disable wpcalypso/jsx-classname-namespace */ interface DetailsProps { platform: ImporterPlatform; fromSite: UrlData[ 'url' ]; onClose: () => void; } export const coveredPlatforms = [ 'wix', 'squarespace', 'blogger', 'wordpress', 'medium' ]; const platformFeatureList: { [ key: string ]: { [ key: string ]: FeatureName[] } } = { wix: { supported: [ 'posts', 'pages_static', 'blocks', 'images' ], unsupported: [ 'styles', 'themes', 'colors', 'fonts' ], }, squarespace: { supported: [ 'posts', 'pages_static', 'blocks', 'images' ], unsupported: [ 'styles', 'themes', 'colors', 'fonts' ], }, blogger: { supported: [ 'posts', 'photos', 'videos', 'files' ], unsupported: [ 'styles', 'themes', 'colors', 'fonts' ], }, wordpress: { supported: [ 'posts', 'pages' ], unsupported: [ 'themes', 'plugins', 'styles', 'fonts', 'colors' ], }, medium: { supported: [ 'posts', 'tags' ], unsupported: [ 'styles', 'themes', 'colors', 'fonts' ], }, }; const ImportPlatformDetails: React.FunctionComponent< DetailsProps > = ( data ) => { const { __ } = useI18n(); const { platform, onClose, fromSite } = data; const learnMoreHref = localizeUrl( 'https://wordpress.com/support/import/' ); const plan = getPlan( PLAN_BUSINESS ); const translatedFeatureList: FeatureList = { tags: __( 'Tags' ), posts: __( 'Blog posts' ), pages: __( 'Pages' ), pages_static: __( 'Static pages' ), blocks: __( 'Various blocks and features' ), images: __( 'Images' ), photos: __( 'Photos' ), videos: __( 'Videos' ), files: __( 'Other embedded files' ), styles: __( 'Site styles' ), themes: __( 'Themes' ), themes_custom: __( 'Custom themes' ), colors: __( 'Colors' ), fonts: __( 'Fonts' ), plugins: __( 'Plugins' ), }; const getTitle = ( _platform: ImporterPlatform ): string => { switch ( _platform ) { case 'wix': return __( 'Importing content from Wix' ); case 'squarespace': return __( 'Importing content from Squarespace' ); case 'blogger': return __( 'Importing content from Blogger' ); case 'wordpress': return __( 'Importing content from self-hosted WordPress to WordPress.com' ); case 'medium': return __( 'Importing content from Medium' ); default: return ''; } }; const getInfo = ( _platform: ImporterPlatform, _fromSite: UrlData[ 'url' ] ): string => { switch ( _platform ) { case 'wix': return __( "Our Wix content importer is the quickest way to move your content. Simply click 'Import your content' and provide your site's web address (called a URL). Once the import is complete, you'll have a site that's pre-filled with your content." ); case 'squarespace': return __( "Our Squarespace content importer is the quickest way to move your content. Simply export the contents from Squarespace as a WordPress format XML file, then click 'Import your content' and upload it to our importer." ); case 'blogger': return __( "Our Blogger content importer is the quickest way to move your content. Simply export the contents from Blogger as a XML file, then click 'Import your content' and upload it to our importer." ); case 'wordpress': if ( _fromSite ) { return __( "Our Self-Hosted WordPress content importer is the quickest way to move your content. After clicking 'Import your content', you will have two options:" ); } return __( 'Our Self-Hosted WordPress content importer is the quickest way to move your content.' ); case 'medium': return __( "Our Medium content importer is the quickest way to move your content. Simply export the contents from Medium as a .ZIP file, then click 'Import your content' and upload it to our importer." ); default: return ''; } }; return (

{ getInfo( platform, fromSite ) }

{ __( 'Learn more' ) } { platform !== 'wordpress' && (

{ createInterpolateElement( __( 'Things we can import:' ), { strong: createElement( 'strong' ), } ) }

    { platformFeatureList[ platform ].supported.map( ( key ) => (
  • { ' ' } { translatedFeatureList[ key as FeatureName ] }
  • ) ) }

{ createInterpolateElement( __( "Things we can't import:" ), { strong: createElement( 'strong' ), } ) }

    { platformFeatureList[ platform ].unsupported.map( ( key ) => (
  • { ' ' } { translatedFeatureList[ key as FeatureName ] }
  • ) ) }
) } { platform === 'wordpress' && (

{ createInterpolateElement( __( 'Import Content only:' ), { strong: createElement( 'strong' ), } ) }

    { platformFeatureList[ platform ].supported.map( ( key ) => (
  • { ' ' } { translatedFeatureList[ key as FeatureName ] }
  • ) ) }
{ /* TODO: is this section / file still relevant? */ } { fromSite && ( <>

{ createInterpolateElement( __( 'Import Everything*:' ), { strong: createElement( 'strong' ), } ) }

    { platformFeatureList[ platform ].supported .concat( platformFeatureList[ platform ].unsupported ) .map( ( key ) => (
  • { ' ' } { translatedFeatureList[ key as FeatureName ] }
  • ) ) }
* { sprintf( /* translators: %(plan)s: name of plan */ __( 'Requires a %(plan)s plan.' ), { plan: plan?.getTitle() ?? '', } ) }
) }
) }
); }; export default ImportPlatformDetails;