feat: workflow remove preview mode (#3941)

This commit is contained in:
zxhlyh
2024-04-28 17:09:56 +08:00
committed by GitHub
parent 0940f01634
commit 8e4989ed03
33 changed files with 549 additions and 309 deletions

View File

@@ -1,9 +1,7 @@
import type { FC } from 'react'
import {
memo,
useMemo,
} from 'react'
import { memo } from 'react'
import { useNodes } from 'reactflow'
import cn from 'classnames'
import { useShallow } from 'zustand/react/shallow'
import type { CommonNodeType } from '../types'
import { Panel as NodePanel } from '../nodes'
@@ -23,9 +21,8 @@ const Panel: FC = () => {
const nodes = useNodes<CommonNodeType>()
const isChatMode = useIsChatMode()
const selectedNode = nodes.find(node => node.data.selected)
const showInputsPanel = useStore(s => s.showInputsPanel)
const workflowRunningData = useStore(s => s.workflowRunningData)
const historyWorkflowData = useStore(s => s.historyWorkflowData)
const showDebugAndPreviewPanel = useStore(s => s.showDebugAndPreviewPanel)
const isRestoring = useStore(s => s.isRestoring)
const {
enableShortcuts,
@@ -37,28 +34,13 @@ const Panel: FC = () => {
showMessageLogModal: state.showMessageLogModal,
setShowMessageLogModal: state.setShowMessageLogModal,
})))
const {
showNodePanel,
showDebugAndPreviewPanel,
showWorkflowPreview,
} = useMemo(() => {
return {
showNodePanel: !!selectedNode && !workflowRunningData && !historyWorkflowData && !showInputsPanel,
showDebugAndPreviewPanel: isChatMode && workflowRunningData && !historyWorkflowData,
showWorkflowPreview: !isChatMode && !historyWorkflowData && (workflowRunningData || showInputsPanel),
}
}, [
showInputsPanel,
selectedNode,
isChatMode,
workflowRunningData,
historyWorkflowData,
])
return (
<div
tabIndex={-1}
className='absolute top-14 right-0 bottom-2 flex z-10 outline-none'
className={cn(
'absolute top-14 right-0 bottom-2 flex z-10 outline-none',
)}
onFocus={disableShortcuts}
onBlur={enableShortcuts}
key={`${isRestoring}`}
@@ -76,6 +58,11 @@ const Panel: FC = () => {
/>
)
}
{
!!selectedNode && (
<NodePanel {...selectedNode!} />
)
}
{
historyWorkflowData && !isChatMode && (
<Record />
@@ -87,20 +74,15 @@ const Panel: FC = () => {
)
}
{
showDebugAndPreviewPanel && (
showDebugAndPreviewPanel && isChatMode && (
<DebugAndPreview />
)
}
{
showWorkflowPreview && (
showDebugAndPreviewPanel && !isChatMode && (
<WorkflowPreview />
)
}
{
showNodePanel && (
<NodePanel {...selectedNode!} />
)
}
</div>
)
}