mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 23:15:59 +08:00
fix can't resize workflow run panel (#18538)
This commit is contained in:
parent
79bf590576
commit
35a008af18
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
memo,
|
memo,
|
||||||
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
@ -47,10 +48,45 @@ const WorkflowPreview = () => {
|
|||||||
switchTab('DETAIL')
|
switchTab('DETAIL')
|
||||||
}, [workflowRunningData])
|
}, [workflowRunningData])
|
||||||
|
|
||||||
|
const [panelWidth, setPanelWidth] = useState(420)
|
||||||
|
const [isResizing, setIsResizing] = useState(false)
|
||||||
|
|
||||||
|
const startResizing = useCallback((e: React.MouseEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
setIsResizing(true)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const stopResizing = useCallback(() => {
|
||||||
|
setIsResizing(false)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const resize = useCallback((e: MouseEvent) => {
|
||||||
|
if (isResizing) {
|
||||||
|
const newWidth = window.innerWidth - e.clientX
|
||||||
|
if (newWidth > 420 && newWidth < 1024)
|
||||||
|
setPanelWidth(newWidth)
|
||||||
|
}
|
||||||
|
}, [isResizing])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener('mousemove', resize)
|
||||||
|
window.addEventListener('mouseup', stopResizing)
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('mousemove', resize)
|
||||||
|
window.removeEventListener('mouseup', stopResizing)
|
||||||
|
}
|
||||||
|
}, [resize, stopResizing])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`
|
<div className={`
|
||||||
flex h-full w-[420px] flex-col rounded-l-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl
|
relative flex h-full flex-col rounded-l-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl
|
||||||
`}>
|
`}
|
||||||
|
style={{ width: `${panelWidth}px` }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="absolute bottom-0 left-[3px] top-1/2 z-50 h-6 w-[3px] cursor-col-resize rounded bg-gray-300"
|
||||||
|
onMouseDown={startResizing}
|
||||||
|
/>
|
||||||
<div className='flex items-center justify-between p-4 pb-1 text-base font-semibold text-text-primary'>
|
<div className='flex items-center justify-between p-4 pb-1 text-base font-semibold text-text-primary'>
|
||||||
{`Test Run${!workflowRunningData?.result.sequence_number ? '' : `#${workflowRunningData?.result.sequence_number}`}`}
|
{`Test Run${!workflowRunningData?.result.sequence_number ? '' : `#${workflowRunningData?.result.sequence_number}`}`}
|
||||||
<div className='cursor-pointer p-1' onClick={() => handleCancelDebugAndPreviewPanel()}>
|
<div className='cursor-pointer p-1' onClick={() => handleCancelDebugAndPreviewPanel()}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user