woocommerce/plugins/woocommerce-admin/client/dashboard/default-sections.js

112 lines
2.9 KiB
JavaScript
Raw Normal View History

/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { applyFilters } from '@wordpress/hooks';
Use Route based code splitting to optimize bundle size (https://github.com/woocommerce/woocommerce-admin/pull/4094) * Use lazy loading to split up the size of the js downloaded * Use lazy loading to split up the size of the js downloaded * Add Moment Timezone plugin to reduce size of data file. * Lazy load header panels and use Dashicons for faster loading * Load assets from the correct publicPath * Load assets from the correct publicPath * PHP cs fixes * Fix missing quotes on string literal. * Fix PropType warning for lazy loaded component. * Separate the task list and dashboard chunks. * Lazy load dashboard sections. * Restore original icons and reduce size by importing only the icons needed * Lazy load alerts to save more Kb on initial load * Minify built JS in production mode. * Add preload tags for WC Admin assets. (https://github.com/woocommerce/woocommerce-admin/pull/4162) * Fix linting errors. * Add modified UnminifiedWebpackPlugin. * Produce minified and unminified bundles for all builds. * Remove unused variable from webpack config. * Run unminify after sourcemap generation. * Only hook after optimization if we're using a devtool. * Add minification suffix in Loader::get_url(). * Lazy load OBW on new home screen. * Move OBW style up a level to layout. * Hydrate ProfileWizard independently of withSelect and withDispatch * Fix order of composition and fallback function when using hydration. Co-authored-by: Jeff Stieler <jeff.m.stieler@gmail.com> Co-authored-by: Paul Sealock <psealock@gmail.com>
2020-04-29 18:01:27 +00:00
import { lazy, Suspense } from '@wordpress/element';
import { Spinner } from '@woocommerce/components';
import { arrowRight, chartBar } from '@wordpress/icons';
import ListOrdered from 'gridicons/dist/list-ordered';
/**
* Internal dependencies
*/
Use Route based code splitting to optimize bundle size (https://github.com/woocommerce/woocommerce-admin/pull/4094) * Use lazy loading to split up the size of the js downloaded * Use lazy loading to split up the size of the js downloaded * Add Moment Timezone plugin to reduce size of data file. * Lazy load header panels and use Dashicons for faster loading * Load assets from the correct publicPath * Load assets from the correct publicPath * PHP cs fixes * Fix missing quotes on string literal. * Fix PropType warning for lazy loaded component. * Separate the task list and dashboard chunks. * Lazy load dashboard sections. * Restore original icons and reduce size by importing only the icons needed * Lazy load alerts to save more Kb on initial load * Minify built JS in production mode. * Add preload tags for WC Admin assets. (https://github.com/woocommerce/woocommerce-admin/pull/4162) * Fix linting errors. * Add modified UnminifiedWebpackPlugin. * Produce minified and unminified bundles for all builds. * Remove unused variable from webpack config. * Run unminify after sourcemap generation. * Only hook after optimization if we're using a devtool. * Add minification suffix in Loader::get_url(). * Lazy load OBW on new home screen. * Move OBW style up a level to layout. * Hydrate ProfileWizard independently of withSelect and withDispatch * Fix order of composition and fallback function when using hydration. Co-authored-by: Jeff Stieler <jeff.m.stieler@gmail.com> Co-authored-by: Paul Sealock <psealock@gmail.com>
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>
);
const DEFAULT_SECTIONS_FILTER = 'woocommerce_dashboard_default_sections';
/**
* An object defining a dashboard section.
*
* @typedef {Object} section
* @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.
* @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.
*/
export default applyFilters( DEFAULT_SECTIONS_FILTER, [
{
key: 'store-performance',
component: StorePerformance,
title: __( 'Performance', 'woocommerce' ),
isVisible: true,
icon: arrowRight,
hiddenBlocks: [
'coupons/amount',
'coupons/orders_count',
'downloads/download_count',
'taxes/order_tax',
'taxes/total_tax',
'taxes/shipping_tax',
'revenue/shipping',
'orders/avg_order_value',
'revenue/refunds',
'revenue/gross_sales',
],
},
{
key: 'charts',
component: DashboardCharts,
title: __( 'Charts', 'woocommerce' ),
isVisible: true,
icon: chartBar,
hiddenBlocks: [
'orders_avg_order_value',
'avg_items_per_order',
'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',
],
},
{
key: 'leaderboards',
component: Leaderboards,
title: __( 'Leaderboards', 'woocommerce' ),
isVisible: true,
icon: <ListOrdered />,
hiddenBlocks: [ 'coupons', 'customers' ],
},
] );