Fix OBW when new home screen is enabled. (https://github.com/woocommerce/woocommerce-admin/pull/4215)
* Move ProfileWizard component out of Dashboard. * Don't trigger the OBW from the Analytics Dashboard (with new home screen). * Trigger OBW from the new home screen. * Fix duplicate import.
This commit is contained in:
parent
6140e7994f
commit
e893ce3c54
|
@ -9,28 +9,20 @@ import { compose } from '@wordpress/compose';
|
|||
*/
|
||||
import './style.scss';
|
||||
import CustomizableDashboard from './customizable';
|
||||
import ProfileWizard from './profile-wizard';
|
||||
import ProfileWizard from '../profile-wizard';
|
||||
import withSelect from 'wc-api/with-select';
|
||||
import { isOnboardingEnabled } from 'dashboard/utils';
|
||||
import { withSettingsHydration } from '@woocommerce/data';
|
||||
|
||||
let PossiblyHydratedProfileWizard = ProfileWizard;
|
||||
|
||||
if (
|
||||
window.wcSettings.preloadSettings &&
|
||||
window.wcSettings.preloadSettings.general
|
||||
) {
|
||||
PossiblyHydratedProfileWizard = withSettingsHydration( 'general', {
|
||||
general: window.wcSettings.preloadSettings.general,
|
||||
} )( PossiblyHydratedProfileWizard );
|
||||
}
|
||||
|
||||
class Dashboard extends Component {
|
||||
render() {
|
||||
const { path, profileItems, query } = this.props;
|
||||
|
||||
if ( isOnboardingEnabled() && ! profileItems.completed ) {
|
||||
return <PossiblyHydratedProfileWizard query={ query } />;
|
||||
if (
|
||||
isOnboardingEnabled() &&
|
||||
! profileItems.completed &&
|
||||
! window.wcAdminFeatures.homepage
|
||||
) {
|
||||
return <ProfileWizard query={ query } />;
|
||||
}
|
||||
|
||||
if ( window.wcAdminFeatures[ 'analytics-dashboard/customizable' ] ) {
|
||||
|
|
|
@ -1,5 +1,32 @@
|
|||
const Homepage = () => {
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { compose } from '@wordpress/compose';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import ProfileWizard from '../profile-wizard';
|
||||
import withSelect from 'wc-api/with-select';
|
||||
import { isOnboardingEnabled } from 'dashboard/utils';
|
||||
|
||||
const Homepage = ( { profileItems, query } ) => {
|
||||
if ( isOnboardingEnabled() && ! profileItems.completed ) {
|
||||
return <ProfileWizard query={ query } />;
|
||||
}
|
||||
|
||||
return <div>Hello World</div>;
|
||||
};
|
||||
|
||||
export default Homepage;
|
||||
export default compose(
|
||||
withSelect( ( select ) => {
|
||||
if ( ! isOnboardingEnabled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { getProfileItems } = select( 'wc-api' );
|
||||
const profileItems = getProfileItems();
|
||||
|
||||
return { profileItems };
|
||||
} )
|
||||
)( Homepage );
|
||||
|
|
|
@ -11,7 +11,11 @@ import { withDispatch } from '@wordpress/data';
|
|||
* WooCommerce dependencies
|
||||
*/
|
||||
import { updateQueryString } from '@woocommerce/navigation';
|
||||
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
|
||||
import {
|
||||
PLUGINS_STORE_NAME,
|
||||
withSettingsHydration,
|
||||
withPluginsHydration,
|
||||
} from '@woocommerce/data';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -234,7 +238,24 @@ class ProfileWizard extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
const hydrateSettings = ( window.wcSettings.preloadSettings && window.wcSettings.preloadSettings.general );
|
||||
|
||||
export default compose(
|
||||
(
|
||||
hydrateSettings
|
||||
? withSettingsHydration( 'general', {
|
||||
general: window.wcSettings.preloadSettings.general,
|
||||
} )
|
||||
: () => ( {} )
|
||||
),
|
||||
(
|
||||
window.wcSettings.plugins
|
||||
? withPluginsHydration( {
|
||||
...window.wcSettings.plugins,
|
||||
jetpackStatus: window.wcSettings.dataEndpoints.jetpackStatus,
|
||||
} )
|
||||
: () => ( {} )
|
||||
),
|
||||
withSelect( ( select ) => {
|
||||
const { getNotes, getProfileItems, getProfileItemsError } = select(
|
||||
'wc-api'
|
|
@ -23,7 +23,7 @@ import { getCountryCode, getCurrencyRegion } from 'dashboard/utils';
|
|||
import {
|
||||
StoreAddress,
|
||||
validateStoreAddress,
|
||||
} from '../../components/settings/general/store-address';
|
||||
} from 'dashboard/components/settings/general/store-address';
|
||||
import UsageModal from './usage-modal';
|
||||
import withWCApiSelect from 'wc-api/with-select';
|
||||
import { CurrencyContext } from 'lib/currency-context';
|
Loading…
Reference in New Issue