mirror of
https://github.com/langgenius/dify.git
synced 2026-05-28 21:03:22 +08:00
fix(web): scope main nav fullscreen canvas routes
This commit is contained in:
@ -68,12 +68,30 @@ describe('MainNavLayout', () => {
|
||||
expect(screen.queryByTestId('desktop-header')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('hides the desktop main nav on fullscreen workflow canvases', () => {
|
||||
mockPathname = '/apps/app-1/workflow'
|
||||
it('hides the desktop main nav on fullscreen app workflow canvases', () => {
|
||||
mockPathname = '/app/app-1/workflow'
|
||||
localStorage.setItem('workflow-canvas-maximize', 'true')
|
||||
|
||||
render(<MainNavLayout><div>content</div></MainNavLayout>)
|
||||
|
||||
expect(screen.getByTestId('main-nav')).toHaveClass('hidden')
|
||||
})
|
||||
|
||||
it('hides the desktop main nav on fullscreen dataset pipeline canvases', () => {
|
||||
mockPathname = '/datasets/dataset-1/pipeline'
|
||||
localStorage.setItem('workflow-canvas-maximize', 'true')
|
||||
|
||||
render(<MainNavLayout><div>content</div></MainNavLayout>)
|
||||
|
||||
expect(screen.getByTestId('main-nav')).toHaveClass('hidden')
|
||||
})
|
||||
|
||||
it('keeps the main nav visible on the integrations workflow tool page', () => {
|
||||
mockPathname = '/integrations/tools/workflow'
|
||||
localStorage.setItem('workflow-canvas-maximize', 'true')
|
||||
|
||||
render(<MainNavLayout><div>content</div></MainNavLayout>)
|
||||
|
||||
expect(screen.getByTestId('main-nav')).not.toHaveClass('hidden')
|
||||
})
|
||||
})
|
||||
|
||||
@ -13,12 +13,16 @@ type MainNavLayoutProps = {
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
const isCanvasFullscreenPath = (pathname: string) => {
|
||||
return /^\/app\/[^/]+\/workflow$/.test(pathname)
|
||||
|| /^\/datasets\/[^/]+\/pipeline$/.test(pathname)
|
||||
}
|
||||
|
||||
const MainNavLayout = ({
|
||||
children,
|
||||
}: MainNavLayoutProps) => {
|
||||
const pathname = usePathname()
|
||||
const inWorkflowCanvas = pathname.endsWith('/workflow')
|
||||
const isPipelineCanvas = pathname.endsWith('/pipeline')
|
||||
const inCanvasFullscreenPath = isCanvasFullscreenPath(pathname)
|
||||
const [hideMainNav, setHideMainNav] = useState(() => (
|
||||
globalThis.localStorage?.getItem('workflow-canvas-maximize') === 'true'
|
||||
))
|
||||
@ -34,7 +38,7 @@ const MainNavLayout = ({
|
||||
<WorkspaceProvider>
|
||||
<MainNav
|
||||
className={cn(
|
||||
hideMainNav && (inWorkflowCanvas || isPipelineCanvas) && 'hidden',
|
||||
hideMainNav && inCanvasFullscreenPath && 'hidden',
|
||||
)}
|
||||
/>
|
||||
</WorkspaceProvider>
|
||||
|
||||
Reference in New Issue
Block a user