From 7b23abe55222ba5b65f144637bce2fefe786dcdb Mon Sep 17 00:00:00 2001 From: Vara Date: Thu, 14 Mar 2024 11:39:59 +0530 Subject: [PATCH] Add DesignStateHandler to Sitegen Editor step --- .../steps/SiteGen/Editor/index.js | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/OnboardingSPA/steps/SiteGen/Editor/index.js b/src/OnboardingSPA/steps/SiteGen/Editor/index.js index 0d759de6d..e10fcb3ea 100644 --- a/src/OnboardingSPA/steps/SiteGen/Editor/index.js +++ b/src/OnboardingSPA/steps/SiteGen/Editor/index.js @@ -4,7 +4,7 @@ import { useEffect, useState } from '@wordpress/element'; import { useDispatch, useSelect } from '@wordpress/data'; import { store as nfdOnboardingStore } from '../../../store'; -import { HEADER_SITEGEN } from '../../../../constants'; +import { HEADER_SITEGEN, THEME_STATUS_ACTIVE } from '../../../../constants'; import { LivePreview } from '../../../components/LivePreview'; import { getGlobalStyles } from '../../../utils/api/themes'; @@ -12,6 +12,7 @@ import { getGlobalStyles } from '../../../utils/api/themes'; // eslint-disable-next-line import/no-extraneous-dependencies import { cloneDeep } from 'lodash'; import { publishSitemapPages } from '../../../utils/api/siteGen'; +import { DesignStateHandler } from '../../../components/StateHandlers'; const StepSiteGenEditor = () => { const [ homepage, setHomepage ] = useState( false ); @@ -25,10 +26,11 @@ const StepSiteGenEditor = () => { setIsHeaderNavigationEnabled, } = useDispatch( nfdOnboardingStore ); - const { currentData } = useSelect( ( select ) => { + const { currentData, themeStatus } = useSelect( ( select ) => { return { currentData: select( nfdOnboardingStore ).getCurrentOnboardingData(), + themeStatus: select( nfdOnboardingStore ).getThemeStatus(), }; } ); @@ -57,12 +59,14 @@ const StepSiteGenEditor = () => { }; useEffect( () => { - setIsHeaderEnabled( true ); - setHeaderActiveView( HEADER_SITEGEN ); - setDrawerActiveView( false ); - loadData(); - handleSitemapPagesGeneration(); - }, [] ); + if ( THEME_STATUS_ACTIVE === themeStatus ) { + setIsHeaderEnabled( true ); + setHeaderActiveView( HEADER_SITEGEN ); + setDrawerActiveView( false ); + loadData(); + handleSitemapPagesGeneration(); + } + }, [ themeStatus ] ); useEffect( () => { if ( currentData?.sitegen?.homepages?.active ) { @@ -117,15 +121,17 @@ const StepSiteGenEditor = () => { }; return ( - -
- { buildPreview() } -
-
-
+ + +
+ { buildPreview() } +
+
+
+
); };