Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site error page #445

Merged
merged 16 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}
);

const { setCurrentOnboardingData } = useDispatch( nfdOnboardingStore );
const { setCurrentOnboardingData, updateSiteGenErrorStatus } = useDispatch( nfdOnboardingStore );

Check failure on line 56 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `·` with `⏎↹↹`

async function syncStoreToDB() {
if ( currentData ) {
Expand All @@ -68,7 +68,8 @@
skipCache,
retryCount = 1
) {
return new Promise( () =>

Check failure on line 71 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Delete `⏎`

generateSiteGenMeta( siteInfo, identifier, skipCache )
.then( ( data ) => {
if ( data.body !== null ) {
Expand All @@ -82,10 +83,14 @@
retryCount + 1
);
}
if ( retryCount === MAX_RETRIES_SITE_GEN ) {
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
updateSiteGenErrorStatus( true );
}
} )
.catch( ( err ) => {
/* eslint-disable no-console */
console.log( err );
updateSiteGenErrorStatus( true );
} )
);
}
Expand Down Expand Up @@ -146,20 +151,20 @@
initializePlugins( pluginInstallHash );
setInterval( cronTrigger, 45000 );
}
}, [ initialize ] );

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

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'pluginInstallHash'. Either include it or remove the dependency array

useEffect( () => {
syncStoreToDB();
generateSiteGenData();
handlePreviousStepTracking();
}, [ location.pathname ] );

Check warning on line 160 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: 'generateSiteGenData', 'handlePreviousStepTracking', and 'syncStoreToDB'. Either include them or remove the dependency array

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

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'pluginInstallHash'. Either include it or remove the dependency array
useEffect( () => {
initializeThemes();
initializeSettings();
}, [] );

return (

Check warning on line 167 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: 'generateSiteGenData', 'handlePreviousStepTracking', and 'syncStoreToDB'. Either include them or remove the dependency array
<ThemeProvider>
<ThemedNewfoldInterfaceSkeleton
id={ 'nfd-onboarding-skeleton--sitegen' }
Expand Down
20 changes: 20 additions & 0 deletions src/OnboardingSPA/components/SiteGenError/contents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { __ } from '@wordpress/i18n';

const getContents = () => {
return {
heading: __( 'Sorry, we\'re having trouble communicating with our AI service.', 'wp-module-onboarding' ),

Check failure on line 5 in src/OnboardingSPA/components/SiteGenError/contents.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `·'Sorry,·we\'re·having·trouble·communicating·with·our·AI·service.',·'wp-module-onboarding'·` with `⏎↹↹↹"Sorry,·we're·having·trouble·communicating·with·our·AI·service.",⏎↹↹↹'wp-module-onboarding'⏎↹↹`
subHeading: __(
'Do you keep getting this error?',
'wp-module-onboarding'
),
message: __(
'If you continue to get this error, you may either continue creating your site without using our AI assistant, or you can ',
'wp-module-onboarding'
),
buttonText: __( 'Try again', 'wp-module-onboarding' ),
buttonSkip: __( 'Continue without AI', 'wp-module-onboarding' ),
buttonExit: __( 'exit to WordPress', 'wp-module-onboarding' ),
};
};

export default getContents;
149 changes: 149 additions & 0 deletions src/OnboardingSPA/components/SiteGenError/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { useViewportMatch } from '@wordpress/compose';
import { useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import getContents from './contents';
import { Button, Fill } from '@wordpress/components';
import { store as nfdOnboardingStore } from '../../store';
import CommonLayout from '../Layouts/Common';
import OrbAnimation from '../OrbAnimation';
import { SITEGEN_FLOW, DEFAULT_FLOW } from '../../data/flows/constants';
import { validateFlow } from '../../data/flows/utils';
import { resolveGetDataForFlow } from '../../data/flows';
import { useNavigate } from 'react-router-dom';
import {
FOOTER_SITEGEN,
FOOTER_END,
HEADER_SITEGEN,
pluginDashboardPage,
} from '../../../constants';

const SiteGenSiteError = () => {
const navigate = useNavigate();
const {
setIsHeaderEnabled,
setSidebarActiveView,
setHeaderActiveView,
setDrawerActiveView,
setHideFooterNav,
setIsHeaderNavigationEnabled,
updateAllSteps,
updateTopSteps,
updateRoutes,
updateDesignRoutes,
updateInitialize,
setCurrentOnboardingData,
updateSiteGenErrorStatus,
} = useDispatch( nfdOnboardingStore );

useEffect( () => {
setHideFooterNav( true );
setIsHeaderEnabled( true );
setSidebarActiveView( false );
setHeaderActiveView( HEADER_SITEGEN );
setIsHeaderNavigationEnabled( true );
setDrawerActiveView( false );
} );

const { brandConfig, currentData } = useSelect( ( select ) => {
return {
brandConfig: select( nfdOnboardingStore ).getNewfoldBrandConfig(),
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
};
} );
const isLargeViewport = useViewportMatch( 'small' );

const content = getContents();
const oldFlow = window.nfdOnboarding?.oldFlow
? window.nfdOnboarding.oldFlow
: DEFAULT_FLOW;

const switchFlow = ( newFlow ) => {
if ( ! validateFlow( brandConfig, newFlow ) ) {
return false;
}
const currentFlow = window.nfdOnboarding.currentFlow;
const getData = resolveGetDataForFlow( newFlow );
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 = newFlow;
currentData.activeFlow = newFlow;
setCurrentOnboardingData( currentData );
if ( SITEGEN_FLOW !== newFlow ) {
updateInitialize( true );
}
navigate( data.steps[ 1 ].path );
};
const handleRetry = ( ) => {

Check failure on line 84 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Delete `·`
updateSiteGenErrorStatus( false );
window.location.reload();
};
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
return (
<CommonLayout className="nfd-onboarding-step--site-gen__error">
<div className="nfd-onboarding-step--site-gen__error__container">
<div className="nfd-onboarding-step--site-gen__error__container__orb">
<OrbAnimation height={ `100px` } />
</div>
<div className="nfd-onboarding-step--site-gen__error__container__heading">
<p className="nfd-onboarding-step--site-gen__error__container__heading__text">
{ content.heading }
</p>
</div>
<div className="nfd-onboarding-step--site-gen__error__container__sub-heading">
<p className="nfd-onboarding-step--site-gen__error__container__sub-heading__text">
{ content.subHeading }
</p>
<p className="nfd-onboarding-step--site-gen__error__container__sub-heading__message">
{ content.message }
<a
className="nfd-onboarding-step--site-gen__error__container__sub-heading__exit"
href={ pluginDashboardPage }>

Check failure on line 107 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `⏎↹↹↹↹↹↹`
{ content.buttonExit }
</a>

Check failure on line 109 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Delete `⏎`

</p>
</div>
<div className="nfd-onboarding-step--site-gen__error__container__buttons">
<Button
className="nfd-onboarding-step--site-gen__error__container__buttons__skip"
onClick={ () => {
switchFlow( oldFlow );
} }
>
{ content.buttonSkip }
</Button>
{ isLargeViewport ? (
<Button
className="nfd-onboarding-step--site-gen__error__container__buttons__retry"
onClick={ () => {
handleRetry();
} }
>
<p className="nfd-onboarding-button--site-gen-next--text">{ content.buttonText }</p>

Check failure on line 129 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `{·content.buttonText·}` with `⏎↹↹↹↹↹↹↹↹{·content.buttonText·}⏎↹↹↹↹↹↹↹`
</Button>
) : (
<Fill name={ `${ FOOTER_SITEGEN }/${ FOOTER_END }` }>
<Button
className="nfd-onboarding-step--site-gen__error__container__buttons__retry"
onClick={ () => {
handleRetry();
} }
>
<p className="nfd-onboarding-button--site-gen-next--text">{ content.buttonText }</p>

Check failure on line 139 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `{·content.buttonText·}` with `⏎↹↹↹↹↹↹↹↹↹{·content.buttonText·}⏎↹↹↹↹↹↹↹↹`
</Button>
</Fill>
) }
</div>
</div>
</CommonLayout>
);
};

export default SiteGenSiteError;
143 changes: 143 additions & 0 deletions src/OnboardingSPA/components/SiteGenError/stylesheet.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
.nfd-onboarding-step {

&--site-gen {

&__error {
display: flex;
justify-content: center;

&__container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 544px;

@media (max-width: #{ ($break-small) }) {
margin: 16px;
margin-bottom: 100px;
}

@media (min-width: 2600px ) {
width: 1000px;
}

&__animation {
background-image: var(--sitegen-ai-animation);
background-repeat: no-repeat;
background-size: cover;
width: 250px;
height: 183px;
}

&__heading {
padding: 0;
width: 100%;
display: flex;
align-items: center;
flex-direction: row;
justify-content: center;

&__text {
line-height: 1;
font-weight: 500;
color: var(--nfd-onboarding-primary);
font-size: 18px;
}
}

&__sub-heading {
padding: 24px 24px 10px 24px;
// min-height: 115px;
margin-bottom: 50px;
border: solid #e01c1c 1px;
border-radius: 8px;
margin-top: 20px;

&__text {
margin: 0;
padding: 0;
text-align: left;
color: var(--nfd-onboarding-primary);
font-size: 16px;
font-weight: 600;
}

&__message {
margin-top: 10px;
padding: 0;
text-align: left;
color: var(--nfd-onboarding-primary);
font-size: 14px;
font-weight: 400;
// line-height: 0.5 !important;
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
}

&__exit {
font-size: 14px;
font-weight: 400;
color: var(--nfd-onboarding-primary);
margin: 0;
padding: 0;

&:hover {
text-decoration: underline;
color: var(--nfd-onboarding-primary);
}
}
}

&__buttons {
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;

&__skip {
font-size: clamp(0.6rem, 0.755rem + 0.227vw, 1.3rem);
font-style: normal;
font-weight: 510;
margin-right: 24px;
color: var(--nfd-onboarding-primary);

&:hover {
text-decoration: underline;
color: var(--nfd-onboarding-primary);
}

@media (max-width: #{ ($break-small) }) {
margin-right: 0;
}
}

&__retry {
height: 50px;
display: flex;
cursor: pointer;
padding: 0 16px;
text-align: center;
border-radius: 8px;
align-items: center;
justify-content: center;
color: var(--nfd-onboarding-secondary);
background-color: var(--nfd-onboarding-primary);
font-size: clamp(0.5rem, 0.3864rem + 0.5682vw, 1.75rem);
}

@media (max-width: #{ ($break-small) }) {
justify-content: center;
margin-bottom: 50px;
margin-right: 0;
}
}

}

&--button {
padding: 0 35px;
}
}

}
}
34 changes: 34 additions & 0 deletions src/OnboardingSPA/components/StateHandlers/SitegenAi/contents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { __, sprintf } from '@wordpress/i18n';

const getContents = ( brandName ) => {
return {
loader: {
title: sprintf(
/* translators: %s: Brand */
__( 'Preparing your %s design studio', 'wp-module-onboarding' ),
brandName
),
subtitle: __(
'Hang tight while we show you some of the best WordPress has to offer!',
'wp-module-onboarding'
),
},
errorState: {
title: sprintf(
/* translators: %s: Brand */
__( 'Preparing your %s design studio', 'wp-module-onboarding' ),
brandName
),
subtitle: __(
'Hang tight while we show you some of the best WordPress has to offer!',
'wp-module-onboarding'
),
error: __(
'Uh-oh, something went wrong. Please contact support.',
'wp-module-onboarding'
),
},
};
};

export default getContents;
Loading
Loading