mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	refactor: Composable new in unleash (#8505)
This commit is contained in:
		
							parent
							
								
									d3294d58c2
								
							
						
					
					
						commit
						cbfdb8ca6e
					
				@ -18,6 +18,7 @@ import { NavigationSidebar } from './NavigationSidebar/NavigationSidebar';
 | 
				
			|||||||
import { MainLayoutEventTimeline } from './MainLayoutEventTimeline';
 | 
					import { MainLayoutEventTimeline } from './MainLayoutEventTimeline';
 | 
				
			||||||
import { EventTimelineProvider } from 'component/events/EventTimeline/EventTimelineProvider';
 | 
					import { EventTimelineProvider } from 'component/events/EventTimeline/EventTimelineProvider';
 | 
				
			||||||
import { AIChat } from 'component/ai/AIChat';
 | 
					import { AIChat } from 'component/ai/AIChat';
 | 
				
			||||||
 | 
					import { NewInUnleash } from './NavigationSidebar/NewInUnleash/NewInUnleash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IMainLayoutProps {
 | 
					interface IMainLayoutProps {
 | 
				
			||||||
    children: ReactNode;
 | 
					    children: ReactNode;
 | 
				
			||||||
@ -124,7 +125,11 @@ export const MainLayout = forwardRef<HTMLDivElement, IMainLayoutProps>(
 | 
				
			|||||||
                        >
 | 
					                        >
 | 
				
			||||||
                            <ConditionallyRender
 | 
					                            <ConditionallyRender
 | 
				
			||||||
                                condition={!isSmallScreen}
 | 
					                                condition={!isSmallScreen}
 | 
				
			||||||
                                show={<NavigationSidebar />}
 | 
					                                show={
 | 
				
			||||||
 | 
					                                    <NavigationSidebar
 | 
				
			||||||
 | 
					                                        NewInUnleash={NewInUnleash}
 | 
				
			||||||
 | 
					                                    />
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
                            />
 | 
					                            />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            <Box
 | 
					                            <Box
 | 
				
			||||||
 | 
				
			|||||||
@ -15,16 +15,17 @@ import {
 | 
				
			|||||||
import { useInitialPathname } from './useInitialPathname';
 | 
					import { useInitialPathname } from './useInitialPathname';
 | 
				
			||||||
import { useLastViewedProject } from 'hooks/useLastViewedProject';
 | 
					import { useLastViewedProject } from 'hooks/useLastViewedProject';
 | 
				
			||||||
import { useLastViewedFlags } from 'hooks/useLastViewedFlags';
 | 
					import { useLastViewedFlags } from 'hooks/useLastViewedFlags';
 | 
				
			||||||
import { NewInUnleash } from './NewInUnleash/NewInUnleash';
 | 
					import type { NewInUnleash } from './NewInUnleash/NewInUnleash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const MobileNavigationSidebar: FC<{ onClick: () => void }> = ({
 | 
					export const MobileNavigationSidebar: FC<{
 | 
				
			||||||
    onClick,
 | 
					    onClick: () => void;
 | 
				
			||||||
}) => {
 | 
					    NewInUnleash?: typeof NewInUnleash;
 | 
				
			||||||
 | 
					}> = ({ onClick, NewInUnleash }) => {
 | 
				
			||||||
    const { routes } = useRoutes();
 | 
					    const { routes } = useRoutes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
        <>
 | 
					        <>
 | 
				
			||||||
            <NewInUnleash onItemClick={onClick} />
 | 
					            {NewInUnleash ? <NewInUnleash /> : null}
 | 
				
			||||||
            <PrimaryNavigationList mode='full' onClick={onClick} />
 | 
					            <PrimaryNavigationList mode='full' onClick={onClick} />
 | 
				
			||||||
            <SecondaryNavigationList
 | 
					            <SecondaryNavigationList
 | 
				
			||||||
                routes={routes.mainNavRoutes}
 | 
					                routes={routes.mainNavRoutes}
 | 
				
			||||||
@ -66,7 +67,9 @@ const StickyContainer = styled(Box)(({ theme }) => ({
 | 
				
			|||||||
    borderTop: `1px solid ${theme.palette.divider}`,
 | 
					    borderTop: `1px solid ${theme.palette.divider}`,
 | 
				
			||||||
}));
 | 
					}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const NavigationSidebar = () => {
 | 
					export const NavigationSidebar: FC<{ NewInUnleash?: typeof NewInUnleash }> = ({
 | 
				
			||||||
 | 
					    NewInUnleash,
 | 
				
			||||||
 | 
					}) => {
 | 
				
			||||||
    const { routes } = useRoutes();
 | 
					    const { routes } = useRoutes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [mode, setMode] = useNavigationMode();
 | 
					    const [mode, setMode] = useNavigationMode();
 | 
				
			||||||
@ -154,10 +157,12 @@ export const NavigationSidebar = () => {
 | 
				
			|||||||
            <Box sx={{ flex: 1 }} />
 | 
					            <Box sx={{ flex: 1 }} />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <StickyContainer>
 | 
					            <StickyContainer>
 | 
				
			||||||
                <NewInUnleash
 | 
					                {NewInUnleash ? (
 | 
				
			||||||
                    mode={mode}
 | 
					                    <NewInUnleash
 | 
				
			||||||
                    onMiniModeClick={() => setMode('full')}
 | 
					                        mode={mode}
 | 
				
			||||||
                />
 | 
					                        onMiniModeClick={() => setMode('full')}
 | 
				
			||||||
 | 
					                    />
 | 
				
			||||||
 | 
					                ) : null}
 | 
				
			||||||
                <ShowHide
 | 
					                <ShowHide
 | 
				
			||||||
                    mode={mode}
 | 
					                    mode={mode}
 | 
				
			||||||
                    onChange={() => {
 | 
					                    onChange={() => {
 | 
				
			||||||
 | 
				
			|||||||
@ -89,13 +89,11 @@ type NewItem = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
interface INewInUnleashProps {
 | 
					interface INewInUnleashProps {
 | 
				
			||||||
    mode?: NavigationMode;
 | 
					    mode?: NavigationMode;
 | 
				
			||||||
    onItemClick?: () => void;
 | 
					 | 
				
			||||||
    onMiniModeClick?: () => void;
 | 
					    onMiniModeClick?: () => void;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const NewInUnleash = ({
 | 
					export const NewInUnleash = ({
 | 
				
			||||||
    mode = 'full',
 | 
					    mode = 'full',
 | 
				
			||||||
    onItemClick,
 | 
					 | 
				
			||||||
    onMiniModeClick,
 | 
					    onMiniModeClick,
 | 
				
			||||||
}: INewInUnleashProps) => {
 | 
					}: INewInUnleashProps) => {
 | 
				
			||||||
    const navigate = useNavigate();
 | 
					    const navigate = useNavigate();
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,7 @@ import styles from './DrawerMenu.module.scss'; // FIXME: useStyle - theme
 | 
				
			|||||||
import theme from 'themes/theme';
 | 
					import theme from 'themes/theme';
 | 
				
			||||||
import { ThemeMode } from 'component/common/ThemeMode/ThemeMode';
 | 
					import { ThemeMode } from 'component/common/ThemeMode/ThemeMode';
 | 
				
			||||||
import { MobileNavigationSidebar } from 'component/layout/MainLayout/NavigationSidebar/NavigationSidebar';
 | 
					import { MobileNavigationSidebar } from 'component/layout/MainLayout/NavigationSidebar/NavigationSidebar';
 | 
				
			||||||
 | 
					import { NewInUnleash } from 'component/layout/MainLayout/NavigationSidebar/NewInUnleash/NewInUnleash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const StyledDrawerHeader = styled('div')(({ theme }) => ({
 | 
					const StyledDrawerHeader = styled('div')(({ theme }) => ({
 | 
				
			||||||
    display: 'flex',
 | 
					    display: 'flex',
 | 
				
			||||||
@ -71,7 +72,10 @@ export const DrawerMenu: VFC<IDrawerMenuProps> = ({
 | 
				
			|||||||
                    </Link>
 | 
					                    </Link>
 | 
				
			||||||
                </StyledDrawerHeader>
 | 
					                </StyledDrawerHeader>
 | 
				
			||||||
                <Divider />
 | 
					                <Divider />
 | 
				
			||||||
                <MobileNavigationSidebar onClick={toggleDrawer} />
 | 
					                <MobileNavigationSidebar
 | 
				
			||||||
 | 
					                    onClick={toggleDrawer}
 | 
				
			||||||
 | 
					                    NewInUnleash={NewInUnleash}
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
            </nav>
 | 
					            </nav>
 | 
				
			||||||
        </Drawer>
 | 
					        </Drawer>
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user