Skip to content

Commit

Permalink
Merge pull request #478 from newfold-labs/remove-building-step-with-e…
Browse files Browse the repository at this point in the history
…rror-ui

Remove building step with error screen UI
  • Loading branch information
officiallygod authored Feb 28, 2024
2 parents 6cfcbde + b233bb2 commit e59a7ef
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 171 deletions.
3 changes: 1 addition & 2 deletions src/OnboardingSPA/chapters/siteGen/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { __ } from '@wordpress/i18n';

import { CHAPTER_SITEGEN_FEATURES } from '../../../constants';
import { Chapter } from '../../data/models/Chapter';
import { stepSiteGenBuilding } from '../../steps/SiteGen/Building/step';
import { stepSiteGenExperience } from '../../steps/SiteGen/Experience/step';

const steps = [ stepSiteGenExperience, stepSiteGenBuilding ];
const steps = [ stepSiteGenExperience ];

export const siteGenFeatures = new Chapter( {
id: CHAPTER_SITEGEN_FEATURES,
Expand Down
26 changes: 26 additions & 0 deletions src/OnboardingSPA/chapters/sitegen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { CHAPTER_SITEGEN } from '../../constants';
import { Chapter } from '../data/models/Chapter';
import { __ } from '@wordpress/i18n';
import { stepSiteGenWelcome } from '../steps/SiteGen/Welcome/step';
import { stepSiteGenSiteDetails } from '../steps/SiteGen/SiteDetails/step';
import { stepSiteGenSiteLogo } from '../steps/SiteGen/SiteLogo/step';
import { stepSiteGenSocialMedia } from '../steps/SiteGen/SocialMedia/step';
import { stepSiteGenExperience } from '../steps/SiteGen/Experience/step';
import { stepSiteGenPreview } from '../steps/SiteGen/Preview/step';
import { stepSiteGenEditor } from '../steps/SiteGen/Editor/step';

const steps = [
stepSiteGenWelcome,
stepSiteGenSiteDetails,
stepSiteGenSocialMedia,
stepSiteGenSiteLogo,
stepSiteGenExperience,
stepSiteGenPreview,
stepSiteGenEditor,
];

export const sitegen = new Chapter( {
id: CHAPTER_SITEGEN,
name: __( 'Site Generation', 'wp-module-onboarding' ),
steps,
} );
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const SiteGenLoader = ( { customNavPercentage, watcher = null } ) => {
}, [] );

useEffect( () => {
/* Divided the totalCount by 2 to complete the progress bar in the experience step */
const percentageValue =
( currentData?.sitegen?.siteGenMetaStatus?.currentStatus /
currentData?.sitegen?.siteGenMetaStatus?.totalCount ) *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef } from '@wordpress/element';
import { useEffect, useRef, useState } from '@wordpress/element';
import { store as coreStore } from '@wordpress/core-data';
import { useLocation } from 'react-router-dom';
import { useSelect, useDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -44,6 +44,13 @@ const ThemedNewfoldInterfaceSkeleton = themeToggleHOC(
);

const SiteGen = () => {
const [ failedApi, setFailedApi ] = useState( [] );

useEffect( () => {
document.body.classList.add( `nfd-brand-${ newfoldBrand }` );
}, [ newfoldBrand ] );
const location = useLocation();

const {
currentData,
initialize,
Expand Down Expand Up @@ -85,7 +92,6 @@ const SiteGen = () => {
useEffect( () => {
document.body.classList.add( `nfd-brand-${ newfoldBrand }` );
}, [ newfoldBrand ] );
const location = useLocation();

const prevSiteGenErrorStatus = useRef();

Expand Down Expand Up @@ -145,18 +151,21 @@ const SiteGen = () => {
retryCount + 1
);
}
updateSiteGenErrorStatus( true );

setFailedApi( ( prevState ) => {
if ( ! prevState.includes( identifier ) ) {
return [ ...prevState, identifier ];
}
return prevState;
} );
currentData.sitegen.siteGenErrorStatus = true;
setCurrentOnboardingData( currentData );
}
}

async function generateSiteGenData() {
// Start the API Requests when the loader is shown.
if (
! (
location.pathname.includes( 'experience' ) ||
location.pathname.includes( 'building' )
)
) {
if ( ! location.pathname.includes( 'experience' ) ) {
return;
}

Expand All @@ -167,24 +176,23 @@ const SiteGen = () => {
}, 1000 );
}

let identifiers = await getSiteGenIdentifiers();
identifiers = identifiers.body;
let identifiers;
if ( Array.isArray( failedApi ) && failedApi.length > 0 ) {
identifiers = failedApi;
setFailedApi( [] );
} else {
identifiers = await getSiteGenIdentifiers();
identifiers = identifiers.body;

const midIndex = Math.floor( identifiers.length / 2 );
if ( location.pathname.includes( 'experience' ) ) {
identifiers = identifiers.slice( 0, midIndex );
currentData.sitegen.siteGenMetaStatus.currentStatus = 0;
} else if ( location.pathname.includes( 'building' ) ) {
identifiers = identifiers.slice( midIndex );
currentData.sitegen.siteGenMetaStatus.currentStatus = midIndex;

setCurrentOnboardingData( currentData );
}
setCurrentOnboardingData( currentData );
const siteInfo = {
site_description: currentData.sitegen?.siteDetails?.prompt,
};

const skipCache = currentData.sitegen?.skipCache;

// Iterate over Identifiers and fire Requests!
identifiers.forEach( ( identifier ) => {
performSiteGenMetaGeneration( siteInfo, identifier, skipCache );
Expand Down Expand Up @@ -284,6 +292,7 @@ const SiteGen = () => {
initializeThemes();
initializeSettings();
getEditedEntityRecord( 'root', 'site' );
updateSiteGenErrorStatus( false );
}, [] );

Check warning on line 296 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'getEditedEntityRecord' and 'updateSiteGenErrorStatus'. Either include them or remove the dependency array

return (
Expand Down
50 changes: 0 additions & 50 deletions src/OnboardingSPA/steps/SiteGen/Building/index.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/OnboardingSPA/steps/SiteGen/Building/step.js

This file was deleted.

80 changes: 0 additions & 80 deletions src/OnboardingSPA/steps/SiteGen/Building/stylesheet.scss

This file was deleted.

2 changes: 1 addition & 1 deletion src/OnboardingSPA/steps/SiteGen/Experience/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const SiteGenExperience = () => {
<div className={ 'nfd-sg-experience-level' }>
<SiteGenLoader
watcher={ selection !== 0 ? true : false }
customNavPercentage={ 50 }
customNavPercentage={ 100 }
/>
<CardWithOptions
title={ content.heading }
Expand Down
1 change: 0 additions & 1 deletion src/OnboardingSPA/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
@import "../steps/SiteGen/SiteLogo/stylesheet";
@import "../steps/SiteGen/SocialMedia/stylesheet";
@import "../steps/SiteGen/Welcome/stylesheet";
@import "../steps/SiteGen/Building/stylesheet";
@import "../steps/SiteGen/Editor/stylesheet";
@import "../steps/SiteGen/Editor/Header/stylesheet";

Expand Down

0 comments on commit e59a7ef

Please sign in to comment.