PluginProbe
ElasticPress / 5.0.2
ElasticPress v5.0.2
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 / controls.js

controls.js in ElasticPress 5.0.2, at assets/js/sync-ui/components/controls.js

89 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 { Button } 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 * Sync controls component.
16 *
17 * @returns {WPElement} Component.
18 */
19 export default () => {
20 const { isPaused, isSyncing, logMessage, pauseSync, resumeSync, stopSync } = useSync();
21
22 const { args } = useSyncSettings();
23
24 /**
25 * Handle clicking pause button.
26 *
27 * @returns {void}
28 */
29 const onPause = () => {
30 pauseSync();
31 logMessage(__('Pausing sync…', 'elasticpress'), 'info');
32 };
33
34 /**
35 * Handle clicking play button.
36 *
37 * @returns {void}
38 */
39 const onResume = () => {
40 resumeSync(args);
41 logMessage(__('Resuming sync…', 'elasticpress'), 'info');
42 };
43
44 /**
45 * Handle clicking stop button.
46 *
47 * @returns {void}
48 */
49 const onStop = () => {
50 stopSync();
51 logMessage(__('Sync stopped', 'elasticpress'), 'info');
52 };
53
54 /**
55 * Render.
56 */
57 return (
58 <div className="ep-sync-controls">
59 {isSyncing ? (
60 <>
61 <Button onClick={onStop} variant="primary">
62 {__('Stop sync', 'elasticpress')}
63 </Button>
64 {isPaused ? (
65 <Button onClick={onResume} variant="secondary">
66 {__('Resume sync', 'elasticpress')}
67 </Button>
68 ) : (
69 <Button onClick={onPause} variant="secondary">
70 {__('Pause sync', 'elasticpress')}
71 </Button>
72 )}
73 </>
74 ) : (
75 <Button variant="primary" type="submit">
76 {__('Start sync', 'elasticpress')}
77 </Button>
78 )}
79 <Button
80 href="https://elasticpress.zendesk.com/hc/en-us/articles/5205632443533"
81 target="_blank"
82 variant="link"
83 >
84 {__('Learn more about Sync', 'elasticpress')}
85 </Button>
86 </div>
87 );
88 };
89