fix(web): scope main nav fullscreen canvas routes

This commit is contained in:
Jingyi-Dify
2026-05-21 15:49:02 -07:00
parent b8868dab90
commit 92bb9a17b7
2 changed files with 27 additions and 5 deletions

View File

@ -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')
})
})

View File

@ -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>