From a2a1a356cbc4cdae85443686a11eb2fe63ab4737 Mon Sep 17 00:00:00 2001 From: Ben Bowler Date: Fri, 11 Oct 2024 14:19:51 +0100 Subject: [PATCH] Update Ads module setup for PAX users. --- .../ads/components/setup/SetupMainPAX.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/assets/js/modules/ads/components/setup/SetupMainPAX.js b/assets/js/modules/ads/components/setup/SetupMainPAX.js index e97a5f9fe10..110bca40f6e 100644 --- a/assets/js/modules/ads/components/setup/SetupMainPAX.js +++ b/assets/js/modules/ads/components/setup/SetupMainPAX.js @@ -28,6 +28,7 @@ import { createInterpolateElement, Fragment, useCallback, + useEffect, useRef, } from '@wordpress/element'; import { __, _x } from '@wordpress/i18n'; @@ -37,7 +38,7 @@ import { addQueryArgs } from '@wordpress/url'; * Internal dependencies */ import { useSelect, useDispatch, useRegistry } from 'googlesitekit-data'; -import { SpinnerButton } from 'googlesitekit-components'; +import { ProgressBar, SpinnerButton } from 'googlesitekit-components'; import AdsIcon from '../../../../../svg/graphics/ads.svg'; import SetupForm from './SetupForm'; import SupportLink from '../../../../components/SupportLink'; @@ -57,6 +58,7 @@ import { PAX_SETUP_STEP, PAX_SETUP_SUCCESS_NOTIFICATION, } from '../../pax/constants'; +import { useFeature } from '../../../../hooks/useFeature'; export default function SetupMainPAX( { finishSetup } ) { const [ showPaxAppQueryParam, setShowPaxAppQueryParam ] = @@ -155,6 +157,14 @@ export default function SetupMainPAX( { finishSetup } ) { paxAppRef.current = app; }, [] ); + const isAdsPaxEnabled = useFeature( 'adsPax' ); + + useEffect( () => { + if ( isAdsPaxEnabled ) { + createAccount(); + } + }, [ isAdsPaxEnabled, createAccount ] ); + return (
@@ -169,6 +179,8 @@ export default function SetupMainPAX( { finishSetup } ) {
+ { isAdsPaxEnabled && ! showPaxAppStep && } + { ! isAdBlockerActive && PAX_SETUP_STEP.LAUNCH === showPaxAppStep && hasAdwordsScope && ( @@ -180,7 +192,8 @@ export default function SetupMainPAX( { finishSetup } ) { /> ) } - { ! isAdBlockerActive && + { ! isAdsPaxEnabled && + ! isAdBlockerActive && ( ! showPaxAppStep || ! hasAdwordsScope ) && (