PluginProbe
ElasticPress / 5.0.0
ElasticPress v5.0.0
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
elasticpress / assets / js / sync-ui / components / limits.js

limits.js in ElasticPress 5.0.0, at assets/js/sync-ui/components/limits.js

75 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies.
3 */
4 import { Flex, FlexItem, TextControl } from '@wordpress/components';
5 import { WPElement } from '@wordpress/element';
6 import { __ } from '@wordpress/i18n';
7
8 /**
9 * Internal dependencies.
10 */
11 import { useSync } from '../../sync';
12 import { useSyncSettings } from '../provider';
13
14 /**
15 * Delete checkbox component.
16 *
17 * @returns {WPElement} Sync page component.
18 */
19 export default () => {
20 const { isSyncing } = useSync();
21 const { args, setArgs } = useSyncSettings();
22
23 /**
24 * Handle changing the lower limit.
25 *
26 * @param {string} value Selected lower ID.
27 * @returns {void}
28 */
29 const onChangeLower = (value) => {
30 const lower_limit_object_id = value ? Math.max(0, value) : value;
31
32 setArgs({ ...args, lower_limit_object_id });
33 };
34
35 /**
36 * Handle changing the upper limit.
37 *
38 * @param {string} value Selected upper ID.
39 * @returns {void}
40 */
41 const onChangeUpper = (value) => {
42 const upper_limit_object_id = value ? Math.max(0, value) : value;
43
44 setArgs({ ...args, upper_limit_object_id });
45 };
46
47 return (
48 <Flex className="ep-sync-advanced-control" justify="start">
49 <FlexItem grow="2">
50 <TextControl
51 disabled={isSyncing}
52 help={__('Sync objects with an ID of this number or higher.', 'elasticpress')}
53 label={__('Lower object ID', 'elasticpress')}
54 max={args.upper_limit_object_id}
55 min="0"
56 onChange={onChangeLower}
57 type="number"
58 value={args.lower_limit_object_id}
59 />
60 </FlexItem>
61 <FlexItem grow="2">
62 <TextControl
63 disabled={isSyncing}
64 help={__('Sync objects with an ID of this number or lower.', 'elasticpress')}
65 label={__('Higher object ID', 'elasticpress')}
66 min={args.lower_limit_object_id}
67 onChange={onChangeUpper}
68 type="number"
69 value={args.upper_limit_object_id}
70 />
71 </FlexItem>
72 </Flex>
73 );
74 };
75