woocommerce/plugins/woocommerce-admin/client/dashboard/index.js

67 lines
1.7 KiB
JavaScript
Raw Normal View History

/**
* External 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
import { Component, Suspense, lazy } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { identity } from 'lodash';
import { getSetting } from '@woocommerce/wc-admin-settings';
import {
ONBOARDING_STORE_NAME,
withOnboardingHydration,
} from '@woocommerce/data';
import { Spinner } from '@woocommerce/components';
Added skip profiler functionality (https://github.com/woocommerce/woocommerce-admin/pull/4721) * Added skip profiler functionality This commit adds the skip profiler functionality, leaving the Home screen `Store details` as incomplete. # Conflicts: # client/task-list/tasks.js * Unit tests repaiared * Added OBW page This commit makes the necessary changes to add an OBW page # Conflicts: # client/profile-wizard/index.js * Event name changed This commit renames the event name we were recording since it was wrong. * Redirection modified This commit modifies the way we do redirection # Conflicts: # client/profile-wizard/index.js * Removed `profiler` feature flag * Removed `profiler` feature flag This commit removes the `profiler` feature flag * Added error handling for `updateProfileItems` This commit adds error handling for the method `updateProfileItems` * Update client/profile-wizard/index.js Co-authored-by: Matt Sherman <matt.sherman@automattic.com> * Removed "throw" from "then" * Update client/dashboard/index.js Co-authored-by: Joshua T Flowers <joshuatf@gmail.com> * Update client/profile-wizard/index.js Co-authored-by: Joshua T Flowers <joshuatf@gmail.com> * Modified redirection URL This commit modifies the redirection URL. # Conflicts: # client/task-list/tasks.js # Conflicts: # client/profile-wizard/index.js * Removed the variable "lastStep" and the related logic. * Removed change of state for variable "skipped" * Added error trowing to onboarding actions This commit adds error trowing to onboarding actions * Removed response handling for `updateProfileItems` * Added default value for "profileItems" in Homescreen and Dashboard * Removed `step` from OnboardingProfile and test This commit removes the `step` from OnboardingProfile.php and from tests Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com> Co-authored-by: Matt Sherman <matt.sherman@automattic.com> Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
2020-07-16 15:17:10 +00:00
import { getHistory, getNewPath } from '@woocommerce/navigation';
/**
* Internal dependencies
*/
2018-08-02 23:10:55 +00:00
import './style.scss';
import { isOnboardingEnabled } from './utils';
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 CustomizableDashboard = lazy( () =>
import( /* webpackChunkName: "customizable-dashboard" */ './customizable' )
);
class Dashboard extends Component {
render() {
const { path, profileItems, query } = this.props;
Added skip profiler functionality (https://github.com/woocommerce/woocommerce-admin/pull/4721) * Added skip profiler functionality This commit adds the skip profiler functionality, leaving the Home screen `Store details` as incomplete. # Conflicts: # client/task-list/tasks.js * Unit tests repaiared * Added OBW page This commit makes the necessary changes to add an OBW page # Conflicts: # client/profile-wizard/index.js * Event name changed This commit renames the event name we were recording since it was wrong. * Redirection modified This commit modifies the way we do redirection # Conflicts: # client/profile-wizard/index.js * Removed `profiler` feature flag * Removed `profiler` feature flag This commit removes the `profiler` feature flag * Added error handling for `updateProfileItems` This commit adds error handling for the method `updateProfileItems` * Update client/profile-wizard/index.js Co-authored-by: Matt Sherman <matt.sherman@automattic.com> * Removed "throw" from "then" * Update client/dashboard/index.js Co-authored-by: Joshua T Flowers <joshuatf@gmail.com> * Update client/profile-wizard/index.js Co-authored-by: Joshua T Flowers <joshuatf@gmail.com> * Modified redirection URL This commit modifies the redirection URL. # Conflicts: # client/task-list/tasks.js # Conflicts: # client/profile-wizard/index.js * Removed the variable "lastStep" and the related logic. * Removed change of state for variable "skipped" * Added error trowing to onboarding actions This commit adds error trowing to onboarding actions * Removed response handling for `updateProfileItems` * Added default value for "profileItems" in Homescreen and Dashboard * Removed `step` from OnboardingProfile and test This commit removes the `step` from OnboardingProfile.php and from tests Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com> Co-authored-by: Matt Sherman <matt.sherman@automattic.com> Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
2020-07-16 15:17:10 +00:00
const { completed: profileCompleted, skipped: profileSkipped } =
profileItems || {};
if (
isOnboardingEnabled() &&
Added skip profiler functionality (https://github.com/woocommerce/woocommerce-admin/pull/4721) * Added skip profiler functionality This commit adds the skip profiler functionality, leaving the Home screen `Store details` as incomplete. # Conflicts: # client/task-list/tasks.js * Unit tests repaiared * Added OBW page This commit makes the necessary changes to add an OBW page # Conflicts: # client/profile-wizard/index.js * Event name changed This commit renames the event name we were recording since it was wrong. * Redirection modified This commit modifies the way we do redirection # Conflicts: # client/profile-wizard/index.js * Removed `profiler` feature flag * Removed `profiler` feature flag This commit removes the `profiler` feature flag * Added error handling for `updateProfileItems` This commit adds error handling for the method `updateProfileItems` * Update client/profile-wizard/index.js Co-authored-by: Matt Sherman <matt.sherman@automattic.com> * Removed "throw" from "then" * Update client/dashboard/index.js Co-authored-by: Joshua T Flowers <joshuatf@gmail.com> * Update client/profile-wizard/index.js Co-authored-by: Joshua T Flowers <joshuatf@gmail.com> * Modified redirection URL This commit modifies the redirection URL. # Conflicts: # client/task-list/tasks.js # Conflicts: # client/profile-wizard/index.js * Removed the variable "lastStep" and the related logic. * Removed change of state for variable "skipped" * Added error trowing to onboarding actions This commit adds error trowing to onboarding actions * Removed response handling for `updateProfileItems` * Added default value for "profileItems" in Homescreen and Dashboard * Removed `step` from OnboardingProfile and test This commit removes the `step` from OnboardingProfile.php and from tests Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com> Co-authored-by: Matt Sherman <matt.sherman@automattic.com> Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
2020-07-16 15:17:10 +00:00
! profileCompleted &&
! profileSkipped &&
! window.wcAdminFeatures.homescreen
) {
Added skip profiler functionality (https://github.com/woocommerce/woocommerce-admin/pull/4721) * Added skip profiler functionality This commit adds the skip profiler functionality, leaving the Home screen `Store details` as incomplete. # Conflicts: # client/task-list/tasks.js * Unit tests repaiared * Added OBW page This commit makes the necessary changes to add an OBW page # Conflicts: # client/profile-wizard/index.js * Event name changed This commit renames the event name we were recording since it was wrong. * Redirection modified This commit modifies the way we do redirection # Conflicts: # client/profile-wizard/index.js * Removed `profiler` feature flag * Removed `profiler` feature flag This commit removes the `profiler` feature flag * Added error handling for `updateProfileItems` This commit adds error handling for the method `updateProfileItems` * Update client/profile-wizard/index.js Co-authored-by: Matt Sherman <matt.sherman@automattic.com> * Removed "throw" from "then" * Update client/dashboard/index.js Co-authored-by: Joshua T Flowers <joshuatf@gmail.com> * Update client/profile-wizard/index.js Co-authored-by: Joshua T Flowers <joshuatf@gmail.com> * Modified redirection URL This commit modifies the redirection URL. # Conflicts: # client/task-list/tasks.js # Conflicts: # client/profile-wizard/index.js * Removed the variable "lastStep" and the related logic. * Removed change of state for variable "skipped" * Added error trowing to onboarding actions This commit adds error trowing to onboarding actions * Removed response handling for `updateProfileItems` * Added default value for "profileItems" in Homescreen and Dashboard * Removed `step` from OnboardingProfile and test This commit removes the `step` from OnboardingProfile.php and from tests Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com> Co-authored-by: Matt Sherman <matt.sherman@automattic.com> Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
2020-07-16 15:17:10 +00:00
getHistory().push( getNewPath( {}, `/profiler`, {} ) );
}
if ( window.wcAdminFeatures[ 'analytics-dashboard/customizable' ] ) {
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
return (
<Suspense fallback={ <Spinner /> }>
<CustomizableDashboard query={ query } path={ path } />
</Suspense>
);
}
return null;
}
}
export default compose(
getSetting( 'onboarding', {} ).profile
? withOnboardingHydration( getSetting( 'onboarding', {} ).profile )
: identity,
withSelect( ( select ) => {
if ( ! isOnboardingEnabled() ) {
return;
}
const { getProfileItems } = select( ONBOARDING_STORE_NAME );
const profileItems = getProfileItems();
return { profileItems };
} )
)( Dashboard );