2018-04-17 23:51:48 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2018-05-10 18:35:55 +00:00
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
2019-05-28 14:45:52 +00:00
|
|
|
import { compose } from '@wordpress/compose';
|
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-04-22 13:23:37 +00:00
|
|
|
import CustomizableDashboard from './customizable';
|
2018-12-22 00:24:26 +00:00
|
|
|
import DashboardCharts from './dashboard-charts';
|
2019-01-08 07:20:01 +00:00
|
|
|
import Leaderboards from './leaderboards';
|
2018-10-24 22:40:59 +00:00
|
|
|
import { ReportFilters } from '@woocommerce/components';
|
2019-10-07 11:51:25 +00:00
|
|
|
import { getSetting } from '@woocommerce/wc-admin-settings';
|
2019-01-08 07:20:01 +00:00
|
|
|
import StorePerformance from './store-performance';
|
2019-03-28 06:09:44 +00:00
|
|
|
import TaskList from './task-list';
|
2019-05-07 19:25:51 +00:00
|
|
|
import ProfileWizard from './profile-wizard';
|
2019-05-28 14:45:52 +00:00
|
|
|
import withSelect from 'wc-api/with-select';
|
2018-04-17 23:51:48 +00:00
|
|
|
|
2019-05-28 14:45:52 +00:00
|
|
|
class Dashboard extends Component {
|
2019-07-05 08:15:49 +00:00
|
|
|
render() {
|
2019-05-28 14:45:52 +00:00
|
|
|
const { path, profileItems, query } = this.props;
|
2019-05-17 03:04:52 +00:00
|
|
|
|
2019-05-28 14:45:52 +00:00
|
|
|
if ( window.wcAdminFeatures.onboarding && ! profileItems.skipped && ! profileItems.completed ) {
|
2019-05-17 03:04:52 +00:00
|
|
|
return <ProfileWizard query={ query } />;
|
2019-05-07 19:25:51 +00:00
|
|
|
}
|
|
|
|
|
2019-10-07 11:51:25 +00:00
|
|
|
const { taskListHidden } = getSetting( 'onboarding', {} );
|
|
|
|
|
2019-03-28 06:09:44 +00:00
|
|
|
// @todo This should be replaced by a check of tasks from the REST API response from #1897.
|
2019-10-07 11:51:25 +00:00
|
|
|
if ( window.wcAdminFeatures.onboarding && ! taskListHidden ) {
|
2019-07-19 02:54:38 +00:00
|
|
|
return <TaskList query={ query } />;
|
2019-04-22 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// @todo When the customizable dashboard is ready to be launched, we can pull `CustomizableDashboard`'s render
|
|
|
|
// method into `index.js`, and replace both this feature check, and the existing dashboard below.
|
2019-05-08 16:10:05 +00:00
|
|
|
if ( window.wcAdminFeatures[ 'analytics-dashboard/customizable' ] ) {
|
2019-04-22 13:23:37 +00:00
|
|
|
return <CustomizableDashboard query={ query } path={ path } />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<ReportFilters query={ query } path={ path } />
|
2019-07-01 09:40:50 +00:00
|
|
|
<StorePerformance query={ query } hiddenBlocks={ [] } />
|
|
|
|
<DashboardCharts query={ query } path={ path } hiddenBlocks={ [] } />
|
|
|
|
<Leaderboards query={ query } hiddenBlocks={ [] } />
|
2019-04-22 13:23:37 +00:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
2018-04-17 23:51:48 +00:00
|
|
|
}
|
2019-05-28 14:45:52 +00:00
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withSelect( select => {
|
2019-05-31 14:55:52 +00:00
|
|
|
if ( ! window.wcAdminFeatures.onboarding ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-28 14:45:52 +00:00
|
|
|
const { getProfileItems } = select( 'wc-api' );
|
|
|
|
const profileItems = getProfileItems();
|
|
|
|
|
|
|
|
return { profileItems };
|
|
|
|
} )
|
|
|
|
)( Dashboard );
|