File size: 2,616 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
import { FormLabel } from '@automattic/components';
import { useTranslate } from 'i18n-calypso';
import { FunctionComponent, ChangeEvent } from 'react';
import FormCheckbox from 'calypso/components/forms/form-checkbox';
import type { RewindConfig } from './types';

import './style.scss';

interface Props {
	currentConfig: RewindConfig;
	onConfigChange: ( config: RewindConfig ) => void;
}

const BackupRewindConfigEditor: FunctionComponent< Props > = ( {
	currentConfig,
	onConfigChange,
} ) => {
	const translate = useTranslate();

	const onChange = ( { target: { name, checked } }: ChangeEvent< HTMLInputElement > ) =>
		onConfigChange( {
			...currentConfig,
			[ name ]: checked,
		} );

	const checkboxes = [
		{
			name: 'themes',
			label: translate( '{{strong}}WordPress themes{{/strong}}', {
				components: {
					strong: <strong />,
				},
			} ),
		},
		{
			name: 'plugins',
			label: translate( '{{strong}}WordPress plugins{{/strong}}', {
				components: {
					strong: <strong />,
				},
			} ),
		},
		{
			name: 'roots',
			label: translate(
				'{{strong}}WordPress root{{/strong}} (includes wp-config php and any non WordPress files)',
				{
					components: {
						strong: <strong />,
					},
				}
			),
		},
		{
			name: 'contents',
			label: translate(
				'{{strong}}WP-content directory{{/strong}} (excludes themes, plugins, and uploads)',
				{
					components: {
						strong: <strong />,
					},
				}
			),
		},
		{
			name: 'sqls',
			label: translate( '{{strong}}Site database{{/strong}} (includes pages, and posts)', {
				components: {
					strong: <strong />,
				},
			} ),
		},
		{
			name: 'uploads',
			label: translate(
				'{{strong}}Media uploads{{/strong}} (you must also select {{em}}Site database{{/em}} for restored media uploads to appear)',
				{
					components: {
						strong: <strong />,
						em: <em />,
					},
					comment:
						'"Site database" is another item of the list, at the same level as "Media Uploads"',
				}
			),
		},
	];

	return (
		<div className="rewind-flow__rewind-config-editor">
			{ checkboxes.map( ( { name, label } ) => (
				<FormLabel
					className="rewind-flow__rewind-config-editor-label"
					key={ name }
					optional={ false }
					required={ false }
				>
					<FormCheckbox
						checked={ currentConfig[ name as keyof RewindConfig ] }
						className="rewind-flow__rewind-config-editor-checkbox"
						name={ name }
						onChange={ onChange }
					/>
					<span className="rewind-flow__rewind-config-editor-label-text">{ label }</span>
				</FormLabel>
			) ) }
		</div>
	);
};

export default BackupRewindConfigEditor;