| 1 |
/** |
| 2 |
* WordPress dependencies. |
| 3 |
*/ |
| 4 |
import { WPElement } from '@wordpress/element'; |
| 5 |
import { __, sprintf } from '@wordpress/i18n'; |
| 6 |
|
| 7 |
/** |
| 8 |
* Internal dependencies. |
| 9 |
*/ |
| 10 |
import SyncPanel from './sync/panel'; |
| 11 |
|
| 12 |
/** |
| 13 |
* Sync page component. |
| 14 |
* |
| 15 |
* @param {object} props Component props. |
| 16 |
* @param {boolean} props.isCli If sync is a CLI sync. |
| 17 |
* @param {boolean} props.isComplete If sync is complete. |
| 18 |
* @param {boolean} props.isDeleting If sync is a delete and sync. |
| 19 |
* @param {boolean} props.isEpio If ElasticPress is using ElasticPress.io. |
| 20 |
* @param {boolean} props.isPaused If sync is paused. |
| 21 |
* @param {boolean} props.isSyncing If sync is running. |
| 22 |
* @param {number} props.itemsProcessed Number of items processed. |
| 23 |
* @param {number} props.itemsTotal Number of items to process. |
| 24 |
* @param {string} props.lastSyncDateTime Date and time of last sync in ISO-8601. |
| 25 |
* @param {boolean} props.lastSyncFailed If the last sync had failures. |
| 26 |
* @param {object[]} props.log Sync message log. |
| 27 |
* @param {Function} props.onDelete Callback for clicking delete and sync. |
| 28 |
* @param {Function} props.onPause Callback for clicking pause. |
| 29 |
* @param {Function} props.onResume Callback for clicking resume. |
| 30 |
* @param {Function} props.onStop Callback for clicking stop. |
| 31 |
* @param {Function} props.onSync Callback for clicking sync. |
| 32 |
* @param {string} props.syncStartDateTime Date and time of current sync in ISO 8601. |
| 33 |
* @returns {WPElement} Sync page component. |
| 34 |
*/ |
| 35 |
export default ({ isCli, isComplete, isDeleting, isEpio, isSyncing, log, ...props }) => { |
| 36 |
const isInitialSync = props.lastSyncDateTime === null; |
| 37 |
|
| 38 |
return ( |
| 39 |
<> |
| 40 |
<h1 className="ep-sync-heading">{__('Sync Settings', 'elasticpress')}</h1> |
| 41 |
|
| 42 |
<SyncPanel |
| 43 |
introduction={ |
| 44 |
isInitialSync |
| 45 |
? sprintf( |
| 46 |
/* translators: %s: Index type. ElasticPress.io or Elasticsearch. */ |
| 47 |
__( |
| 48 |
'Run a sync to index your existing content %s. Once syncing finishes, your site is officially supercharged.', |
| 49 |
'elasticpress', |
| 50 |
), |
| 51 |
isEpio |
| 52 |
? __('on ElasticPress.io', 'elasticpress') |
| 53 |
: __('in Elasticsearch', 'elasticpress'), |
| 54 |
) |
| 55 |
: __( |
| 56 |
'If you are missing data in your search results or have recently added custom content types to your site, you should run a sync to reflect these changes.', |
| 57 |
'elasticpress', |
| 58 |
) |
| 59 |
} |
| 60 |
isComplete={isComplete} |
| 61 |
isDisabled={(isSyncing && isDeleting) || (isSyncing && isCli)} |
| 62 |
isSyncing={isSyncing && !isDeleting} |
| 63 |
logMessages={log.filter((m) => !m.isDeleting)} |
| 64 |
showLastSync |
| 65 |
showProgress={!isDeleting && (isSyncing || isComplete)} |
| 66 |
showSync |
| 67 |
{...props} |
| 68 |
/> |
| 69 |
|
| 70 |
{!isInitialSync ? ( |
| 71 |
<SyncPanel |
| 72 |
heading={__('Delete All Data and Sync', 'elasticpress')} |
| 73 |
introduction={__( |
| 74 |
'If you are still having issues with your search results, you may need to do a completely fresh sync.', |
| 75 |
'elasticpress', |
| 76 |
)} |
| 77 |
isComplete={isComplete} |
| 78 |
isDisabled={(isSyncing && !isDeleting) || (isSyncing && isCli)} |
| 79 |
isSyncing={isSyncing && isDeleting} |
| 80 |
logMessages={log.filter((m) => m.isDeleting)} |
| 81 |
showDelete |
| 82 |
showProgress={isDeleting && (isSyncing || isComplete)} |
| 83 |
warningMessage={__( |
| 84 |
'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', |
| 85 |
'elasticpress', |
| 86 |
)} |
| 87 |
{...props} |
| 88 |
/> |
| 89 |
) : null} |
| 90 |
</> |
| 91 |
); |
| 92 |
}; |
| 93 |
|