2018-04-17 23:51:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2020-04-29 18:01:27 +00:00
|
|
|
import { Component, Suspense, lazy } from '@wordpress/element';
|
2019-05-28 14:45:52 +00:00
|
|
|
import { compose } from '@wordpress/compose';
|
2020-05-28 08:51:40 +00:00
|
|
|
import { withSelect } from '@wordpress/data';
|
|
|
|
import { identity } from 'lodash';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WooCommerce dependencies
|
|
|
|
*/
|
|
|
|
import { getSetting } from '@woocommerce/wc-admin-settings';
|
|
|
|
import {
|
|
|
|
ONBOARDING_STORE_NAME,
|
|
|
|
withOnboardingHydration,
|
|
|
|
} from '@woocommerce/data';
|
|
|
|
import { Spinner } from '@woocommerce/components';
|
2020-07-16 15:17:10 +00:00
|
|
|
import { getHistory, getNewPath } from '@woocommerce/navigation';
|
2018-04-17 23:51:48 +00:00
|
|
|
|
|
|
|
/**
|
2018-05-03 18:23:17 +00:00
|
|
|
* Internal dependencies
|
2018-04-17 23:51:48 +00:00
|
|
|
*/
|
2018-08-02 23:10:55 +00:00
|
|
|
import './style.scss';
|
2019-11-07 18:31:02 +00:00
|
|
|
import { isOnboardingEnabled } from 'dashboard/utils';
|
2020-04-29 18:01:27 +00:00
|
|
|
|
|
|
|
const CustomizableDashboard = lazy( () =>
|
|
|
|
import( /* webpackChunkName: "customizable-dashboard" */ './customizable' )
|
|
|
|
);
|
|
|
|
|
2019-05-28 14:45:52 +00:00
|
|
|
class Dashboard extends Component {
|
2019-07-05 08:15:49 +00:00
|
|
|
render() {
|
2020-06-11 00:26:20 +00:00
|
|
|
const { path, profileItems, query } = this.props;
|
2020-07-16 15:17:10 +00:00
|
|
|
const { completed: profileCompleted, skipped: profileSkipped } =
|
|
|
|
profileItems || {};
|
2020-04-27 14:56:15 +00:00
|
|
|
if (
|
|
|
|
isOnboardingEnabled() &&
|
2020-07-16 15:17:10 +00:00
|
|
|
! profileCompleted &&
|
|
|
|
! profileSkipped &&
|
2020-06-15 02:17:12 +00:00
|
|
|
! window.wcAdminFeatures.homescreen
|
2020-04-27 14:56:15 +00:00
|
|
|
) {
|
2020-07-16 15:17:10 +00:00
|
|
|
getHistory().push( getNewPath( {}, `/profiler`, {} ) );
|
2019-05-07 19:25:51 +00:00
|
|
|
}
|
|
|
|
|
2019-05-08 16:10:05 +00:00
|
|
|
if ( window.wcAdminFeatures[ 'analytics-dashboard/customizable' ] ) {
|
2020-04-29 18:01:27 +00:00
|
|
|
return (
|
|
|
|
<Suspense fallback={ <Spinner /> }>
|
|
|
|
<CustomizableDashboard query={ query } path={ path } />
|
|
|
|
</Suspense>
|
|
|
|
);
|
2019-04-22 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
2019-10-11 12:55:35 +00:00
|
|
|
return null;
|
2019-04-22 13:23:37 +00:00
|
|
|
}
|
2018-04-17 23:51:48 +00:00
|
|
|
}
|
2019-05-28 14:45:52 +00:00
|
|
|
|
|
|
|
export default compose(
|
2020-05-28 08:51:40 +00:00
|
|
|
getSetting( 'onboarding', {} ).profile
|
|
|
|
? withOnboardingHydration( getSetting( 'onboarding', {} ).profile )
|
|
|
|
: identity,
|
2020-02-14 02:23:21 +00:00
|
|
|
withSelect( ( select ) => {
|
2019-11-07 18:31:02 +00:00
|
|
|
if ( ! isOnboardingEnabled() ) {
|
2019-05-31 14:55:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-28 08:51:40 +00:00
|
|
|
const { getProfileItems } = select( ONBOARDING_STORE_NAME );
|
2019-05-28 14:45:52 +00:00
|
|
|
const profileItems = getProfileItems();
|
|
|
|
|
|
|
|
return { profileItems };
|
|
|
|
} )
|
|
|
|
)( Dashboard );
|