diff --git a/packages/toolpad-core/src/DashboardLayout/DashboardLayout.tsx b/packages/toolpad-core/src/DashboardLayout/DashboardLayout.tsx index 2d921608aba..2eba8c7e418 100644 --- a/packages/toolpad-core/src/DashboardLayout/DashboardLayout.tsx +++ b/packages/toolpad-core/src/DashboardLayout/DashboardLayout.tsx @@ -1,7 +1,7 @@ 'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; -import { styled, useTheme, type Theme, SxProps } from '@mui/material'; +import { styled, useTheme, SxProps } from '@mui/material'; import MuiAppBar from '@mui/material/AppBar'; import Box from '@mui/material/Box'; import Drawer from '@mui/material/Drawer'; @@ -106,7 +106,7 @@ export interface DashboardLayoutProps { /** * The system prop that allows defining system overrides as well as additional CSS styles. */ - sx?: SxProps; + sx?: SxProps; } /** @@ -327,55 +327,52 @@ function DashboardLayout(props: DashboardLayoutProps) { > - {!hideNavigation ? ( - - - {getMenuIcon(isMobileNavigationExpanded)} - - - {getMenuIcon(isDesktopNavigationExpanded)} - - - ) : null} - - - - - {branding?.logo ?? } - - {applicationTitle} - - - - - - - - + + {!hideNavigation ? ( + + + {getMenuIcon(isMobileNavigationExpanded)} + + + {getMenuIcon(isDesktopNavigationExpanded)} + + + ) : null} + + + {branding?.logo ?? } + + {applicationTitle} + + + + + + + + diff --git a/packages/toolpad-studio/src/runtime/AppLayout.tsx b/packages/toolpad-studio/src/runtime/AppLayout.tsx index 35f81c63b6e..7c25b46db1b 100644 --- a/packages/toolpad-studio/src/runtime/AppLayout.tsx +++ b/packages/toolpad-studio/src/runtime/AppLayout.tsx @@ -52,7 +52,7 @@ export function AppLayout({ const hasLayout = hasLayoutProp && hasShell; - const { session, signOut } = React.useContext(AuthContext); + const { session, signOut, hasAuthentication } = React.useContext(AuthContext); const navigation = React.useMemo( () => @@ -63,9 +63,18 @@ export function AppLayout({ [pages, retainedSearch], ); - const signIn = React.useCallback(() => { - navigate('/signin'); - }, [navigate]); + const authentication = React.useMemo( + () => + hasAuthentication + ? { + signIn: () => { + navigate('/signin'); + }, + signOut, + } + : undefined, + [hasAuthentication, navigate, signOut], + ); const layoutContent = ( @@ -80,10 +89,7 @@ export function AppLayout({ branding={{ title: 'Toolpad Studio', }} - authentication={{ - signIn, - signOut, - }} + authentication={authentication} session={session} > {hasLayout ? ( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1bf1c04ca87..813f6df256c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4042,8 +4042,8 @@ packages: engines: {node: '>=18'} peerDependencies: '@testing-library/dom': ^10.0.0 - '@types/react': ^18.0.0 - '@types/react-dom': ^18.0.0 + '@types/react': ^18.3.11 + '@types/react-dom': 18.3.1 react: ^18.0.0 react-dom: ^18.0.0 peerDependenciesMeta: