소스 검색

fix can't resize workflow run panel (#18538)

tags/1.3.0
非法操作 6 달 전
부모
커밋
35a008af18
No account linked to committer's email address
1개의 변경된 파일38개의 추가작업 그리고 2개의 파일을 삭제
  1. 38
    2
      web/app/components/workflow/panel/workflow-preview.tsx

+ 38
- 2
web/app/components/workflow/panel/workflow-preview.tsx 파일 보기

import { import {
memo, memo,
useCallback,
useEffect, useEffect,
useState, useState,
} from 'react' } from 'react'
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…
취소
저장