Files
dify/web/app/components/workflow/header/index.tsx
Novice fd124e6d32 Merge main HEAD (segment 5) into sandboxed-agent-rebase
Resolve 83 conflicts: 10 backend, 62 frontend, 11 config/lock files.
Preserve sandbox/agent/collaboration features while adopting main's
UI refactorings (Dialog/AlertDialog/Popover), model provider updates,
and enterprise features.

Made-with: Cursor
2026-03-23 14:20:06 +08:00

85 lines
2.0 KiB
TypeScript

import type { ReactNode } from 'react'
import type { HeaderInNormalProps } from './header-in-normal'
import type { HeaderInRestoringProps } from './header-in-restoring'
import type { HeaderInHistoryProps } from './header-in-view-history'
import dynamic from '@/next/dynamic'
import { usePathname } from '@/next/navigation'
import {
useWorkflowMode,
} from '../hooks'
import { useStore } from '../store'
import HeaderInNormal from './header-in-normal'
const HeaderInHistory = dynamic(() => import('./header-in-view-history'), {
ssr: false,
})
const HeaderInRestoring = dynamic(() => import('./header-in-restoring'), {
ssr: false,
})
export type HeaderProps = {
normal?: HeaderInNormalProps
viewHistory?: HeaderInHistoryProps
restoring?: HeaderInRestoringProps
}
type HeaderShellProps = {
children: ReactNode
}
export const HeaderShell = ({ children }: HeaderShellProps) => {
const pathname = usePathname()
const inWorkflowCanvas = pathname.endsWith('/workflow')
const isPipelineCanvas = pathname.endsWith('/pipeline')
const maximizeCanvas = useStore(s => s.maximizeCanvas)
return (
<div
className="absolute left-0 top-7 z-10 flex h-0 w-full items-center justify-between bg-mask-top2bottom-gray-50-to-transparent px-3"
>
{(inWorkflowCanvas || isPipelineCanvas) && maximizeCanvas && <div className="h-14 w-[52px]" />}
{children}
</div>
)
}
const Header = ({
normal: normalProps,
viewHistory: viewHistoryProps,
restoring: restoringProps,
}: HeaderProps) => {
const {
normal,
restoring,
viewHistory,
} = useWorkflowMode()
return (
<HeaderShell>
{
normal && (
<HeaderInNormal
{...normalProps}
/>
)
}
{
viewHistory && (
<HeaderInHistory
{...viewHistoryProps}
/>
)
}
{
restoring && (
<HeaderInRestoring
{...restoringProps}
/>
)
}
</HeaderShell>
)
}
export default Header