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

Fix issue with onboarding in AI branch #428

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions src/OnboardingSPA/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* @return Button
*/

const Button = ( { children, onClick, disabled, className } ) => {
const Button = ( { text, handleClick, disabled, className } ) => {
const handleBtnClick = () => {
if ( onClick ) {
onClick();
if ( handleClick ) {
handleClick();
}
Comment on lines +10 to 12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( handleClick ) {
handleClick();
}
if ( typeof handleClick === 'function' ) {
handleClick();
}

};

Expand All @@ -19,7 +19,7 @@ const Button = ( { children, onClick, disabled, className } ) => {
onClick={ handleBtnClick }
disabled={ disabled }
>
{ children }
{ text }
</button>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { ThemeContext } from '../../ThemeContextProvider';
*/

const HeadingWithSubHeading = ( { title, subtitle } ) => {
const { theme } = useContext( ThemeContext );
const themeContext = useContext( ThemeContext );
const theme = themeContext?.theme || false;

return (
<div className="nfd-onboarding-step__heading">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ const SiteGenPreviewSelectableCard = ( {
>
<Button
className={ `${ className }__live-preview-container__overlay__button` }
onClick={ () => handlePreview() }
>
<Icon icon={ search } />
{ __( 'Preview Version', 'wp-module-onboarding' ) }
</Button>
text={
<>
<Icon icon={ search } />
{ __(
'Preview Version',
'wp-module-onboarding'
) }
</>
}
handleClick={ handlePreview }
/>
</div>
) }
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
select( nfdOnboardingStore ).getPluginInstallHash(),
};
},
[ location.pathname ]

Check warning on line 104 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useSelect has an unnecessary dependency: 'location.pathname'. Either exclude it or remove the dependency array

Check warning on line 104 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useSelect has an unnecessary dependency: 'location.pathname'. Either exclude it or remove the dependency array
);

const [ isRequestPlaced, setIsRequestPlaced ] = useState( false );
Expand Down Expand Up @@ -364,7 +364,7 @@

useEffect( () => {
trackChapters();
}, [ currentStep ] );

Check warning on line 367 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

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

Check warning on line 367 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

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

const prioritizeFlow = () => {
const currentFlow = window.nfdOnboarding.currentFlow;
Expand Down Expand Up @@ -405,13 +405,13 @@
initializeSettings();
setInterval( cronTrigger, 45000 );
}
}, [ initialize ] );

Check warning on line 408 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/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

Check warning on line 408 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/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( () => {
if ( false !== brandConfig?.prioritization ) {
return prioritizeFlow();
}
}, [ experienceLevel, topPriority ] );

Check warning on line 414 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'brandConfig?.prioritization' and 'prioritizeFlow'. Either include them or remove the dependency array

Check warning on line 414 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'brandConfig?.prioritization' and 'prioritizeFlow'. Either include them or remove the dependency array

useEffect( () => {
document.body.classList.add( `nfd-brand-${ newfoldBrand }` );
Expand All @@ -421,7 +421,7 @@
syncStoreToDB();
handlePreviousStepTracking();
handleConditionalDesignStepsRoutes();
}, [ location.pathname, onboardingFlow ] );

Check warning on line 424 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'handleConditionalDesignStepsRoutes', 'handlePreviousStepTracking', and 'syncStoreToDB'. Either include them or remove the dependency array

Check warning on line 424 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteBuild/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'handleConditionalDesignStepsRoutes', 'handlePreviousStepTracking', and 'syncStoreToDB'. Either include them or remove the dependency array

const isForkStep =
currentStep === stepTheFork ||
Expand All @@ -434,28 +434,35 @@
isForkStep
);

return (
<ThemeProvider>
<ThemedNewfoldInterfaceSkeleton
className={ classNames(
'nfd-onboarding-skeleton',
`brand-${ newfoldBrand }`,
`path-${ pathname }`,
{ 'is-drawer-open': isDrawerOpen },
{ 'is-large-viewport': isLargeViewport },
{ 'is-small-viewport': ! isLargeViewport },
{
'nfd-onboarding-skeleton--sitegen': isForkStep,
}
) }
header={ <Header /> }
drawer={ <Drawer /> }
content={ <Content /> }
sidebar={ <Sidebar /> }
footer={ isForkStep ? <Footer /> : null }
/>
</ThemeProvider>
);
const commonSkeletonProps = {
className: classNames(
'nfd-onboarding-skeleton',
`brand-${ newfoldBrand }`,
`path-${ pathname }`,
{ 'is-drawer-open': isDrawerOpen },
{ 'is-large-viewport': isLargeViewport },
{ 'is-small-viewport': ! isLargeViewport },
{ 'nfd-onboarding-skeleton--sitegen': isForkStep }
),
header: <Header />,
drawer: <Drawer />,
content: <Content />,
sidebar: <Sidebar />,
footer: isForkStep ? <Footer /> : null,
};

const renderSkeleton = ( Component ) =>
isForkStep ? (
<ThemeProvider>
<Component { ...commonSkeletonProps } />
</ThemeProvider>
) : (
<Component { ...commonSkeletonProps } />
);

return isForkStep
? renderSkeleton( ThemedNewfoldInterfaceSkeleton )
: renderSkeleton( NewfoldInterfaceSkeleton );
};

export default SiteBuild;
15 changes: 10 additions & 5 deletions src/OnboardingSPA/components/NewfoldInterfaceSkeleton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ function NewfoldInterfaceSkeleton(
ref
) {
const navigateRegionsProps = useNavigateRegions( shortcuts );
const { theme } = useContext( ThemeContext );
useHTMLClass(
'nfd-interface-interface-skeleton__html-container',
theme === THEME_DARK
);
const isSiteGenFlow = window.nfdOnboarding.currentFlow === 'sitegen';
if ( isSiteGenFlow ) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { theme } = useContext( ThemeContext );
// eslint-disable-next-line react-hooks/rules-of-hooks
useHTMLClass(
'nfd-interface-interface-skeleton__html-container',
theme === THEME_DARK
);
}

const defaultLabels = {
/* translators: accessibility text for the nav bar landmark region. */
Expand Down