woocommerce/plugins/woocommerce-admin/client/analytics/settings/historical-data/layout.js

189 lines
4.6 KiB
JavaScript
Raw Normal View History

/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { Component, Fragment } from '@wordpress/element';
import { isNil } from 'lodash';
import { SectionHeader } from '@woocommerce/components';
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
import { IMPORT_STORE_NAME } from '@woocommerce/data';
import { withSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import { formatParams, getStatus } from './utils';
import HistoricalDataActions from './actions';
import HistoricalDataPeriodSelector from './period-selector';
import HistoricalDataProgress from './progress';
import HistoricalDataStatus from './status';
import HistoricalDataSkipCheckbox from './skip-checkbox';
import './style.scss';
class HistoricalDataLayout extends Component {
render() {
const {
customersProgress,
customersTotal,
dateFormat,
importDate,
inProgress,
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
lastImportStartTimestamp,
clearStatusAndTotalsCache,
ordersProgress,
ordersTotal,
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
onImportStarted,
period,
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
stopImport,
skipChecked,
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
status,
} = this.props;
return (
<Fragment>
<SectionHeader
title={ __( 'Import historical data', 'woocommerce' ) }
/>
<div className="woocommerce-settings__wrapper">
<div className="woocommerce-setting">
<div className="woocommerce-setting__input">
<span className="woocommerce-setting__help">
{ __(
'This tool populates historical analytics data by processing customers ' +
'and orders created prior to activating WooCommerce Admin.',
'woocommerce'
) }
</span>
{ status !== 'finished' && (
<Fragment>
<HistoricalDataPeriodSelector
dateFormat={ dateFormat }
disabled={ inProgress }
value={ period }
/>
<HistoricalDataSkipCheckbox
disabled={ inProgress }
checked={ skipChecked }
/>
<HistoricalDataProgress
label={ __(
'Registered Customers',
'woocommerce'
) }
progress={ customersProgress }
total={ customersTotal }
/>
<HistoricalDataProgress
label={ __(
'Orders and Refunds',
'woocommerce'
) }
progress={ ordersProgress }
total={ ordersTotal }
/>
</Fragment>
) }
<HistoricalDataStatus
importDate={ importDate }
status={ status }
/>
</div>
</div>
</div>
<HistoricalDataActions
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
clearStatusAndTotalsCache={ clearStatusAndTotalsCache }
dateFormat={ dateFormat }
importDate={ importDate }
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
lastImportStartTimestamp={ lastImportStartTimestamp }
onImportStarted={ onImportStarted }
stopImport={ stopImport }
status={ status }
/>
</Fragment>
);
}
}
export default withSelect( ( select, props ) => {
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
const { getImportError, getImportStatus, getImportTotals } = select(
IMPORT_STORE_NAME
);
const {
activeImport,
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
cacheNeedsClearing,
dateFormat,
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
inProgress,
onImportStarted,
onImportFinished,
period,
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
startStatusCheckInterval,
skipChecked,
} = props;
const params = formatParams( dateFormat, period, skipChecked );
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
const { customers, orders, lastImportStartTimestamp } = getImportTotals(
params
);
const {
customers: customersStatus,
imported_from: importDate,
is_importing: isImporting,
orders: ordersStatus,
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
} = getImportStatus( lastImportStartTimestamp );
const { imported: customersProgress, total: customersTotal } =
customersStatus || {};
const { imported: ordersProgress, total: ordersTotal } = ordersStatus || {};
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
const isError = Boolean(
getImportError( lastImportStartTimestamp ) || getImportError( params )
);
const hasImportStarted = Boolean(
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
! lastImportStartTimestamp && ! inProgress && isImporting === true
);
if ( hasImportStarted ) {
onImportStarted();
}
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
const hasImportFinished = Boolean(
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
inProgress &&
! cacheNeedsClearing &&
isImporting === false &&
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
( customersTotal > 0 || ordersTotal > 0 ) &&
customersProgress === customersTotal &&
ordersProgress === ordersTotal
);
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
let response = {
customersTotal: customers,
isError,
ordersTotal: orders,
};
if ( activeImport ) {
response = {
cacheNeedsClearing,
customersProgress,
customersTotal: isNil( customersTotal )
? customers
: customersTotal,
inProgress,
isError,
ordersProgress,
ordersTotal: isNil( ordersTotal ) ? orders : ordersTotal,
};
}
Migrated "import" store to "wp.data" (https://github.com/woocommerce/woocommerce-admin/pull/4982) * Migrated the "import" store to "wp.data" This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js * Added error handling This commit adds error handling to the apiFetch * Fixred reducer.js * Added reducer.js tests * Removed "endpoint" references * Tests fixed * Removed old import store files and wc-api-spec import references This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js * Added interval to invalidate resolution of getImportStatus * Fixed timestamp * Store dependency removed * Fixed reimport functionality # Conflicts: # client/analytics/settings/historical-data/index.js * Refactored layout.js * Refactored clearCache method * inProgress check refactored * Using activeImport from store # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed console warning # Conflicts: # client/analytics/settings/historical-data/index.js * Migration done! # Conflicts: # client/analytics/settings/historical-data/index.js * Fixed hasImportFinished * Test fixed * Removed "setImportFinished" from actions.js and index.js * Added style to disabled button * Fixed incorrect "Finalizing" status * Fixed tests * Fixed notes update on importation start * Removed local constants * Removed css for disabled button * Typo corrected * Fixed param for getImportError method Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-09-01 13:21:31 +00:00
const status = getStatus( response );
if ( status === 'initializing' ) {
startStatusCheckInterval();
}
if ( hasImportFinished ) {
onImportFinished();
}
return { ...response, importDate, status };
} )( HistoricalDataLayout );