From 8353bc01cfa7b55374af5449614241f1407d546f Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Tue, 27 Feb 2024 14:33:48 +0530 Subject: [PATCH 1/8] updated fork: redirect to old flow if ai sitegen is false --- src/OnboardingSPA/steps/TheFork/index.js | 36 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/OnboardingSPA/steps/TheFork/index.js b/src/OnboardingSPA/steps/TheFork/index.js index 1ee659af7..7ad49c95b 100644 --- a/src/OnboardingSPA/steps/TheFork/index.js +++ b/src/OnboardingSPA/steps/TheFork/index.js @@ -10,16 +10,22 @@ import { pluginDashboardPage, } from '../../../constants'; -import { DEFAULT_FLOW } from '../../data/flows/constants'; +import { DEFAULT_FLOW, SITEGEN_FLOW } from '../../data/flows/constants'; import HeadingWithSubHeading from '../../components/HeadingWithSubHeading/SiteGen/index'; import StartOptions from '../../components/StartOptions'; import getContents from './contents'; import SitegenAiStateHandler from '../../components/StateHandlers/SitegenAi'; +import { validateFlow } from '../../data/flows/utils'; +import { resolveGetDataForFlow } from '../../data/flows'; +import { useNavigate } from 'react-router-dom'; const TheFork = () => { - const { migrationUrl } = useSelect( ( select ) => { + const { migrationUrl, brandConfig, currentData } = useSelect( ( select ) => { return { migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(), + brandConfig: select( nfdOnboardingStore ).getNewfoldBrandConfig(), + currentData: + select( nfdOnboardingStore ).getCurrentOnboardingData(), }; } ); @@ -31,6 +37,12 @@ const TheFork = () => { setIsHeaderNavigationEnabled, setFooterActiveView, setHideFooterNav, + updateAllSteps, + updateTopSteps, + updateRoutes, + updateDesignRoutes, + updateInitialize, + setCurrentOnboardingData, } = useDispatch( nfdOnboardingStore ); useEffect( () => { @@ -42,6 +54,26 @@ const TheFork = () => { setDrawerActiveView( false ); setFooterActiveView( FOOTER_SITEGEN ); } ); + const navigate = useNavigate(); + useEffect( () => { + 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 From 2f3f450994c690273463c1c0bd83b7dea31a1ec2 Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Tue, 27 Feb 2024 14:37:35 +0530 Subject: [PATCH 2/8] Update index.js --- src/OnboardingSPA/steps/TheFork/index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/OnboardingSPA/steps/TheFork/index.js b/src/OnboardingSPA/steps/TheFork/index.js index 7ad49c95b..ebd094ce5 100644 --- a/src/OnboardingSPA/steps/TheFork/index.js +++ b/src/OnboardingSPA/steps/TheFork/index.js @@ -20,14 +20,17 @@ 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, brandConfig, currentData } = useSelect( + ( select ) => { + return { + migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(), + brandConfig: + select( nfdOnboardingStore ).getNewfoldBrandConfig(), + currentData: + select( nfdOnboardingStore ).getCurrentOnboardingData(), + }; + } + ); const { setIsHeaderEnabled, From fb9de19c836547a8803537bb114df112d12ff843 Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Tue, 27 Feb 2024 15:36:28 +0530 Subject: [PATCH 3/8] Update index.js --- src/OnboardingSPA/steps/TheFork/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/OnboardingSPA/steps/TheFork/index.js b/src/OnboardingSPA/steps/TheFork/index.js index ebd094ce5..a0cba9a21 100644 --- a/src/OnboardingSPA/steps/TheFork/index.js +++ b/src/OnboardingSPA/steps/TheFork/index.js @@ -48,7 +48,10 @@ const TheFork = () => { setCurrentOnboardingData, } = useDispatch( nfdOnboardingStore ); + const navigate = useNavigate(); + useEffect( () => { + checkHasAiAccess(); setHideFooterNav( true ); setIsHeaderEnabled( false ); setSidebarActiveView( false ); @@ -57,8 +60,8 @@ const TheFork = () => { setDrawerActiveView( false ); setFooterActiveView( FOOTER_SITEGEN ); } ); - const navigate = useNavigate(); - useEffect( () => { + + const checkHasAiAccess = () => { if ( false === validateFlow( brandConfig, SITEGEN_FLOW ) ) { const currentFlow = window.nfdOnboarding.currentFlow; const getData = resolveGetDataForFlow( DEFAULT_FLOW ); @@ -76,8 +79,7 @@ const TheFork = () => { updateInitialize( true ); navigate( data.steps[ 1 ].path ); } - } ); - + }; const oldFlow = window.nfdOnboarding?.oldFlow ? window.nfdOnboarding.oldFlow : DEFAULT_FLOW; From dcafcf443053f90c74f6ae9d7174a609373e34a0 Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Wed, 28 Feb 2024 12:41:11 +0530 Subject: [PATCH 4/8] added handling in flows --- .../components/StartOptions/index.js | 5 ++- src/OnboardingSPA/data/flows/default.js | 10 ++++- src/OnboardingSPA/data/flows/ecommerce.js | 11 ++++- src/OnboardingSPA/steps/TheFork/index.js | 40 ++----------------- 4 files changed, 24 insertions(+), 42 deletions(-) diff --git a/src/OnboardingSPA/components/StartOptions/index.js b/src/OnboardingSPA/components/StartOptions/index.js index 6dbb43305..ab4514145 100644 --- a/src/OnboardingSPA/components/StartOptions/index.js +++ b/src/OnboardingSPA/components/StartOptions/index.js @@ -30,6 +30,7 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => { if ( ! validateFlow( brandConfig, newFlow ) ) { return false; } + window.nfdOnboarding.currentBrand = brandConfig; const currentFlow = window.nfdOnboarding.currentFlow; const getData = resolveGetDataForFlow( newFlow ); const data = getData(); @@ -46,8 +47,10 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => { setCurrentOnboardingData( currentData ); if ( SITEGEN_FLOW !== newFlow ) { updateInitialize( true ); + navigate( data.steps[ 0 ].path ); + } else { + navigate( data.steps[ 1 ].path ); } - navigate( data.steps[ 1 ].path ); }; const selectFlow = ( flow ) => { switch ( flow ) { diff --git a/src/OnboardingSPA/data/flows/default.js b/src/OnboardingSPA/data/flows/default.js index f7b3740c1..7ace3da04 100644 --- a/src/OnboardingSPA/data/flows/default.js +++ b/src/OnboardingSPA/data/flows/default.js @@ -13,6 +13,8 @@ import { indexPage } from '../../pages/IndexPage/page'; import { brush } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; import { stepTheFork } from '../../steps/TheFork/step'; +import { validateFlow } from '../../data/flows/utils'; +import { SITEGEN_FLOW } from '../../data/flows/constants'; export const pages = [ indexPage, errorPage ]; @@ -20,7 +22,9 @@ export const initialChapters = [ demographic, design, layoutContent, features ]; export const getSteps = ( chapters = initialChapters ) => { let steps = []; - steps.push( stepTheFork ); + if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { + steps.push( stepTheFork ); + } steps.push( stepWelcome ); chapters.forEach( ( chapter ) => { steps = steps.concat( [ @@ -34,7 +38,9 @@ export const getSteps = ( chapters = initialChapters ) => { export const getRoutes = ( chapters = initialChapters ) => { let routes = [ ...pages ]; - routes.push( stepTheFork ); + if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { + routes.push( stepTheFork ); + } routes.push( stepWelcome ); chapters.forEach( ( chapter ) => { routes = routes.concat( [ diff --git a/src/OnboardingSPA/data/flows/ecommerce.js b/src/OnboardingSPA/data/flows/ecommerce.js index 68bca7e04..687358b89 100644 --- a/src/OnboardingSPA/data/flows/ecommerce.js +++ b/src/OnboardingSPA/data/flows/ecommerce.js @@ -19,6 +19,8 @@ import { filter } from 'lodash'; import { store } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; import { stepTheFork } from '../../steps/TheFork/step'; +import { validateFlow } from '../../data/flows/utils'; +import { SITEGEN_FLOW } from '../../data/flows/constants'; export const pages = [ indexPage, errorPage ]; @@ -32,7 +34,10 @@ export const initialChapters = [ export const getSteps = ( chapters = initialChapters ) => { let steps = []; - steps.push( stepTheFork ); + if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { + steps.push( stepTheFork ); + } + steps.push( stepWelcome ); chapters.forEach( ( chapter ) => { steps = steps.concat( [ @@ -49,7 +54,9 @@ export const getSteps = ( chapters = initialChapters ) => { export const getRoutes = ( chapters = initialChapters ) => { let routes = [ ...pages ]; - routes.push( stepTheFork ); + if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { + routes.push( stepTheFork ); + } routes.push( stepWelcome ); chapters.forEach( ( chapter ) => { routes = routes.concat( [ diff --git a/src/OnboardingSPA/steps/TheFork/index.js b/src/OnboardingSPA/steps/TheFork/index.js index a0cba9a21..2002aa8fa 100644 --- a/src/OnboardingSPA/steps/TheFork/index.js +++ b/src/OnboardingSPA/steps/TheFork/index.js @@ -10,24 +10,18 @@ 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'; import SitegenAiStateHandler from '../../components/StateHandlers/SitegenAi'; -import { validateFlow } from '../../data/flows/utils'; -import { resolveGetDataForFlow } from '../../data/flows'; -import { useNavigate } from 'react-router-dom'; const TheFork = () => { - const { migrationUrl, brandConfig, currentData } = useSelect( + const { migrationUrl } = useSelect( ( select ) => { return { migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(), - brandConfig: - select( nfdOnboardingStore ).getNewfoldBrandConfig(), - currentData: - select( nfdOnboardingStore ).getCurrentOnboardingData(), + }; } ); @@ -40,18 +34,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 ); @@ -61,25 +46,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; From 0c195cf9641963bf31cf72e0c9e099d430211640 Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Wed, 28 Feb 2024 13:18:23 +0530 Subject: [PATCH 5/8] lint fixes --- src/OnboardingSPA/data/flows/default.js | 8 ++++++-- src/OnboardingSPA/data/flows/ecommerce.js | 8 ++++++-- src/OnboardingSPA/steps/TheFork/index.js | 13 +++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/OnboardingSPA/data/flows/default.js b/src/OnboardingSPA/data/flows/default.js index 7ace3da04..a5d1c865c 100644 --- a/src/OnboardingSPA/data/flows/default.js +++ b/src/OnboardingSPA/data/flows/default.js @@ -22,7 +22,9 @@ export const initialChapters = [ demographic, design, layoutContent, features ]; export const getSteps = ( chapters = initialChapters ) => { let steps = []; - if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { + if ( + validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) + ) { steps.push( stepTheFork ); } steps.push( stepWelcome ); @@ -38,7 +40,9 @@ export const getSteps = ( chapters = initialChapters ) => { export const getRoutes = ( chapters = initialChapters ) => { let routes = [ ...pages ]; - if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { + if ( + validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) + ) { routes.push( stepTheFork ); } routes.push( stepWelcome ); diff --git a/src/OnboardingSPA/data/flows/ecommerce.js b/src/OnboardingSPA/data/flows/ecommerce.js index 687358b89..a63543778 100644 --- a/src/OnboardingSPA/data/flows/ecommerce.js +++ b/src/OnboardingSPA/data/flows/ecommerce.js @@ -34,7 +34,9 @@ export const initialChapters = [ export const getSteps = ( chapters = initialChapters ) => { let steps = []; - if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { + if ( + validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) + ) { steps.push( stepTheFork ); } @@ -54,7 +56,9 @@ export const getSteps = ( chapters = initialChapters ) => { export const getRoutes = ( chapters = initialChapters ) => { let routes = [ ...pages ]; - if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { + if ( + validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) + ) { routes.push( stepTheFork ); } routes.push( stepWelcome ); diff --git a/src/OnboardingSPA/steps/TheFork/index.js b/src/OnboardingSPA/steps/TheFork/index.js index 2002aa8fa..1ee659af7 100644 --- a/src/OnboardingSPA/steps/TheFork/index.js +++ b/src/OnboardingSPA/steps/TheFork/index.js @@ -17,14 +17,11 @@ import getContents from './contents'; import SitegenAiStateHandler from '../../components/StateHandlers/SitegenAi'; const TheFork = () => { - const { migrationUrl } = useSelect( - ( select ) => { - return { - migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(), - - }; - } - ); + const { migrationUrl } = useSelect( ( select ) => { + return { + migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(), + }; + } ); const { setIsHeaderEnabled, From e4734793d84b272a4adc2d7da581ce9fb0517f05 Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Wed, 28 Feb 2024 16:31:41 +0530 Subject: [PATCH 6/8] Revert "lint fixes" This reverts commit 0c195cf9641963bf31cf72e0c9e099d430211640. --- src/OnboardingSPA/data/flows/default.js | 8 ++------ src/OnboardingSPA/data/flows/ecommerce.js | 8 ++------ src/OnboardingSPA/steps/TheFork/index.js | 13 ++++++++----- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/OnboardingSPA/data/flows/default.js b/src/OnboardingSPA/data/flows/default.js index a5d1c865c..7ace3da04 100644 --- a/src/OnboardingSPA/data/flows/default.js +++ b/src/OnboardingSPA/data/flows/default.js @@ -22,9 +22,7 @@ export const initialChapters = [ demographic, design, layoutContent, features ]; export const getSteps = ( chapters = initialChapters ) => { let steps = []; - if ( - validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) - ) { + if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { steps.push( stepTheFork ); } steps.push( stepWelcome ); @@ -40,9 +38,7 @@ export const getSteps = ( chapters = initialChapters ) => { export const getRoutes = ( chapters = initialChapters ) => { let routes = [ ...pages ]; - if ( - validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) - ) { + if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { routes.push( stepTheFork ); } routes.push( stepWelcome ); diff --git a/src/OnboardingSPA/data/flows/ecommerce.js b/src/OnboardingSPA/data/flows/ecommerce.js index a63543778..687358b89 100644 --- a/src/OnboardingSPA/data/flows/ecommerce.js +++ b/src/OnboardingSPA/data/flows/ecommerce.js @@ -34,9 +34,7 @@ export const initialChapters = [ export const getSteps = ( chapters = initialChapters ) => { let steps = []; - if ( - validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) - ) { + if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { steps.push( stepTheFork ); } @@ -56,9 +54,7 @@ export const getSteps = ( chapters = initialChapters ) => { export const getRoutes = ( chapters = initialChapters ) => { let routes = [ ...pages ]; - if ( - validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) - ) { + if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { routes.push( stepTheFork ); } routes.push( stepWelcome ); diff --git a/src/OnboardingSPA/steps/TheFork/index.js b/src/OnboardingSPA/steps/TheFork/index.js index 1ee659af7..2002aa8fa 100644 --- a/src/OnboardingSPA/steps/TheFork/index.js +++ b/src/OnboardingSPA/steps/TheFork/index.js @@ -17,11 +17,14 @@ import getContents from './contents'; import SitegenAiStateHandler from '../../components/StateHandlers/SitegenAi'; const TheFork = () => { - const { migrationUrl } = useSelect( ( select ) => { - return { - migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(), - }; - } ); + const { migrationUrl } = useSelect( + ( select ) => { + return { + migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(), + + }; + } + ); const { setIsHeaderEnabled, From 830b87bfdd20d624299cbefed4666690ec49037f Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Wed, 28 Feb 2024 16:31:48 +0530 Subject: [PATCH 7/8] Revert "added handling in flows" This reverts commit dcafcf443053f90c74f6ae9d7174a609373e34a0. --- .../components/StartOptions/index.js | 5 +-- src/OnboardingSPA/data/flows/default.js | 10 +---- src/OnboardingSPA/data/flows/ecommerce.js | 11 +---- src/OnboardingSPA/steps/TheFork/index.js | 40 +++++++++++++++++-- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/OnboardingSPA/components/StartOptions/index.js b/src/OnboardingSPA/components/StartOptions/index.js index ab4514145..6dbb43305 100644 --- a/src/OnboardingSPA/components/StartOptions/index.js +++ b/src/OnboardingSPA/components/StartOptions/index.js @@ -30,7 +30,6 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => { if ( ! validateFlow( brandConfig, newFlow ) ) { return false; } - window.nfdOnboarding.currentBrand = brandConfig; const currentFlow = window.nfdOnboarding.currentFlow; const getData = resolveGetDataForFlow( newFlow ); const data = getData(); @@ -47,10 +46,8 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => { setCurrentOnboardingData( currentData ); if ( SITEGEN_FLOW !== newFlow ) { updateInitialize( true ); - navigate( data.steps[ 0 ].path ); - } else { - navigate( data.steps[ 1 ].path ); } + navigate( data.steps[ 1 ].path ); }; const selectFlow = ( flow ) => { switch ( flow ) { diff --git a/src/OnboardingSPA/data/flows/default.js b/src/OnboardingSPA/data/flows/default.js index 7ace3da04..f7b3740c1 100644 --- a/src/OnboardingSPA/data/flows/default.js +++ b/src/OnboardingSPA/data/flows/default.js @@ -13,8 +13,6 @@ import { indexPage } from '../../pages/IndexPage/page'; import { brush } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; import { stepTheFork } from '../../steps/TheFork/step'; -import { validateFlow } from '../../data/flows/utils'; -import { SITEGEN_FLOW } from '../../data/flows/constants'; export const pages = [ indexPage, errorPage ]; @@ -22,9 +20,7 @@ export const initialChapters = [ demographic, design, layoutContent, features ]; export const getSteps = ( chapters = initialChapters ) => { let steps = []; - if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { - steps.push( stepTheFork ); - } + steps.push( stepTheFork ); steps.push( stepWelcome ); chapters.forEach( ( chapter ) => { steps = steps.concat( [ @@ -38,9 +34,7 @@ export const getSteps = ( chapters = initialChapters ) => { export const getRoutes = ( chapters = initialChapters ) => { let routes = [ ...pages ]; - if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { - routes.push( stepTheFork ); - } + routes.push( stepTheFork ); routes.push( stepWelcome ); chapters.forEach( ( chapter ) => { routes = routes.concat( [ diff --git a/src/OnboardingSPA/data/flows/ecommerce.js b/src/OnboardingSPA/data/flows/ecommerce.js index 687358b89..68bca7e04 100644 --- a/src/OnboardingSPA/data/flows/ecommerce.js +++ b/src/OnboardingSPA/data/flows/ecommerce.js @@ -19,8 +19,6 @@ import { filter } from 'lodash'; import { store } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; import { stepTheFork } from '../../steps/TheFork/step'; -import { validateFlow } from '../../data/flows/utils'; -import { SITEGEN_FLOW } from '../../data/flows/constants'; export const pages = [ indexPage, errorPage ]; @@ -34,10 +32,7 @@ export const initialChapters = [ export const getSteps = ( chapters = initialChapters ) => { let steps = []; - if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { - steps.push( stepTheFork ); - } - + steps.push( stepTheFork ); steps.push( stepWelcome ); chapters.forEach( ( chapter ) => { steps = steps.concat( [ @@ -54,9 +49,7 @@ export const getSteps = ( chapters = initialChapters ) => { export const getRoutes = ( chapters = initialChapters ) => { let routes = [ ...pages ]; - if ( validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW ) ) { - routes.push( stepTheFork ); - } + routes.push( stepTheFork ); routes.push( stepWelcome ); chapters.forEach( ( chapter ) => { routes = routes.concat( [ diff --git a/src/OnboardingSPA/steps/TheFork/index.js b/src/OnboardingSPA/steps/TheFork/index.js index 2002aa8fa..a0cba9a21 100644 --- a/src/OnboardingSPA/steps/TheFork/index.js +++ b/src/OnboardingSPA/steps/TheFork/index.js @@ -10,18 +10,24 @@ import { pluginDashboardPage, } from '../../../constants'; -import { DEFAULT_FLOW } from '../../data/flows/constants'; +import { DEFAULT_FLOW, SITEGEN_FLOW } from '../../data/flows/constants'; import HeadingWithSubHeading from '../../components/HeadingWithSubHeading/SiteGen/index'; import StartOptions from '../../components/StartOptions'; import getContents from './contents'; import SitegenAiStateHandler from '../../components/StateHandlers/SitegenAi'; +import { validateFlow } from '../../data/flows/utils'; +import { resolveGetDataForFlow } from '../../data/flows'; +import { useNavigate } from 'react-router-dom'; const TheFork = () => { - const { migrationUrl } = useSelect( + const { migrationUrl, brandConfig, currentData } = useSelect( ( select ) => { return { migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(), - + brandConfig: + select( nfdOnboardingStore ).getNewfoldBrandConfig(), + currentData: + select( nfdOnboardingStore ).getCurrentOnboardingData(), }; } ); @@ -34,9 +40,18 @@ const TheFork = () => { setIsHeaderNavigationEnabled, setFooterActiveView, setHideFooterNav, + updateAllSteps, + updateTopSteps, + updateRoutes, + updateDesignRoutes, + updateInitialize, + setCurrentOnboardingData, } = useDispatch( nfdOnboardingStore ); + const navigate = useNavigate(); + useEffect( () => { + checkHasAiAccess(); setHideFooterNav( true ); setIsHeaderEnabled( false ); setSidebarActiveView( false ); @@ -46,6 +61,25 @@ 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; From 0574173496fbdc297cbc77c2a06c696c3c231ab3 Mon Sep 17 00:00:00 2001 From: Avneet Raj Date: Wed, 28 Feb 2024 16:44:46 +0530 Subject: [PATCH 8/8] remove back button in get started welcome step --- .../2-general-onboarding-flow/get-started-welcome.cy.js | 4 ++-- .../3-ecommerce-onboarding-flow/get-started-welcome.cy.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cypress/integration/2-general-onboarding-flow/get-started-welcome.cy.js b/tests/cypress/integration/2-general-onboarding-flow/get-started-welcome.cy.js index c07993ab1..3d569ec7d 100644 --- a/tests/cypress/integration/2-general-onboarding-flow/get-started-welcome.cy.js +++ b/tests/cypress/integration/2-general-onboarding-flow/get-started-welcome.cy.js @@ -84,8 +84,8 @@ describe( 'Get Started Welcome Page', function () { GetPluginName(); } ); - it( 'Check navigation back is visible', () => { - cy.get( '.navigation-buttons_back' ).should('exist'); + it( 'Check navigation back is not visible', () => { + cy.get( '.navigation-buttons_back' ).should('not.exist'); } ); it( 'Check if next step loads on clicking navigation next', () => { diff --git a/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-welcome.cy.js b/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-welcome.cy.js index 6f24fc950..0752c9380 100644 --- a/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-welcome.cy.js +++ b/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-welcome.cy.js @@ -83,8 +83,8 @@ describe( 'Get Started Welcome Page', function () { GetPluginName(); } ); - it( 'Check navigation back is visible', () => { - cy.get( '.navigation-buttons_back' ).should( 'exist' ); + it( 'Check navigation back is not visible', () => { + cy.get( '.navigation-buttons_back' ).should( 'not.exist' ); } ); it( 'Check if next step loads on clicking navigation next', () => {