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

Save continue dim UI #462

Merged
merged 14 commits into from
Feb 21, 2024
28,277 changes: 24,297 additions & 3,980 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,25 @@
}, [ newfoldBrand ] );
const location = useLocation();

const { currentData, initialize, pluginInstallHash, siteGenErrorStatus } =
useSelect( ( select ) => {
return {
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
initialize: select( nfdOnboardingStore ).getInitialize(),
pluginInstallHash:
select( nfdOnboardingStore ).getPluginInstallHash(),
siteGenErrorStatus:
select( nfdOnboardingStore ).getSiteGenErrorStatus(),
};
} );
const {
currentData,
initialize,
pluginInstallHash,
siteGenErrorStatus,
interactionDisabled,
} = useSelect( ( select ) => {
return {
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
initialize: select( nfdOnboardingStore ).getInitialize(),
pluginInstallHash:
select( nfdOnboardingStore ).getPluginInstallHash(),
siteGenErrorStatus:
select( nfdOnboardingStore ).getSiteGenErrorStatus(),
interactionDisabled:
select( nfdOnboardingStore ).getInteractionDisabled(),
};
} );

const { setCurrentOnboardingData, updateSiteGenErrorStatus } =
useDispatch( nfdOnboardingStore );
Expand Down Expand Up @@ -172,21 +179,24 @@
initializePlugins( pluginInstallHash );
setInterval( cronTrigger, 45000 );
}
}, [ initialize ] );

Check warning on line 182 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 188 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

useEffect( () => {
if ( prevSiteGenErrorStatus.current === true && siteGenErrorStatus === false ) {
if (
prevSiteGenErrorStatus.current === true &&
siteGenErrorStatus === false
) {
generateSiteGenData();
syncStoreToDB();
}
prevSiteGenErrorStatus.current = siteGenErrorStatus;
}, [ siteGenErrorStatus ] );

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

useEffect( () => {
initializeThemes();
Expand All @@ -205,6 +215,7 @@
content={ <Content /> }
sidebar={ <Sidebar /> }
footer={ <Footer /> }
interactionDisabled={ interactionDisabled }
/>
</ThemeProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function NewfoldInterfaceSkeleton(
labels,
className,
shortcuts,
interactionDisabled,
},
ref
) {
Expand Down Expand Up @@ -182,6 +183,9 @@ function NewfoldInterfaceSkeleton(
{ footer }
</div>
) }
{ interactionDisabled && (
<div className="nfd-interface-interface-skeleton__overlay--disabled"></div>
) }
</div>
);
}
Expand Down
16 changes: 15 additions & 1 deletion src/OnboardingSPA/components/NewfoldInterfaceSkeleton/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,28 @@ html.nfd-interface-interface-skeleton__html-container {
top: 0;
}
}

&__overlay {
// z-index: to display over sidebar.
&--disabled {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(var(--nfd-onboarding-secondary-rgb), 0.3);
cursor: not-allowed;
z-index: 1000001;
}
}
}

.nfd-interface-interface-skeleton__editor {
display: flex;
flex-direction: column;
flex: 0 1 100%;
overflow: hidden;
position: relative;
}

@include editor-left(".nfd-interface-interface-skeleton");
Expand Down Expand Up @@ -197,4 +212,3 @@ html.nfd-interface-interface-skeleton__html-container {
}
}
}

16 changes: 11 additions & 5 deletions src/OnboardingSPA/steps/SiteGen/Editor/Header/center.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,31 @@ const DropDownMenu = memo(
onRenameItemSelect,
onViewAll,
isLargeViewport,
onToggle,
} ) => {
const onMenuItemClick = ( action ) => () => {
action();
onToggle();
};
return (
<MenuGroup className="nfd-onboarding-header__version_dropdown-menu">
{ ! isLargeViewport && (
<>
<MenuItem onClick={ onRegenerate }>
<MenuItem onClick={ onMenuItemClick( onRegenerate ) }>
<Icon icon={ reusableBlock } />
{ __( 'Regenerate', 'wp-module-onboarding' ) }
</MenuItem>
<MenuItem onClick={ onCustomize }>
<MenuItem onClick={ onMenuItemClick( onCustomize ) }>
<div className="nfd-onboarding-header__version_dropdown-menu__customize-button__icon"></div>
{ __( 'Customize', 'wp-module-onboarding' ) }
</MenuItem>
</>
) }

<MenuItem onClick={ onRenameItemSelect }>
<MenuItem onClick={ onMenuItemClick( onRenameItemSelect ) }>
{ __( 'Rename', 'wp-module-onboarding' ) }
</MenuItem>
<MenuItem onClick={ onViewAll }>
<MenuItem onClick={ onMenuItemClick( onViewAll ) }>
{ __( 'View All', 'wp-module-onboarding' ) }
</MenuItem>
</MenuGroup>
Expand Down Expand Up @@ -126,13 +131,14 @@ const TitleContent = memo(
/>
</div>
) }
renderContent={ () => (
renderContent={ ( { onToggle } ) => (
<DropDownMenu
onRegenerate={ onRegenerate }
onCustomize={ onCustomize }
onRenameItemSelect={ onRenameItemSelect }
onViewAll={ onViewAll }
isLargeViewport={ isLargeViewport }
onToggle={ onToggle }
/>
) }
/>
Expand Down
19 changes: 16 additions & 3 deletions src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
setCurrentOnboardingData,
setSidebarActiveView,
setIsSidebarOpened,
setInteractionDisabled,
} = useDispatch( nfdOnboardingStore );
const { currentData, sideBarView, isSidebarOpened } = useSelect(
( select ) => {
Expand Down Expand Up @@ -214,7 +215,7 @@

useEffect( () => {
handleCustomize();
}, [] );

Check warning on line 218 in src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

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

useEffect( () => {
if ( currentData?.sitegen?.homepages?.active ) {
Expand All @@ -222,6 +223,18 @@
}
}, [ currentData ] );

useEffect( () => {
if ( isSaving || isRegenerating ) {
setInteractionDisabled( true );
} else {
setInteractionDisabled( false );
}

return () => {
setInteractionDisabled( false );
};
}, [ isSaving, isRegenerating ] );

Check warning on line 236 in src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

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

return (
<>
<Fill name={ `${ HEADER_SITEGEN }/${ HEADER_START }` }>
Expand Down Expand Up @@ -299,9 +312,9 @@
>
{ isLargeViewport
? __(
'Save & Continue',
'wp-module-onboarding'
)
'Save & Continue',
'wp-module-onboarding'
)
: __( 'Next', 'wp-module-onboarding' ) }
</div>
{ isSaving ? (
Expand Down
7 changes: 7 additions & 0 deletions src/OnboardingSPA/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,10 @@ export function updateSiteGenErrorStatus( siteGenErrorStatus ) {
siteGenErrorStatus,
};
}

export function setInteractionDisabled( interactionDisabled ) {
return {
type: 'SET_INTERACTION_DISABLED',
interactionDisabled,
};
}
6 changes: 6 additions & 0 deletions src/OnboardingSPA/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function flow(
},
},
chapter: undefined,
interactionDisabled: false,
},
action
) {
Expand Down Expand Up @@ -121,6 +122,11 @@ export function flow(
...state,
chapter: action.chapter,
};
case 'SET_INTERACTION_DISABLED':
return {
...state,
interactionDisabled: action.interactionDisabled,
};
}

return state;
Expand Down
4 changes: 4 additions & 0 deletions src/OnboardingSPA/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,3 +470,7 @@ export function getCustomizeSidebarData( state ) {
export function getSiteGenErrorStatus( state ) {
return state.data.flowData.sitegen.siteGenErrorStatus;
}

export function getInteractionDisabled( state ) {
return state.flow.interactionDisabled;
}
Loading