diff --git a/src/OnboardingSPA/components/Header/components/SiteBuildHeader/step-navigation.js b/src/OnboardingSPA/components/Header/components/SiteBuildHeader/step-navigation.js
index 77f33c2ca..940c5543e 100644
--- a/src/OnboardingSPA/components/Header/components/SiteBuildHeader/step-navigation.js
+++ b/src/OnboardingSPA/components/Header/components/SiteBuildHeader/step-navigation.js
@@ -126,19 +126,9 @@ const StepNavigation = () => {
showErrorDialog: select( nfdOnboardingStore ).getShowErrorDialog(),
};
}, [] );
- let isFirstStep = null === previousStep || false === previousStep;
+ const isFirstStep = null === previousStep || false === previousStep;
const isLastStep = null === nextStep || false === nextStep;
- let isDisabled = false;
- if ( currentStep === stepWelcome ) {
- if ( currentData.continueWithoutAi === true ) {
- isFirstStep = false;
- isDisabled = false;
- } else {
- isFirstStep = true;
- }
- }
-
return (
@@ -146,7 +136,11 @@ const StepNavigation = () => {
) }
{ isLastStep ? (
diff --git a/src/OnboardingSPA/components/SiteGenError/index.js b/src/OnboardingSPA/components/SiteGenError/index.js
index ffe239d2b..788723f94 100644
--- a/src/OnboardingSPA/components/SiteGenError/index.js
+++ b/src/OnboardingSPA/components/SiteGenError/index.js
@@ -33,7 +33,6 @@ const SiteGenSiteError = () => {
updateInitialize,
setCurrentOnboardingData,
updateSiteGenErrorStatus,
- setContinueWithoutAi,
} = useDispatch( nfdOnboardingStore );
useEffect( () => {
@@ -77,7 +76,6 @@ const SiteGenSiteError = () => {
window.nfdOnboarding.currentFlow = newFlow;
currentData.activeFlow = newFlow;
currentData.continueWithoutAi = true;
- setContinueWithoutAi( true );
setCurrentOnboardingData( currentData );
updateSiteGenErrorStatus( false );
if ( SITEGEN_FLOW !== newFlow ) {
diff --git a/src/OnboardingSPA/components/StartOptions/index.js b/src/OnboardingSPA/components/StartOptions/index.js
index 2c9918619..3d400e248 100644
--- a/src/OnboardingSPA/components/StartOptions/index.js
+++ b/src/OnboardingSPA/components/StartOptions/index.js
@@ -48,7 +48,7 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => {
window.nfdOnboarding.currentFlow = newFlow;
currentData.activeFlow = newFlow;
- currentData.continueWithoutAi = true;
+ currentData.continueWithoutAi = false;
setCurrentOnboardingData( currentData );
if ( SITEGEN_FLOW !== newFlow ) {
updateInitialize( true );
diff --git a/src/OnboardingSPA/components/StateHandlers/Flow/index.js b/src/OnboardingSPA/components/StateHandlers/Flow/index.js
index 673daf52a..88b095d70 100644
--- a/src/OnboardingSPA/components/StateHandlers/Flow/index.js
+++ b/src/OnboardingSPA/components/StateHandlers/Flow/index.js
@@ -17,7 +17,14 @@ import { commerce } from '../../../chapters/commerce';
import EcommerceStepLoader from '../../Loaders/Step/Ecommerce';
import SiteBuild from '../../NewfoldInterfaceSkeleton/SiteBuild';
import SiteGen from '../../NewfoldInterfaceSkeleton/SiteGen';
-import { validateFlow } from '../../../data/flows/utils';
+import {
+ validateFlow,
+ removeFromAllSteps,
+ removeFromTopSteps,
+ removeFromRoutes,
+} from '../../../data/flows/utils';
+import { resolveGetDataForFlow } from '../../../data/flows';
+import { stepTheFork } from '../../../steps/TheFork/step';
const FlowStateHandler = () => {
const location = useLocation();
@@ -37,6 +44,9 @@ const FlowStateHandler = () => {
setSidebarActiveView,
setActiveFlow,
setActiveStep,
+ updateAllSteps,
+ updateTopSteps,
+ updateRoutes,
} = useDispatch( nfdOnboardingStore );
const handleCommerceFlow = async ( flow, retries = 0 ) => {
@@ -79,6 +89,28 @@ const FlowStateHandler = () => {
setSidebarActiveView( false );
};
+ const checkCapability = () => {
+ if ( ! validateFlow( brandConfig, SITEGEN_FLOW ) ) {
+ const getData = resolveGetDataForFlow( DEFAULT_FLOW );
+ const data = getData();
+
+ const updateAllStep = removeFromAllSteps( data.steps, [
+ stepTheFork,
+ ] );
+ updateAllSteps( updateAllStep.allSteps );
+
+ const updateTopStep = removeFromTopSteps( data?.topSteps, [
+ stepTheFork,
+ ] );
+ updateTopSteps( updateTopStep.topSteps );
+
+ const updateRoute = removeFromRoutes( data.routes, [
+ stepTheFork,
+ ] );
+ updateRoutes( updateRoute.routes );
+ }
+ };
+
useEffect( () => {
if ( window.nfdOnboarding?.newFlow ) {
const flow = window.nfdOnboarding.newFlow;
@@ -102,6 +134,7 @@ const FlowStateHandler = () => {
switch ( window.nfdOnboarding.currentFlow ) {
case DEFAULT_FLOW:
case ECOMMERCE_FLOW:
+ checkCapability();
return ;
case SITEGEN_FLOW:
return ;
diff --git a/src/OnboardingSPA/data/flows/utils.js b/src/OnboardingSPA/data/flows/utils.js
index 4fe3d68d0..2736a2a98 100644
--- a/src/OnboardingSPA/data/flows/utils.js
+++ b/src/OnboardingSPA/data/flows/utils.js
@@ -50,3 +50,29 @@ export const validateFlow = ( brandConfig, flow ) => {
}
return true;
};
+
+export const removeFromTopSteps = ( topSteps, conditionalSteps ) => {
+ const conditionalStepsPaths = new Set(
+ conditionalSteps.map( ( a ) => a.path )
+ );
+
+ return {
+ topSteps: filter(
+ topSteps,
+ ( topStep ) => ! conditionalStepsPaths.has( topStep.path )
+ ),
+ };
+};
+
+export const removeFromRoutes = ( routes, conditionalSteps ) => {
+ const conditionalStepsPaths = new Set(
+ conditionalSteps.map( ( a ) => a.path )
+ );
+
+ return {
+ routes: filter(
+ routes,
+ ( route ) => ! conditionalStepsPaths.has( route.path )
+ ),
+ };
+};
diff --git a/src/OnboardingSPA/steps/TheFork/index.js b/src/OnboardingSPA/steps/TheFork/index.js
index aef522165..81dcfbc8b 100644
--- a/src/OnboardingSPA/steps/TheFork/index.js
+++ b/src/OnboardingSPA/steps/TheFork/index.js
@@ -10,7 +10,7 @@ import {
pluginDashboardPage,
} from '../../../constants';
-import { DEFAULT_FLOW, SITEGEN_FLOW } from '../../data/flows/constants';
+import { DEFAULT_FLOW } from '../../data/flows/constants';
import HeadingWithSubHeading from '../../components/HeadingWithSubHeading/SiteGen/index';
import StartOptions from '../../components/StartOptions';
import getContents from './contents';
@@ -21,22 +21,13 @@ import {
trackOnboardingEvent,
} from '../../utils/analytics/hiive';
import { ACTION_SITEGEN_FORK_OPTION_SELECTED } from '../../utils/analytics/hiive/constants';
-import { validateFlow } from '../../data/flows/utils';
-import { resolveGetDataForFlow } from '../../data/flows';
-import { useNavigate } from 'react-router-dom';
const TheFork = () => {
- const { migrationUrl, brandConfig, currentData } = useSelect(
- ( select ) => {
- return {
- migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(),
- brandConfig:
- select( nfdOnboardingStore ).getNewfoldBrandConfig(),
- currentData:
- select( nfdOnboardingStore ).getCurrentOnboardingData(),
- };
- }
- );
+ const { migrationUrl } = useSelect( ( select ) => {
+ return {
+ migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(),
+ };
+ } );
const {
setIsHeaderEnabled,
@@ -46,18 +37,9 @@ const TheFork = () => {
setIsHeaderNavigationEnabled,
setFooterActiveView,
setHideFooterNav,
- updateAllSteps,
- updateTopSteps,
- updateRoutes,
- updateDesignRoutes,
- updateInitialize,
- setCurrentOnboardingData,
} = useDispatch( nfdOnboardingStore );
- const navigate = useNavigate();
-
useEffect( () => {
- checkHasAiAccess();
setHideFooterNav( true );
setIsHeaderEnabled( false );
setSidebarActiveView( false );
@@ -67,25 +49,6 @@ const TheFork = () => {
setFooterActiveView( FOOTER_SITEGEN );
} );
- const checkHasAiAccess = () => {
- if ( false === validateFlow( brandConfig, SITEGEN_FLOW ) ) {
- const currentFlow = window.nfdOnboarding.currentFlow;
- const getData = resolveGetDataForFlow( DEFAULT_FLOW );
- const data = getData();
- updateAllSteps( data.steps );
- updateTopSteps( data?.topSteps );
- updateRoutes( data.routes );
- updateDesignRoutes( data?.designRoutes );
- if ( SITEGEN_FLOW !== currentFlow ) {
- window.nfdOnboarding.oldFlow = currentFlow;
- }
- window.nfdOnboarding.currentFlow = DEFAULT_FLOW;
- currentData.activeFlow = DEFAULT_FLOW;
- setCurrentOnboardingData( currentData );
- updateInitialize( true );
- navigate( data.steps[ 1 ].path );
- }
- };
const oldFlow = window.nfdOnboarding?.oldFlow
? window.nfdOnboarding.oldFlow
: DEFAULT_FLOW;