|
@@ -20,6 +20,7 @@ import ReactFlow, {
|
|
useEdgesState,
|
|
useEdgesState,
|
|
useNodesState,
|
|
useNodesState,
|
|
useOnViewportChange,
|
|
useOnViewportChange,
|
|
|
|
+ useReactFlow,
|
|
} from 'reactflow'
|
|
} from 'reactflow'
|
|
import type {
|
|
import type {
|
|
Viewport,
|
|
Viewport,
|
|
@@ -32,6 +33,7 @@ import type {
|
|
} from './types'
|
|
} from './types'
|
|
import { WorkflowContextProvider } from './context'
|
|
import { WorkflowContextProvider } from './context'
|
|
import {
|
|
import {
|
|
|
|
+ useDSL,
|
|
useEdgesInteractions,
|
|
useEdgesInteractions,
|
|
useNodesInteractions,
|
|
useNodesInteractions,
|
|
useNodesReadOnly,
|
|
useNodesReadOnly,
|
|
@@ -58,6 +60,7 @@ import CandidateNode from './candidate-node'
|
|
import PanelContextmenu from './panel-contextmenu'
|
|
import PanelContextmenu from './panel-contextmenu'
|
|
import NodeContextmenu from './node-contextmenu'
|
|
import NodeContextmenu from './node-contextmenu'
|
|
import SyncingDataModal from './syncing-data-modal'
|
|
import SyncingDataModal from './syncing-data-modal'
|
|
|
|
+import UpdateDSLModal from './update-dsl-modal'
|
|
import {
|
|
import {
|
|
useStore,
|
|
useStore,
|
|
useWorkflowStore,
|
|
useWorkflowStore,
|
|
@@ -76,6 +79,7 @@ import {
|
|
import Loading from '@/app/components/base/loading'
|
|
import Loading from '@/app/components/base/loading'
|
|
import { FeaturesProvider } from '@/app/components/base/features'
|
|
import { FeaturesProvider } from '@/app/components/base/features'
|
|
import type { Features as FeaturesData } from '@/app/components/base/features/types'
|
|
import type { Features as FeaturesData } from '@/app/components/base/features/types'
|
|
|
|
+import { useFeaturesStore } from '@/app/components/base/features/hooks'
|
|
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
|
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
|
import Confirm from '@/app/components/base/confirm/common'
|
|
import Confirm from '@/app/components/base/confirm/common'
|
|
|
|
|
|
@@ -99,15 +103,20 @@ const Workflow: FC<WorkflowProps> = memo(({
|
|
}) => {
|
|
}) => {
|
|
const workflowContainerRef = useRef<HTMLDivElement>(null)
|
|
const workflowContainerRef = useRef<HTMLDivElement>(null)
|
|
const workflowStore = useWorkflowStore()
|
|
const workflowStore = useWorkflowStore()
|
|
|
|
+ const reactflow = useReactFlow()
|
|
|
|
+ const featuresStore = useFeaturesStore()
|
|
const [nodes, setNodes] = useNodesState(originalNodes)
|
|
const [nodes, setNodes] = useNodesState(originalNodes)
|
|
const [edges, setEdges] = useEdgesState(originalEdges)
|
|
const [edges, setEdges] = useEdgesState(originalEdges)
|
|
const showFeaturesPanel = useStore(state => state.showFeaturesPanel)
|
|
const showFeaturesPanel = useStore(state => state.showFeaturesPanel)
|
|
const controlMode = useStore(s => s.controlMode)
|
|
const controlMode = useStore(s => s.controlMode)
|
|
const nodeAnimation = useStore(s => s.nodeAnimation)
|
|
const nodeAnimation = useStore(s => s.nodeAnimation)
|
|
const showConfirm = useStore(s => s.showConfirm)
|
|
const showConfirm = useStore(s => s.showConfirm)
|
|
|
|
+ const showImportDSLModal = useStore(s => s.showImportDSLModal)
|
|
const {
|
|
const {
|
|
setShowConfirm,
|
|
setShowConfirm,
|
|
setControlPromptEditorRerenderKey,
|
|
setControlPromptEditorRerenderKey,
|
|
|
|
+ setShowImportDSLModal,
|
|
|
|
+ setSyncWorkflowDraftHash,
|
|
} = workflowStore.getState()
|
|
} = workflowStore.getState()
|
|
const {
|
|
const {
|
|
handleSyncWorkflowDraft,
|
|
handleSyncWorkflowDraft,
|
|
@@ -122,6 +131,19 @@ const Workflow: FC<WorkflowProps> = memo(({
|
|
if (v.type === WORKFLOW_DATA_UPDATE) {
|
|
if (v.type === WORKFLOW_DATA_UPDATE) {
|
|
setNodes(v.payload.nodes)
|
|
setNodes(v.payload.nodes)
|
|
setEdges(v.payload.edges)
|
|
setEdges(v.payload.edges)
|
|
|
|
+
|
|
|
|
+ if (v.payload.viewport)
|
|
|
|
+ reactflow.setViewport(v.payload.viewport)
|
|
|
|
+
|
|
|
|
+ if (v.payload.features && featuresStore) {
|
|
|
|
+ const { setFeatures } = featuresStore.getState()
|
|
|
|
+
|
|
|
|
+ setFeatures(v.payload.features)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (v.payload.hash)
|
|
|
|
+ setSyncWorkflowDraftHash(v.payload.hash)
|
|
|
|
+
|
|
setTimeout(() => setControlPromptEditorRerenderKey(Date.now()))
|
|
setTimeout(() => setControlPromptEditorRerenderKey(Date.now()))
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -204,11 +226,15 @@ const Workflow: FC<WorkflowProps> = memo(({
|
|
} = useSelectionInteractions()
|
|
} = useSelectionInteractions()
|
|
const {
|
|
const {
|
|
handlePaneContextMenu,
|
|
handlePaneContextMenu,
|
|
|
|
+ handlePaneContextmenuCancel,
|
|
} = usePanelInteractions()
|
|
} = usePanelInteractions()
|
|
const {
|
|
const {
|
|
isValidConnection,
|
|
isValidConnection,
|
|
} = useWorkflow()
|
|
} = useWorkflow()
|
|
const { handleStartWorkflowRun } = useWorkflowStartRun()
|
|
const { handleStartWorkflowRun } = useWorkflowStartRun()
|
|
|
|
+ const {
|
|
|
|
+ handleExportDSL,
|
|
|
|
+ } = useDSL()
|
|
|
|
|
|
useOnViewportChange({
|
|
useOnViewportChange({
|
|
onEnd: () => {
|
|
onEnd: () => {
|
|
@@ -266,6 +292,15 @@ const Workflow: FC<WorkflowProps> = memo(({
|
|
/>
|
|
/>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
+ {
|
|
|
|
+ showImportDSLModal && (
|
|
|
|
+ <UpdateDSLModal
|
|
|
|
+ onCancel={() => setShowImportDSLModal(false)}
|
|
|
|
+ onBackup={handleExportDSL}
|
|
|
|
+ onImport={handlePaneContextmenuCancel}
|
|
|
|
+ />
|
|
|
|
+ )
|
|
|
|
+ }
|
|
<ReactFlow
|
|
<ReactFlow
|
|
nodeTypes={nodeTypes}
|
|
nodeTypes={nodeTypes}
|
|
edgeTypes={edgeTypes}
|
|
edgeTypes={edgeTypes}
|