Onboarding: Allow Jetpack connection to be skipped in tax task (https://github.com/woocommerce/woocommerce-admin/pull/3589)

* Add skip action to Connect component

* Add skip button to tax connect step

* Record event when tax Jetpack connection is skipped
This commit is contained in:
Joshua T Flowers 2020-01-22 16:37:05 +08:00 committed by GitHub
parent c4b1d552d4
commit 4b02e0850d
2 changed files with 30 additions and 10 deletions

View File

@ -38,17 +38,22 @@ class Connect extends Component {
}
render() {
const { hasErrors, isRequesting } = this.props;
const { hasErrors, isRequesting, onSkip, skipText } = this.props;
return hasErrors ? (
<Button isPrimary onClick={ () => location.reload() }>
{ __( 'Retry', 'woocommerce-admin' ) }
</Button>
) : (
return (
<Fragment>
<Button isBusy={ isRequesting } isPrimary onClick={ this.connectJetpack }>
{ __( 'Connect', 'woocommerce-admin' ) }
</Button>
{ hasErrors ? (
<Button isPrimary onClick={ () => location.reload() }>
{ __( 'Retry', 'woocommerce-admin' ) }
</Button>
) : (
<Button isBusy={ isRequesting } isPrimary onClick={ this.connectJetpack }>
{ __( 'Connect', 'woocommerce-admin' ) }
</Button>
) }
{ onSkip && (
<Button onClick={ onSkip }>{ skipText || __( 'No thanks', 'woocommerce-admin' ) }</Button>
) }
</Fragment>
);
}
@ -75,10 +80,18 @@ Connect.propTypes = {
* Generated Jetpack connection URL.
*/
jetpackConnectUrl: PropTypes.string,
/**
* Called when the plugin connection is skipped.
*/
onSkip: PropTypes.func,
/**
* Redirect URL to encode as a URL param for the connection path.
*/
redirectUrl: PropTypes.string,
/**
* Text used for the skip connection button.
*/
skipText: PropTypes.string,
};
export default compose(

View File

@ -239,8 +239,15 @@ class Tax extends Component {
<Connect
{ ...this.props }
onConnect={ () => {
recordEvent( 'tasklist_tax_connect_store' );
recordEvent( 'tasklist_tax_connect_store', { connect: true } );
} }
onSkip={ () => {
queueRecordEvent( 'tasklist_tax_connect_store', { connect: false } );
window.location.href = getAdminLink(
'admin.php?page=wc-settings&tab=tax&section=standard'
);
} }
skipText={ __( 'Set up tax rates manually', 'woocommerce-admin' ) }
/>
),
visible: ! isJetpackConnected && this.isTaxJarSupported(),