Onboarding: Redirect to task list after shipping step connection (https://github.com/woocommerce/woocommerce-admin/pull/3331)

* Add redirectUrl prop to connect step

* Add propTypes to connect component
This commit is contained in:
Joshua T Flowers 2019-12-04 07:16:17 +08:00 committed by GitHub
parent 7e2aa85235
commit 7c9ba29fa2
2 changed files with 32 additions and 3 deletions

View File

@ -14,8 +14,8 @@ import { withDispatch } from '@wordpress/data';
* WooCommerce dependencies * WooCommerce dependencies
*/ */
import { Card, Link, Stepper } from '@woocommerce/components'; import { Card, Link, Stepper } from '@woocommerce/components';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getHistory, getNewPath } from '@woocommerce/navigation'; import { getHistory, getNewPath } from '@woocommerce/navigation';
import { getSetting } from '@woocommerce/wc-admin-settings';
/** /**
* Internal dependencies * Internal dependencies
@ -231,6 +231,7 @@ class Shipping extends Component {
), ),
content: ( content: (
<Connect <Connect
redirectUrl={ getAdminLink( 'admin.php?page=wc-admin' ) }
completeStep={ this.completeStep } completeStep={ this.completeStep }
{ ...this.props } { ...this.props }
onConnect={ () => { onConnect={ () => {

View File

@ -6,6 +6,7 @@ import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components'; import { Button } from '@wordpress/components';
import { Component, Fragment } from '@wordpress/element'; import { Component, Fragment } from '@wordpress/element';
import { compose } from '@wordpress/compose'; import { compose } from '@wordpress/compose';
import PropTypes from 'prop-types';
import { withDispatch } from '@wordpress/data'; import { withDispatch } from '@wordpress/data';
/** /**
@ -53,8 +54,35 @@ class Connect extends Component {
} }
} }
Connect.propTypes = {
/**
* Method to create a displayed notice.
*/
createNotice: PropTypes.func.isRequired,
/**
* Human readable error message.
*/
error: PropTypes.string,
/**
* Bool to determine if the "Retry" button should be displayed.
*/
hasErrors: PropTypes.bool,
/**
* Bool to check if the connection URL is still being requested.
*/
isRequesting: PropTypes.bool,
/**
* Generated Jetpack connection URL.
*/
jetpackConnectUrl: PropTypes.string,
/**
* Redirect URL to encode as a URL param for the connection path.
*/
redirectUrl: PropTypes.string,
};
export default compose( export default compose(
withSelect( select => { withSelect( ( select, props ) => {
const { const {
getJetpackConnectUrl, getJetpackConnectUrl,
isGetJetpackConnectUrlRequesting, isGetJetpackConnectUrlRequesting,
@ -62,7 +90,7 @@ export default compose(
} = select( 'wc-api' ); } = select( 'wc-api' );
const queryArgs = { const queryArgs = {
redirect_url: window.location.href, redirect_url: props.redirectUrl || window.location.href,
}; };
const isRequesting = isGetJetpackConnectUrlRequesting( queryArgs ); const isRequesting = isGetJetpackConnectUrlRequesting( queryArgs );
const error = getJetpackConnectUrlError( queryArgs ); const error = getJetpackConnectUrlError( queryArgs );