Onboarding: Add option to track appearance completion (https://github.com/woocommerce/woocommerce-admin/pull/3503)
* Add option to track appearance completion * Disable proceed button if no logo and not dirty state
This commit is contained in:
parent
8a976c28bb
commit
da9421692f
|
@ -27,15 +27,15 @@ import Payments from './tasks/payments';
|
||||||
|
|
||||||
export function getAllTasks( { profileItems, options, query, toggleCartModal } ) {
|
export function getAllTasks( { profileItems, options, query, toggleCartModal } ) {
|
||||||
const {
|
const {
|
||||||
hasHomepage,
|
|
||||||
hasPhysicalProducts,
|
hasPhysicalProducts,
|
||||||
hasProducts,
|
hasProducts,
|
||||||
|
isAppearanceComplete,
|
||||||
isTaxComplete,
|
isTaxComplete,
|
||||||
shippingZonesCount,
|
shippingZonesCount,
|
||||||
} = getSetting( 'onboarding', {
|
} = getSetting( 'onboarding', {
|
||||||
hasHomepage: false,
|
|
||||||
hasPhysicalProducts: false,
|
hasPhysicalProducts: false,
|
||||||
hasProducts: false,
|
hasProducts: false,
|
||||||
|
isAppearanceComplete: false,
|
||||||
isTaxComplete: false,
|
isTaxComplete: false,
|
||||||
shippingZonesCount: 0,
|
shippingZonesCount: 0,
|
||||||
} );
|
} );
|
||||||
|
@ -93,7 +93,7 @@ export function getAllTasks( { profileItems, options, query, toggleCartModal } )
|
||||||
content: __( 'Create a custom homepage and upload your logo', 'wooocommerce-admin' ),
|
content: __( 'Create a custom homepage and upload your logo', 'wooocommerce-admin' ),
|
||||||
icon: 'palette',
|
icon: 'palette',
|
||||||
container: <Appearance />,
|
container: <Appearance />,
|
||||||
completed: hasHomepage,
|
completed: isAppearanceComplete,
|
||||||
visible: true,
|
visible: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Appearance extends Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
isDirty: false,
|
||||||
isPending: false,
|
isPending: false,
|
||||||
logo: null,
|
logo: null,
|
||||||
stepIndex: 0,
|
stepIndex: 0,
|
||||||
|
@ -203,14 +204,20 @@ class Appearance extends Component {
|
||||||
added_text: Boolean( storeNoticeText.length ),
|
added_text: Boolean( storeNoticeText.length ),
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
setSetting( 'onboarding', {
|
||||||
|
...getSetting( 'onboarding', {} ),
|
||||||
|
isAppearanceComplete: true,
|
||||||
|
} );
|
||||||
|
|
||||||
updateOptions( {
|
updateOptions( {
|
||||||
|
woocommerce_task_list_appearance_complete: true,
|
||||||
woocommerce_demo_store: storeNoticeText.length ? 'yes' : 'no',
|
woocommerce_demo_store: storeNoticeText.length ? 'yes' : 'no',
|
||||||
woocommerce_demo_store_notice: storeNoticeText,
|
woocommerce_demo_store_notice: storeNoticeText,
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
getSteps() {
|
getSteps() {
|
||||||
const { isPending, logo, storeNoticeText } = this.state;
|
const { isDirty, isPending, logo, storeNoticeText } = this.state;
|
||||||
const { isRequesting } = this.props;
|
const { isRequesting } = this.props;
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
|
@ -263,8 +270,16 @@ class Appearance extends Component {
|
||||||
description: __( 'Ensure your store is on-brand by adding your logo', 'woocommerce-admin' ),
|
description: __( 'Ensure your store is on-brand by adding your logo', 'woocommerce-admin' ),
|
||||||
content: isPending ? null : (
|
content: isPending ? null : (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<ImageUpload image={ logo } onChange={ image => this.setState( { logo: image } ) } />
|
<ImageUpload
|
||||||
<Button onClick={ this.updateLogo } isBusy={ isRequesting } isPrimary>
|
image={ logo }
|
||||||
|
onChange={ image => this.setState( { isDirty: true, logo: image } ) }
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
disabled={ ! logo && ! isDirty }
|
||||||
|
onClick={ this.updateLogo }
|
||||||
|
isBusy={ isRequesting }
|
||||||
|
isPrimary
|
||||||
|
>
|
||||||
{ __( 'Proceed', 'woocommerce-admin' ) }
|
{ __( 'Proceed', 'woocommerce-admin' ) }
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={ () => this.completeStep() }>
|
<Button onClick={ () => this.completeStep() }>
|
||||||
|
@ -343,7 +358,11 @@ export default compose(
|
||||||
const isRequesting =
|
const isRequesting =
|
||||||
Boolean( isUpdateOptionsRequesting( [ `theme_mods_${ stylesheet }` ] ) ) ||
|
Boolean( isUpdateOptionsRequesting( [ `theme_mods_${ stylesheet }` ] ) ) ||
|
||||||
Boolean(
|
Boolean(
|
||||||
isUpdateOptionsRequesting( [ 'woocommerce_demo_store', 'woocommerce_demo_store_notice' ] )
|
isUpdateOptionsRequesting( [
|
||||||
|
'woocommerce_task_list_appearance_complete',
|
||||||
|
'woocommerce_demo_store',
|
||||||
|
'woocommerce_demo_store_notice',
|
||||||
|
] )
|
||||||
);
|
);
|
||||||
|
|
||||||
return { errors, getOptionsError, hasErrors, isRequesting, options };
|
return { errors, getOptionsError, hasErrors, isRequesting, options };
|
||||||
|
|
|
@ -94,6 +94,7 @@ class OnboardingTasks {
|
||||||
)
|
)
|
||||||
) > 0;
|
) > 0;
|
||||||
$settings['onboarding']['hasProducts'] = self::check_task_completion( 'products' );
|
$settings['onboarding']['hasProducts'] = self::check_task_completion( 'products' );
|
||||||
|
$settings['onboarding']['isAppearanceComplete'] = get_option( 'woocommerce_task_list_appearance_complete' );
|
||||||
$settings['onboarding']['isTaxComplete'] = self::check_task_completion( 'tax' );
|
$settings['onboarding']['isTaxComplete'] = self::check_task_completion( 'tax' );
|
||||||
$settings['onboarding']['shippingZonesCount'] = count( \WC_Shipping_Zones::get_zones() );
|
$settings['onboarding']['shippingZonesCount'] = count( \WC_Shipping_Zones::get_zones() );
|
||||||
$settings['onboarding']['stylesheet'] = get_option( 'stylesheet' );
|
$settings['onboarding']['stylesheet'] = get_option( 'stylesheet' );
|
||||||
|
|
Loading…
Reference in New Issue