| 1 |
/** |
| 2 |
* WordPress dependencies. |
| 3 |
*/ |
| 4 |
import { CheckboxControl, Notice } 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 { isDeleting, isSyncing } = useSync(); |
| 21 |
const { args, setArgs } = useSyncSettings(); |
| 22 |
|
| 23 |
return ( |
| 24 |
<> |
| 25 |
{args.put_mapping ? ( |
| 26 |
<Notice isDismissible={false} status="warning"> |
| 27 |
{__( |
| 28 |
'Search results could be out of date or returned in different order while the sync completes.', |
| 29 |
'elasticpress', |
| 30 |
)} |
| 31 |
</Notice> |
| 32 |
) : null} |
| 33 |
<CheckboxControl |
| 34 |
className="ep-sync-delete" |
| 35 |
disabled={isSyncing} |
| 36 |
checked={args.put_mapping} |
| 37 |
help={__( |
| 38 |
'All indexed data on ElasticPress will be deleted without affecting anything on your WordPress website. This may take a few hours depending on the amount of content that needs to be synced and indexed. While this is happening, searches will use the default WordPress results.', |
| 39 |
'elasticpress', |
| 40 |
)} |
| 41 |
indeterminate={isSyncing && isDeleting && !args.put_mapping} |
| 42 |
label={__('Delete all data and start fresh sync', 'elasticpress')} |
| 43 |
onChange={(checked) => setArgs({ ...args, put_mapping: checked })} |
| 44 |
/> |
| 45 |
</> |
| 46 |
); |
| 47 |
}; |
| 48 |
|