2023-08-28 01:28:05 +00:00
|
|
|
// Reference: https://github.com/WordPress/gutenberg/blob/v16.4.0/packages/edit-site/src/components/sidebar/index.js
|
|
|
|
/* eslint-disable @woocommerce/dependency-group */
|
|
|
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-06-11 13:26:04 +00:00
|
|
|
import { memo, useCallback, useContext } from '@wordpress/element';
|
2023-08-28 01:28:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { SidebarNavigationScreenColorPalette } from './sidebar-navigation-screen-color-palette';
|
2024-07-19 12:52:26 +00:00
|
|
|
import { SidebarNavigationScreenFooter } from './sidebar-navigation-screen-footer/sidebar-navigation-screen-footer';
|
|
|
|
import { SidebarNavigationScreenHeader } from './sidebar-navigation-screen-header/sidebar-navigation-screen-header';
|
2024-07-22 13:46:11 +00:00
|
|
|
import { SidebarNavigationScreenHomepage } from './sidebar-navigation-screen-homepage/sidebar-navigation-screen-homepage';
|
2024-06-11 13:26:04 +00:00
|
|
|
import { SidebarNavigationScreenMain } from './sidebar-navigation-screen-main';
|
2024-07-30 10:10:51 +00:00
|
|
|
import { SidebarNavigationScreenTypography } from './sidebar-navigation-screen-typography/sidebar-navigation-screen-typography';
|
2023-09-19 03:37:46 +00:00
|
|
|
// import { SidebarNavigationScreenPages } from './sidebar-navigation-screen-pages';
|
2023-08-28 01:28:05 +00:00
|
|
|
|
2024-06-11 13:26:04 +00:00
|
|
|
import { getNewPath, navigateTo, useQuery } from '@woocommerce/navigation';
|
2023-08-28 01:28:05 +00:00
|
|
|
import { SaveHub } from './save-hub';
|
2024-04-23 15:52:29 +00:00
|
|
|
// In some cases, the assembler is loaded in an iframe, so we have to re-apply the filter.
|
|
|
|
import '~/customize-store/design-with-ai/entrepreneur-flow';
|
2024-06-11 13:26:04 +00:00
|
|
|
import {
|
|
|
|
SidebarContent,
|
|
|
|
SidebarNavigationAnimationDirection,
|
|
|
|
SidebarNavigationContext,
|
|
|
|
} from '../components/sidebar';
|
|
|
|
import { SidebarNavigationScreenLogo } from './sidebar-navigation-screen-logo';
|
2024-07-16 10:19:00 +00:00
|
|
|
import { isFullComposabilityFeatureAndAPIAvailable } from '../utils/is-full-composability-enabled';
|
2024-07-15 12:02:56 +00:00
|
|
|
import { SidebarNavigationScreenHomepagePTK } from './sidebar-navigation-screen-homepage-ptk/sidebar-navigation-screen-homepage-ptk';
|
2023-08-28 01:28:05 +00:00
|
|
|
|
2024-06-11 13:26:04 +00:00
|
|
|
const getComponentByPathParams = (
|
|
|
|
params: string,
|
|
|
|
onNavigateBackClick: () => void
|
|
|
|
) => {
|
|
|
|
if ( params === '/customize-store/assembler-hub' ) {
|
|
|
|
return <SidebarNavigationScreenMain />;
|
2023-08-28 01:28:05 +00:00
|
|
|
}
|
|
|
|
|
2024-06-11 13:26:04 +00:00
|
|
|
if ( params === '/customize-store/assembler-hub/color-palette' ) {
|
|
|
|
return (
|
|
|
|
<SidebarNavigationScreenColorPalette
|
|
|
|
onNavigateBackClick={ onNavigateBackClick }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( params === '/customize-store/assembler-hub/logo' ) {
|
|
|
|
return (
|
|
|
|
<SidebarNavigationScreenLogo
|
|
|
|
onNavigateBackClick={ onNavigateBackClick }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( params === '/customize-store/assembler-hub/typography' ) {
|
|
|
|
return (
|
|
|
|
<SidebarNavigationScreenTypography
|
|
|
|
onNavigateBackClick={ onNavigateBackClick }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( params === '/customize-store/assembler-hub/header' ) {
|
|
|
|
return (
|
|
|
|
<SidebarNavigationScreenHeader
|
|
|
|
onNavigateBackClick={ onNavigateBackClick }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-06-18 12:16:16 +00:00
|
|
|
if (
|
2024-07-16 10:19:00 +00:00
|
|
|
isFullComposabilityFeatureAndAPIAvailable() &&
|
2024-06-18 12:16:16 +00:00
|
|
|
params?.includes( '/customize-store/assembler-hub/homepage' )
|
|
|
|
) {
|
|
|
|
return (
|
|
|
|
<SidebarNavigationScreenHomepagePTK
|
|
|
|
onNavigateBackClick={ onNavigateBackClick }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
2024-07-16 10:19:00 +00:00
|
|
|
! isFullComposabilityFeatureAndAPIAvailable() &&
|
2024-06-18 12:16:16 +00:00
|
|
|
params === '/customize-store/assembler-hub/homepage'
|
|
|
|
) {
|
2024-06-11 13:26:04 +00:00
|
|
|
return (
|
|
|
|
<SidebarNavigationScreenHomepage
|
|
|
|
onNavigateBackClick={ onNavigateBackClick }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( params === '/customize-store/assembler-hub/footer' ) {
|
|
|
|
return (
|
|
|
|
<SidebarNavigationScreenFooter
|
|
|
|
onNavigateBackClick={ onNavigateBackClick }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <SidebarNavigationScreenMain />;
|
|
|
|
};
|
2023-08-28 01:28:05 +00:00
|
|
|
|
|
|
|
function SidebarScreens() {
|
2024-06-11 13:26:04 +00:00
|
|
|
const params = useQuery().path;
|
|
|
|
|
|
|
|
const { navigate } = useContext( SidebarNavigationContext );
|
|
|
|
|
|
|
|
const onNavigateBackClick = useCallback( () => {
|
|
|
|
const assemblerUrl = getNewPath(
|
|
|
|
{ customizing: true },
|
|
|
|
'/customize-store/assembler-hub',
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
navigateTo( { url: assemblerUrl } );
|
|
|
|
navigate( SidebarNavigationAnimationDirection.Back );
|
|
|
|
}, [ navigate ] );
|
|
|
|
|
|
|
|
return <>{ getComponentByPathParams( params, onNavigateBackClick ) }</>;
|
2023-08-28 01:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function Sidebar() {
|
|
|
|
return (
|
|
|
|
<>
|
2024-06-11 13:26:04 +00:00
|
|
|
<SidebarContent>
|
2023-08-28 01:28:05 +00:00
|
|
|
<SidebarScreens />
|
2024-06-11 13:26:04 +00:00
|
|
|
</SidebarContent>
|
|
|
|
<SaveHub />
|
2023-08-28 01:28:05 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default memo( Sidebar );
|