From 545b6c634fa0c652951e2661e692469f79ab1262 Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Wed, 14 Feb 2024 20:15:21 +0530 Subject: [PATCH 1/3] disable back button in old flow from error state --- .../SiteBuildHeader/step-navigation.js | 38 ++++++++++++------- .../components/SiteGenError/index.js | 3 ++ .../components/StartOptions/index.js | 3 ++ src/OnboardingSPA/store/actions.js | 6 +++ src/OnboardingSPA/store/reducer.js | 5 +++ 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/OnboardingSPA/components/Header/components/SiteBuildHeader/step-navigation.js b/src/OnboardingSPA/components/Header/components/SiteBuildHeader/step-navigation.js index 538225de9..7748abe96 100644 --- a/src/OnboardingSPA/components/Header/components/SiteBuildHeader/step-navigation.js +++ b/src/OnboardingSPA/components/Header/components/SiteBuildHeader/step-navigation.js @@ -13,6 +13,7 @@ import { sendOnboardingEvent, } from '../../../../utils/analytics/hiive'; import { ACTION_ONBOARDING_COMPLETE } from '../../../../utils/analytics/hiive/constants'; +import { stepWelcome } from '../../../../steps/GetStarted/Welcome/step'; /** * Back step Navigation button. @@ -21,7 +22,7 @@ import { ACTION_ONBOARDING_COMPLETE } from '../../../../utils/analytics/hiive/co * * @return {WPComponent} Back Component */ -const Back = ( { path, showErrorDialog } ) => { +const Back = ( { path, showErrorDialog, disabled } ) => { const { setNavErrorContinuePath } = useDispatch( nfdOnboardingStore ); const navigate = useNavigate(); const navigateBack = () => { @@ -36,6 +37,7 @@ const Back = ( { path, showErrorDialog } ) => { className="navigation-buttons navigation-buttons_back" onClick={ navigateBack } variant="secondary" + disabled={ disabled } > { __( 'Back', 'wp-module-onboarding' ) } @@ -108,19 +110,22 @@ const Finish = ( { currentData, saveDataAndExitFunc } ) => ( * @return {WPComponent} StepNavigation Component */ const StepNavigation = () => { - const { previousStep, nextStep, currentData, showErrorDialog } = useSelect( - ( select ) => { - return { - nextStep: select( nfdOnboardingStore ).getNextStep(), - previousStep: select( nfdOnboardingStore ).getPreviousStep(), - currentData: - select( nfdOnboardingStore ).getCurrentOnboardingData(), - showErrorDialog: - select( nfdOnboardingStore ).getShowErrorDialog(), - }; - }, - [] - ); + const { + currentStep, + previousStep, + nextStep, + currentData, + showErrorDialog, + } = useSelect( ( select ) => { + return { + currentStep: select( nfdOnboardingStore ).getCurrentStep(), + nextStep: select( nfdOnboardingStore ).getNextStep(), + previousStep: select( nfdOnboardingStore ).getPreviousStep(), + currentData: + select( nfdOnboardingStore ).getCurrentOnboardingData(), + showErrorDialog: select( nfdOnboardingStore ).getShowErrorDialog(), + }; + }, [] ); const isFirstStep = null === previousStep || false === previousStep; const isLastStep = null === nextStep || false === nextStep; return ( @@ -130,6 +135,11 @@ const StepNavigation = () => { ) } { isLastStep ? ( diff --git a/src/OnboardingSPA/components/SiteGenError/index.js b/src/OnboardingSPA/components/SiteGenError/index.js index 7202ba969..bf2740c3f 100644 --- a/src/OnboardingSPA/components/SiteGenError/index.js +++ b/src/OnboardingSPA/components/SiteGenError/index.js @@ -33,6 +33,7 @@ const SiteGenSiteError = () => { updateInitialize, setCurrentOnboardingData, updateSiteGenErrorStatus, + setContinueWithoutAi, } = useDispatch( nfdOnboardingStore ); useEffect( () => { @@ -75,6 +76,8 @@ const SiteGenSiteError = () => { window.nfdOnboarding.currentFlow = newFlow; currentData.activeFlow = newFlow; + currentData.continueWithoutAi = true; + setContinueWithoutAi(true); setCurrentOnboardingData( currentData ); if ( SITEGEN_FLOW !== newFlow ) { updateInitialize( true ); diff --git a/src/OnboardingSPA/components/StartOptions/index.js b/src/OnboardingSPA/components/StartOptions/index.js index 6dbb43305..45d125f1e 100644 --- a/src/OnboardingSPA/components/StartOptions/index.js +++ b/src/OnboardingSPA/components/StartOptions/index.js @@ -24,6 +24,7 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => { updateDesignRoutes, updateInitialize, setCurrentOnboardingData, + setContinueWithoutAi, } = useDispatch( nfdOnboardingStore ); const switchFlow = ( newFlow ) => { @@ -43,6 +44,8 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => { window.nfdOnboarding.currentFlow = newFlow; currentData.activeFlow = newFlow; + currentData.continueWithoutAi = false; + setContinueWithoutAi( false ); setCurrentOnboardingData( currentData ); if ( SITEGEN_FLOW !== newFlow ) { updateInitialize( true ); diff --git a/src/OnboardingSPA/store/actions.js b/src/OnboardingSPA/store/actions.js index 283681925..cb1ae8a20 100644 --- a/src/OnboardingSPA/store/actions.js +++ b/src/OnboardingSPA/store/actions.js @@ -326,3 +326,9 @@ export function updateSiteGenErrorStatus( siteGenErrorStatus ) { siteGenErrorStatus, }; } +export function setContinueWithoutAi( continueWithoutAi ) { + return { + type: 'SET_FLOW_WITHOUT_AI', + continueWithoutAi, + }; +} \ No newline at end of file diff --git a/src/OnboardingSPA/store/reducer.js b/src/OnboardingSPA/store/reducer.js index f20e80ae7..157a9954b 100644 --- a/src/OnboardingSPA/store/reducer.js +++ b/src/OnboardingSPA/store/reducer.js @@ -121,6 +121,11 @@ export function flow( ...state, chapter: action.chapter, }; + case 'SET_FLOW_WITHOUT_AI': + return { + ...state, + flow: action.continueWithoutAi, + }; } return state; From 7b14db83332bce255da794a13588b8e38c3cf0d2 Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Thu, 15 Feb 2024 12:07:22 +0530 Subject: [PATCH 2/3] Update index.js --- src/OnboardingSPA/components/SiteGenError/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OnboardingSPA/components/SiteGenError/index.js b/src/OnboardingSPA/components/SiteGenError/index.js index bf2740c3f..e430dfec1 100644 --- a/src/OnboardingSPA/components/SiteGenError/index.js +++ b/src/OnboardingSPA/components/SiteGenError/index.js @@ -79,6 +79,7 @@ const SiteGenSiteError = () => { currentData.continueWithoutAi = true; setContinueWithoutAi(true); setCurrentOnboardingData( currentData ); + updateSiteGenErrorStatus( false ); if ( SITEGEN_FLOW !== newFlow ) { updateInitialize( true ); } From ae9146098f6afd931cc4b69b6b9243336e0d0ca8 Mon Sep 17 00:00:00 2001 From: "lokapure.girish" Date: Wed, 28 Feb 2024 16:43:47 +0530 Subject: [PATCH 3/3] lint fixes --- src/OnboardingSPA/components/SiteGenError/index.js | 2 +- src/OnboardingSPA/store/actions.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OnboardingSPA/components/SiteGenError/index.js b/src/OnboardingSPA/components/SiteGenError/index.js index e430dfec1..ffe239d2b 100644 --- a/src/OnboardingSPA/components/SiteGenError/index.js +++ b/src/OnboardingSPA/components/SiteGenError/index.js @@ -77,7 +77,7 @@ const SiteGenSiteError = () => { window.nfdOnboarding.currentFlow = newFlow; currentData.activeFlow = newFlow; currentData.continueWithoutAi = true; - setContinueWithoutAi(true); + setContinueWithoutAi( true ); setCurrentOnboardingData( currentData ); updateSiteGenErrorStatus( false ); if ( SITEGEN_FLOW !== newFlow ) { diff --git a/src/OnboardingSPA/store/actions.js b/src/OnboardingSPA/store/actions.js index 745514b05..af82d6321 100644 --- a/src/OnboardingSPA/store/actions.js +++ b/src/OnboardingSPA/store/actions.js @@ -338,4 +338,4 @@ export function setContinueWithoutAi( continueWithoutAi ) { type: 'SET_FLOW_WITHOUT_AI', continueWithoutAi, }; -} \ No newline at end of file +}