File size: 2,037 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
import { ProgressBar } from '@automattic/components';
import { Progress, SubTitle, Title } from '@automattic/onboarding';
import { useI18n } from '@wordpress/react-i18n';
import React, { useCallback } from 'react';
import useProgressValue from './use-progress-value';
import type { ImportJob } from '../../types';

interface Props {
	job?: ImportJob;
	showHeading?: boolean;
}
const ProgressScreen: React.FunctionComponent< Props > = ( props ) => {
	const { __ } = useI18n();
	const { job, showHeading } = props;
	const { customData } = job || {};
	const progressValue = useProgressValue( job?.progress );

	const getPlaygroundImportTitle = useCallback( () => {
		switch ( customData?.current_step ) {
			case 'unpack_file':
			case 'preprocess':
			case 'process_files':
				return __( 'Moving your files' );

			case 'recreate_database':
			case 'postprocess_database':
			case 'verify_site_integrity':
			case 'clean_up':
				return __( 'Migrating your data' );

			case 'download_archive':
				return __( 'Backing up your data' );

			case 'convert_to_atomic':
			default:
				return __( 'Preparing your site for import' );
		}
	}, [ customData?.current_step ] );

	const title =
		job?.importerFileType !== 'playground' ? __( 'Importing' ) : getPlaygroundImportTitle();

	if ( showHeading ) {
		return (
			<div className="import-layout__center">
				<Progress>
					<div className="import__heading import__heading-center">
						<Title>{ title }...</Title>
						<ProgressBar compact value={ progressValue } />
						<SubTitle>
							{ __(
								'Feel free to close this window. We’ll email you when your new site is ready.'
							) }
						</SubTitle>
					</div>
				</Progress>
			</div>
		);
	}

	return (
		<Progress>
			<div className="import__heading import__heading-center">
				<ProgressBar compact value={ progressValue } />
				<SubTitle>
					{ __( 'Feel free to close this window. We’ll email you when your new site is ready.' ) }
				</SubTitle>
			</div>
		</Progress>
	);
};

export default ProgressScreen;