Onboarding: Skip Shipping connect step if Jetpack is already connected (https://github.com/woocommerce/woocommerce-admin/pull/3486)

This commit is contained in:
Joshua T Flowers 2019-12-27 17:16:39 +08:00 committed by GitHub
parent 8b02019c1c
commit 2df87c674d
1 changed files with 17 additions and 4 deletions

View File

@ -143,12 +143,16 @@ class Shipping extends Component {
}
getSteps() {
const { countryCode } = this.props;
const { countryCode, isJetpackConnected } = this.props;
let plugins = [];
if ( [ 'GB', 'CA', 'AU' ].includes( countryCode ) ) {
plugins = [ 'woocommerce-shipstation-integration' ];
} else if ( 'US' === countryCode ) {
plugins = [ 'jetpack', 'woocommerce-services' ];
plugins = [ 'woocommerce-services' ];
if ( ! isJetpackConnected ) {
plugins.push( 'jetpack' );
}
}
const steps = [
@ -275,7 +279,9 @@ class Shipping extends Component {
export default compose(
withSelect( select => {
const { getSettings, getSettingsError, isGetSettingsRequesting } = select( 'wc-api' );
const { getSettings, getSettingsError, isGetSettingsRequesting, isJetpackConnected } = select(
'wc-api'
);
const settings = getSettings( 'general' );
const isSettingsError = Boolean( getSettingsError( 'general' ) );
@ -287,7 +293,14 @@ export default compose(
const country = countryCode ? countries.find( c => c.code === countryCode ) : null;
const countryName = country ? country.name : null;
return { countryCode, countryName, isSettingsError, isSettingsRequesting, settings };
return {
countryCode,
countryName,
isJetpackConnected: isJetpackConnected(),
isSettingsError,
isSettingsRequesting,
settings,
};
} ),
withDispatch( dispatch => {
const { createNotice } = dispatch( 'core/notices' );