Skip to content

Commit

Permalink
Allow woocommerce-payments to be included in the WooCommerce Core Pro…
Browse files Browse the repository at this point in the history
…filer (#94911)

* Allow more from values to determine woo core profiler flow

* Remove snake_case var

* Check authQuery for core profiler
  • Loading branch information
moon0326 authored Sep 26, 2024
1 parent 6be3bf9 commit a3e6ad3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion client/jetpack-connect/authorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { canCurrentUser } from 'calypso/state/selectors/can-current-user';
import getPartnerIdFromQuery from 'calypso/state/selectors/get-partner-id-from-query';
import getPartnerSlugFromQuery from 'calypso/state/selectors/get-partner-slug-from-query';
import isVipSite from 'calypso/state/selectors/is-vip-site';
import isWooCommerceCoreProfilerFlow from 'calypso/state/selectors/is-woocommerce-core-profiler-flow';
import siteHasFeature from 'calypso/state/selectors/site-has-feature';
import { getSite, isRequestingSite, isRequestingSites } from 'calypso/state/sites/selectors';
import AuthFormHeader from './auth-form-header';
Expand Down Expand Up @@ -124,6 +125,7 @@ export class JetpackAuthorize extends Component {
isFetchingSites: PropTypes.bool,
isSiteBlocked: PropTypes.bool,
isRequestingSitePurchases: PropTypes.bool,
isWooCoreProfiler: PropTypes.bool,
recordTracksEvent: PropTypes.func.isRequired,
siteHasJetpackPaidProduct: PropTypes.bool,
retryAuth: PropTypes.func.isRequired,
Expand Down Expand Up @@ -456,7 +458,7 @@ export class JetpackAuthorize extends Component {

isWooCoreProfiler( props = this.props ) {
const { from } = props.authQuery;
return 'woocommerce-core-profiler' === from;
return 'woocommerce-core-profiler' === from || this.props.isWooCoreProfiler;
}

getWooDnaConfig( props = this.props ) {
Expand Down Expand Up @@ -1322,6 +1324,7 @@ const connectComponent = connect(
isRequestingSitePurchases: isFetchingSitePurchases( state ),
isSiteBlocked: isSiteBlockedSelector( state ),
isVip: isVipSite( state, authQuery.clientId ),
isWooCoreProfiler: isWooCommerceCoreProfilerFlow( state ),
mobileAppRedirect,
partnerID: getPartnerIdFromQuery( state ),
partnerSlug: getPartnerSlugFromQuery( state ),
Expand Down
5 changes: 4 additions & 1 deletion client/jetpack-connect/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
errorNotice as errorNoticeAction,
warningNotice as warningNoticeAction,
} from 'calypso/state/notices/actions';
import isWooCommerceCoreProfilerFlow from 'calypso/state/selectors/is-woocommerce-core-profiler-flow';
import AuthFormHeader from './auth-form-header';
import HelpButton from './help-button';
import MainWrapper from './main-wrapper';
Expand All @@ -65,6 +66,7 @@ export class JetpackSignup extends Component {
createAccount: PropTypes.func.isRequired,
recordTracksEvent: PropTypes.func.isRequired,
translate: PropTypes.func.isRequired,
isWooCoreProfiler: PropTypes.bool,
};

state = {
Expand Down Expand Up @@ -129,7 +131,7 @@ export class JetpackSignup extends Component {

isWooCoreProfiler( props = this.props ) {
const { from } = props.authQuery;
return 'woocommerce-core-profiler' === from;
return 'woocommerce-core-profiler' === from || this.props.isWooCoreProfiler;
}

getWooDnaConfig() {
Expand Down Expand Up @@ -568,6 +570,7 @@ const connectComponent = connect(
usernameOrEmail: getLastCheckedUsernameOrEmail( state ),
isFullLoginFormVisible: !! getAuthAccountType( state ),
redirectTo: getRedirectToOriginal( state ),
isWooCoreProfiler: isWooCommerceCoreProfilerFlow( state ),
} ),
{
createAccount: createAccountAction,
Expand Down
5 changes: 3 additions & 2 deletions client/state/selectors/is-woocommerce-core-profiler-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import type { AppState } from 'calypso/types';
* @returns {?boolean} Whether the user reached Calypso via the WooCommerce Core Profiler flow
*/
export const isWooCommerceCoreProfilerFlow = ( state: AppState ): boolean => {
const allowedFrom = [ 'woocommerce-core-profiler', 'woocommerce-payments' ];
return (
'woocommerce-core-profiler' === get( getCurrentQueryArguments( state ), 'from' ) ||
'woocommerce-core-profiler' === get( getInitialQueryArguments( state ), 'from' ) ||
allowedFrom.includes( get( getInitialQueryArguments( state ), 'from' ) as string ) ||
allowedFrom.includes( get( getCurrentQueryArguments( state ), 'from' ) as string ) ||
( config.isEnabled( 'woocommerce/core-profiler-passwordless-auth' ) &&
new URLSearchParams( state.login?.redirectTo?.original ).get( 'from' ) ===
'woocommerce-core-profiler' )
Expand Down

0 comments on commit a3e6ad3

Please sign in to comment.