2019-05-07 07:21:34 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
2020-04-29 18:01:27 +00:00
|
|
|
import { lazy, Suspense } from '@wordpress/element';
|
2020-08-13 02:05:22 +00:00
|
|
|
import { Spinner } from '@woocommerce/components';
|
2021-05-25 15:14:14 +00:00
|
|
|
import { arrowRight, chartBar } from '@wordpress/icons';
|
|
|
|
import ListOrdered from 'gridicons/dist/list-ordered';
|
2019-05-07 07:21:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-04-29 18:01:27 +00:00
|
|
|
const LazyDashboardCharts = lazy( () =>
|
|
|
|
import( /* webpackChunkName: "dashboard-charts" */ './dashboard-charts' )
|
|
|
|
);
|
|
|
|
const LazyLeaderboards = lazy( () =>
|
|
|
|
import( /* webpackChunkName: "leaderboards" */ './leaderboards' )
|
|
|
|
);
|
|
|
|
const LazyStorePerformance = lazy( () =>
|
|
|
|
import( /* webpackChunkName: "store-performance" */ './store-performance' )
|
|
|
|
);
|
|
|
|
|
|
|
|
const DashboardCharts = ( props ) => (
|
|
|
|
<Suspense fallback={ <Spinner /> }>
|
|
|
|
<LazyDashboardCharts { ...props } />
|
|
|
|
</Suspense>
|
|
|
|
);
|
|
|
|
|
|
|
|
const Leaderboards = ( props ) => (
|
|
|
|
<Suspense fallback={ <Spinner /> }>
|
|
|
|
<LazyLeaderboards { ...props } />
|
|
|
|
</Suspense>
|
|
|
|
);
|
|
|
|
|
|
|
|
const StorePerformance = ( props ) => (
|
|
|
|
<Suspense fallback={ <Spinner /> }>
|
|
|
|
<LazyStorePerformance { ...props } />
|
|
|
|
</Suspense>
|
|
|
|
);
|
2019-05-07 07:21:34 +00:00
|
|
|
|
|
|
|
const DEFAULT_SECTIONS_FILTER = 'woocommerce_dashboard_default_sections';
|
|
|
|
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* An object defining a dashboard section.
|
|
|
|
*
|
|
|
|
* @typedef {Object} section
|
2022-03-18 11:45:14 +00:00
|
|
|
* @property {string} key Unique identifying string.
|
|
|
|
* @property {Node} component React component to render.
|
|
|
|
* @property {string} title Title.
|
|
|
|
* @property {boolean} isVisible The default visibilty.
|
|
|
|
* @property {Node} icon Section icon.
|
2022-02-11 14:38:38 +00:00
|
|
|
* @property {Array.<string>} hiddenBlocks Blocks that are hidden by default.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default Dashboard sections. Defaults are Store Performance, Charts, and Leaderboards
|
|
|
|
*
|
|
|
|
* @filter woocommerce_dashboard_default_sections
|
|
|
|
* @param {Array.<section>} sections Report filters.
|
|
|
|
*/
|
2019-05-07 07:21:34 +00:00
|
|
|
export default applyFilters( DEFAULT_SECTIONS_FILTER, [
|
|
|
|
{
|
|
|
|
key: 'store-performance',
|
|
|
|
component: StorePerformance,
|
|
|
|
title: __( 'Performance', 'woocommerce-admin' ),
|
|
|
|
isVisible: true,
|
2021-05-25 15:14:14 +00:00
|
|
|
icon: arrowRight,
|
2019-05-07 07:21:34 +00:00
|
|
|
hiddenBlocks: [
|
|
|
|
'coupons/amount',
|
|
|
|
'coupons/orders_count',
|
|
|
|
'downloads/download_count',
|
|
|
|
'taxes/order_tax',
|
|
|
|
'taxes/total_tax',
|
|
|
|
'taxes/shipping_tax',
|
|
|
|
'revenue/shipping',
|
2020-04-01 00:58:06 +00:00
|
|
|
'orders/avg_order_value',
|
|
|
|
'revenue/refunds',
|
|
|
|
'revenue/gross_sales',
|
2019-05-07 07:21:34 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'charts',
|
|
|
|
component: DashboardCharts,
|
|
|
|
title: __( 'Charts', 'woocommerce-admin' ),
|
|
|
|
isVisible: true,
|
2021-05-25 15:14:14 +00:00
|
|
|
icon: chartBar,
|
2019-05-07 07:21:34 +00:00
|
|
|
hiddenBlocks: [
|
2020-04-01 00:58:06 +00:00
|
|
|
'orders_avg_order_value',
|
2019-05-07 07:21:34 +00:00
|
|
|
'avg_items_per_order',
|
2020-04-01 00:58:06 +00:00
|
|
|
'products_items_sold',
|
|
|
|
'revenue_total_sales',
|
|
|
|
'revenue_refunds',
|
|
|
|
'coupons_amount',
|
|
|
|
'coupons_orders_count',
|
|
|
|
'revenue_shipping',
|
|
|
|
'taxes_total_tax',
|
|
|
|
'taxes_order_tax',
|
|
|
|
'taxes_shipping_tax',
|
|
|
|
'downloads_download_count',
|
2019-05-07 07:21:34 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'leaderboards',
|
|
|
|
component: Leaderboards,
|
|
|
|
title: __( 'Leaderboards', 'woocommerce-admin' ),
|
|
|
|
isVisible: true,
|
2021-05-25 15:14:14 +00:00
|
|
|
icon: <ListOrdered />,
|
2019-05-07 07:21:34 +00:00
|
|
|
hiddenBlocks: [ 'coupons', 'customers' ],
|
|
|
|
},
|
|
|
|
] );
|