|
|
|
@ -8,6 +8,8 @@ import {
|
|
|
|
useCallback,
|
|
|
|
useCallback,
|
|
|
|
useRef,
|
|
|
|
useRef,
|
|
|
|
useState,
|
|
|
|
useState,
|
|
|
|
|
|
|
|
useEffect,
|
|
|
|
|
|
|
|
useMemo,
|
|
|
|
} from 'react'
|
|
|
|
} from 'react'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
RiCloseLine,
|
|
|
|
RiCloseLine,
|
|
|
|
@ -36,7 +38,6 @@ import {
|
|
|
|
useNodesReadOnly,
|
|
|
|
useNodesReadOnly,
|
|
|
|
useNodesSyncDraft,
|
|
|
|
useNodesSyncDraft,
|
|
|
|
useToolIcon,
|
|
|
|
useToolIcon,
|
|
|
|
useWorkflow,
|
|
|
|
|
|
|
|
useWorkflowHistory,
|
|
|
|
useWorkflowHistory,
|
|
|
|
} from '@/app/components/workflow/hooks'
|
|
|
|
} from '@/app/components/workflow/hooks'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
@ -54,6 +55,7 @@ import useOneStepRun from '../../hooks/use-one-step-run'
|
|
|
|
import type { PanelExposedType } from '@/types/workflow'
|
|
|
|
import type { PanelExposedType } from '@/types/workflow'
|
|
|
|
import BeforeRunForm from '../before-run-form'
|
|
|
|
import BeforeRunForm from '../before-run-form'
|
|
|
|
import { sleep } from '@/utils'
|
|
|
|
import { sleep } from '@/utils'
|
|
|
|
|
|
|
|
import { debounce } from 'lodash-es'
|
|
|
|
|
|
|
|
|
|
|
|
type BasePanelProps = {
|
|
|
|
type BasePanelProps = {
|
|
|
|
children: ReactNode
|
|
|
|
children: ReactNode
|
|
|
|
@ -69,19 +71,30 @@ const BasePanel: FC<BasePanelProps> = ({
|
|
|
|
showMessageLogModal: state.showMessageLogModal,
|
|
|
|
showMessageLogModal: state.showMessageLogModal,
|
|
|
|
})))
|
|
|
|
})))
|
|
|
|
const showSingleRunPanel = useStore(s => s.showSingleRunPanel)
|
|
|
|
const showSingleRunPanel = useStore(s => s.showSingleRunPanel)
|
|
|
|
const panelWidth = localStorage.getItem('workflow-node-panel-width') ? Number.parseFloat(localStorage.getItem('workflow-node-panel-width')!) : 420
|
|
|
|
const workflowCanvasWidth = useStore(s => s.workflowCanvasWidth)
|
|
|
|
const {
|
|
|
|
const nodePanelWidth = useStore(s => s.nodePanelWidth)
|
|
|
|
setPanelWidth,
|
|
|
|
const otherPanelWidth = useStore(s => s.otherPanelWidth)
|
|
|
|
} = useWorkflow()
|
|
|
|
const setNodePanelWidth = useStore(s => s.setNodePanelWidth)
|
|
|
|
const { handleNodeSelect } = useNodesInteractions()
|
|
|
|
|
|
|
|
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
|
|
|
const maxNodePanelWidth = useMemo(() => {
|
|
|
|
const { nodesReadOnly } = useNodesReadOnly()
|
|
|
|
if (!workflowCanvasWidth)
|
|
|
|
const { availableNextBlocks } = useAvailableBlocks(data.type, data.isInIteration, data.isInLoop)
|
|
|
|
return 720
|
|
|
|
const toolIcon = useToolIcon(data)
|
|
|
|
if (!otherPanelWidth)
|
|
|
|
|
|
|
|
return workflowCanvasWidth - 400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return workflowCanvasWidth - otherPanelWidth - 400
|
|
|
|
|
|
|
|
}, [workflowCanvasWidth, otherPanelWidth])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateNodePanelWidth = useCallback((width: number) => {
|
|
|
|
|
|
|
|
// Ensure the width is within the min and max range
|
|
|
|
|
|
|
|
const newValue = Math.min(Math.max(width, 400), maxNodePanelWidth)
|
|
|
|
|
|
|
|
localStorage.setItem('workflow-node-panel-width', `${newValue}`)
|
|
|
|
|
|
|
|
setNodePanelWidth(newValue)
|
|
|
|
|
|
|
|
}, [maxNodePanelWidth, setNodePanelWidth])
|
|
|
|
|
|
|
|
|
|
|
|
const handleResize = useCallback((width: number) => {
|
|
|
|
const handleResize = useCallback((width: number) => {
|
|
|
|
setPanelWidth(width)
|
|
|
|
updateNodePanelWidth(width)
|
|
|
|
}, [setPanelWidth])
|
|
|
|
}, [updateNodePanelWidth])
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
triggerRef,
|
|
|
|
triggerRef,
|
|
|
|
@ -89,15 +102,28 @@ const BasePanel: FC<BasePanelProps> = ({
|
|
|
|
} = useResizePanel({
|
|
|
|
} = useResizePanel({
|
|
|
|
direction: 'horizontal',
|
|
|
|
direction: 'horizontal',
|
|
|
|
triggerDirection: 'left',
|
|
|
|
triggerDirection: 'left',
|
|
|
|
minWidth: 420,
|
|
|
|
minWidth: 400,
|
|
|
|
maxWidth: 720,
|
|
|
|
maxWidth: maxNodePanelWidth,
|
|
|
|
onResize: handleResize,
|
|
|
|
onResize: debounce(handleResize),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const debounceUpdate = debounce(updateNodePanelWidth)
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if (!workflowCanvasWidth)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
if (workflowCanvasWidth - 400 <= nodePanelWidth + otherPanelWidth)
|
|
|
|
|
|
|
|
debounceUpdate(workflowCanvasWidth - 400 - otherPanelWidth)
|
|
|
|
|
|
|
|
}, [nodePanelWidth, otherPanelWidth, workflowCanvasWidth, updateNodePanelWidth])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { handleNodeSelect } = useNodesInteractions()
|
|
|
|
|
|
|
|
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
|
|
|
|
|
|
|
const { nodesReadOnly } = useNodesReadOnly()
|
|
|
|
|
|
|
|
const { availableNextBlocks } = useAvailableBlocks(data.type, data.isInIteration, data.isInLoop)
|
|
|
|
|
|
|
|
const toolIcon = useToolIcon(data)
|
|
|
|
|
|
|
|
|
|
|
|
const { saveStateToHistory } = useWorkflowHistory()
|
|
|
|
const { saveStateToHistory } = useWorkflowHistory()
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
handleNodeDataUpdate,
|
|
|
|
|
|
|
|
handleNodeDataUpdateWithSyncDraft,
|
|
|
|
handleNodeDataUpdateWithSyncDraft,
|
|
|
|
} = useNodeDataUpdate()
|
|
|
|
} = useNodeDataUpdate()
|
|
|
|
|
|
|
|
|
|
|
|
@ -117,7 +143,6 @@ const BasePanel: FC<BasePanelProps> = ({
|
|
|
|
isShowSingleRun,
|
|
|
|
isShowSingleRun,
|
|
|
|
showSingleRun,
|
|
|
|
showSingleRun,
|
|
|
|
hideSingleRun,
|
|
|
|
hideSingleRun,
|
|
|
|
toVarInputs,
|
|
|
|
|
|
|
|
runningStatus,
|
|
|
|
runningStatus,
|
|
|
|
handleRun,
|
|
|
|
handleRun,
|
|
|
|
handleStop,
|
|
|
|
handleStop,
|
|
|
|
@ -144,19 +169,19 @@ const BasePanel: FC<BasePanelProps> = ({
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className={cn(
|
|
|
|
<div className={cn(
|
|
|
|
'relative mr-2 h-full',
|
|
|
|
'relative mr-1 h-full',
|
|
|
|
showMessageLogModal && '!absolute -top-[5px] right-[416px] z-0 !mr-0 w-[384px] overflow-hidden rounded-2xl border-[0.5px] border-components-panel-border shadow-lg transition-all',
|
|
|
|
showMessageLogModal && '!absolute -top-[5px] right-[416px] z-0 !mr-0 w-[384px] overflow-hidden rounded-2xl border-[0.5px] border-components-panel-border shadow-lg transition-all',
|
|
|
|
)}>
|
|
|
|
)}>
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
ref={triggerRef}
|
|
|
|
ref={triggerRef}
|
|
|
|
className='absolute -left-2 top-1/2 h-6 w-3 -translate-y-1/2 cursor-col-resize resize-x'>
|
|
|
|
className='absolute -left-1 top-0 flex h-full w-1 cursor-col-resize resize-x items-center justify-center'>
|
|
|
|
<div className='h-6 w-1 rounded-sm bg-divider-regular'></div>
|
|
|
|
<div className='h-10 w-0.5 rounded-sm bg-state-base-handle hover:h-full hover:bg-state-accent-solid active:h-full active:bg-state-accent-solid'></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
ref={containerRef}
|
|
|
|
ref={containerRef}
|
|
|
|
className={cn('h-full rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-lg', showSingleRunPanel ? 'overflow-hidden' : 'overflow-y-auto')}
|
|
|
|
className={cn('h-full rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-lg', showSingleRunPanel ? 'overflow-hidden' : 'overflow-y-auto')}
|
|
|
|
style={{
|
|
|
|
style={{
|
|
|
|
width: `${panelWidth}px`,
|
|
|
|
width: `${nodePanelWidth}px`,
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div className='sticky top-0 z-10 border-b-[0.5px] border-divider-regular bg-components-panel-bg'>
|
|
|
|
<div className='sticky top-0 z-10 border-b-[0.5px] border-divider-regular bg-components-panel-bg'>
|
|
|
|
|