File size: 7,372 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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 (
		<Modal
			className="components-modal-new__frame import__details-modal"
			title={ getTitle( platform ) }
			onRequestClose={ onClose }
		>
			<div className="import__details-modal-content">
				<p>{ getInfo( platform, fromSite ) }</p>

				<a
					className="import__details-learn-more"
					href={ learnMoreHref }
					target="_blank"
					rel="noopener noreferrer"
				>
					{ __( 'Learn more' ) }
				</a>

				{ platform !== 'wordpress' && (
					<div className="import__details-features">
						<p>
							{ createInterpolateElement( __( 'Things we <strong>can</strong> import:' ), {
								strong: createElement( 'strong' ),
							} ) }
						</p>
						<ul className="import__details-list">
							{ platformFeatureList[ platform ].supported.map( ( key ) => (
								<li key={ key }>
									<Icon size={ 20 } icon={ check } />{ ' ' }
									{ translatedFeatureList[ key as FeatureName ] }
								</li>
							) ) }
						</ul>

						<p>
							{ createInterpolateElement( __( "Things we <strong>can't</strong> import:" ), {
								strong: createElement( 'strong' ),
							} ) }
						</p>
						<ul className="import__details-list">
							{ platformFeatureList[ platform ].unsupported.map( ( key ) => (
								<li key={ key }>
									<Icon size={ 20 } icon={ close } />{ ' ' }
									{ translatedFeatureList[ key as FeatureName ] }
								</li>
							) ) }
						</ul>
					</div>
				) }

				{ platform === 'wordpress' && (
					<div className="import__details-features">
						<p>
							{ createInterpolateElement( __( 'Import <strong>Content only</strong>:' ), {
								strong: createElement( 'strong' ),
							} ) }
						</p>
						<ul className="import__details-list">
							{ platformFeatureList[ platform ].supported.map( ( key ) => (
								<li key={ key }>
									<Icon size={ 20 } icon={ check } />{ ' ' }
									{ translatedFeatureList[ key as FeatureName ] }
								</li>
							) ) }
						</ul>
						{ /* TODO: is this section / file still relevant? */ }
						{ fromSite && (
							<>
								<p>
									{ createInterpolateElement( __( 'Import <strong>Everything*</strong>:' ), {
										strong: createElement( 'strong' ),
									} ) }
								</p>
								<ul className="import__details-list">
									{ platformFeatureList[ platform ].supported
										.concat( platformFeatureList[ platform ].unsupported )
										.map( ( key ) => (
											<li key={ key }>
												<Icon size={ 20 } icon={ check } />{ ' ' }
												{ translatedFeatureList[ key as FeatureName ] }
											</li>
										) ) }
								</ul>
								<div className="import__details-footer">
									<i>
										*
										{ sprintf(
											/* translators: %(plan)s: name of plan */
											__( 'Requires a %(plan)s plan.' ),
											{
												plan: plan?.getTitle() ?? '',
											}
										) }
									</i>
								</div>
							</>
						) }
					</div>
				) }
			</div>
		</Modal>
	);
};

export default ImportPlatformDetails;