Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
e474e02a
Commit
e474e02a
authored
Mar 05, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync workflow draft
parent
54d9cdaa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
1 deletion
+22
-1
hooks.ts
web/app/components/workflow/hooks.ts
+4
-1
index.tsx
web/app/components/workflow/index.tsx
+12
-0
zoom-in-out.tsx
web/app/components/workflow/operator/zoom-in-out.tsx
+4
-0
workflow.ts
web/types/workflow.ts
+2
-0
No files found.
web/app/components/workflow/hooks.ts
View file @
e474e02a
...
@@ -47,6 +47,7 @@ export const useWorkflow = () => {
...
@@ -47,6 +47,7 @@ export const useWorkflow = () => {
getNodes
,
getNodes
,
edges
,
edges
,
}
=
store
.
getState
()
}
=
store
.
getState
()
const
{
getViewport
}
=
reactFlow
const
appId
=
useAppStore
.
getState
().
appDetail
?.
id
const
appId
=
useAppStore
.
getState
().
appDetail
?.
id
if
(
appId
)
{
if
(
appId
)
{
...
@@ -56,12 +57,13 @@ export const useWorkflow = () => {
...
@@ -56,12 +57,13 @@ export const useWorkflow = () => {
graph
:
{
graph
:
{
nodes
:
getNodes
(),
nodes
:
getNodes
(),
edges
,
edges
,
viewport
:
getViewport
(),
},
},
features
:
{},
features
:
{},
},
},
})
})
}
}
},
[
store
])
},
[
store
,
reactFlow
])
const
handleLayout
=
useCallback
(
async
()
=>
{
const
handleLayout
=
useCallback
(
async
()
=>
{
const
{
const
{
...
@@ -430,6 +432,7 @@ export const useWorkflow = () => {
...
@@ -430,6 +432,7 @@ export const useWorkflow = () => {
},
[
store
])
},
[
store
])
return
{
return
{
handleSyncWorkflowDraft
,
handleLayout
,
handleLayout
,
handleSetViewport
,
handleSetViewport
,
...
...
web/app/components/workflow/index.tsx
View file @
e474e02a
...
@@ -10,7 +10,9 @@ import ReactFlow, {
...
@@ -10,7 +10,9 @@ import ReactFlow, {
ReactFlowProvider
,
ReactFlowProvider
,
useEdgesState
,
useEdgesState
,
useNodesState
,
useNodesState
,
useOnViewportChange
,
}
from
'reactflow'
}
from
'reactflow'
import
type
{
Viewport
}
from
'reactflow'
import
'reactflow/dist/style.css'
import
'reactflow/dist/style.css'
import
type
{
import
type
{
Edge
,
Edge
,
...
@@ -47,16 +49,20 @@ const edgeTypes = {
...
@@ -47,16 +49,20 @@ const edgeTypes = {
type
WorkflowProps
=
{
type
WorkflowProps
=
{
nodes
:
Node
[]
nodes
:
Node
[]
edges
:
Edge
[]
edges
:
Edge
[]
viewport
?:
Viewport
}
}
const
Workflow
:
FC
<
WorkflowProps
>
=
memo
(({
const
Workflow
:
FC
<
WorkflowProps
>
=
memo
(({
nodes
:
initialNodes
,
nodes
:
initialNodes
,
edges
:
initialEdges
,
edges
:
initialEdges
,
viewport
,
})
=>
{
})
=>
{
const
showFeaturesPanel
=
useStore
(
state
=>
state
.
showFeaturesPanel
)
const
showFeaturesPanel
=
useStore
(
state
=>
state
.
showFeaturesPanel
)
const
[
nodes
]
=
useNodesState
(
initialNodes
)
const
[
nodes
]
=
useNodesState
(
initialNodes
)
const
[
edges
]
=
useEdgesState
(
initialEdges
)
const
[
edges
]
=
useEdgesState
(
initialEdges
)
const
{
const
{
handleSyncWorkflowDraft
,
handleNodeDragStart
,
handleNodeDragStart
,
handleNodeDrag
,
handleNodeDrag
,
handleNodeDragStop
,
handleNodeDragStop
,
...
@@ -71,6 +77,10 @@ const Workflow: FC<WorkflowProps> = memo(({
...
@@ -71,6 +77,10 @@ const Workflow: FC<WorkflowProps> = memo(({
handleEdgesChange
,
handleEdgesChange
,
}
=
useWorkflow
()
}
=
useWorkflow
()
useOnViewportChange
({
onEnd
:
()
=>
handleSyncWorkflowDraft
(),
})
useKeyPress
(
'Backspace'
,
handleEdgeDelete
)
useKeyPress
(
'Backspace'
,
handleEdgeDelete
)
return
(
return
(
...
@@ -101,6 +111,7 @@ const Workflow: FC<WorkflowProps> = memo(({
...
@@ -101,6 +111,7 @@ const Workflow: FC<WorkflowProps> = memo(({
connectionLineComponent=
{
CustomConnectionLine
}
connectionLineComponent=
{
CustomConnectionLine
}
deleteKeyCode=
{
null
}
deleteKeyCode=
{
null
}
nodeDragThreshold=
{
1
}
nodeDragThreshold=
{
1
}
defaultViewport=
{
viewport
}
>
>
<
Background
<
Background
gap=
{
[
14
,
14
]
}
gap=
{
[
14
,
14
]
}
...
@@ -176,6 +187,7 @@ const WorkflowWrap: FC<WorkflowProps> = ({
...
@@ -176,6 +187,7 @@ const WorkflowWrap: FC<WorkflowProps> = ({
<
Workflow
<
Workflow
nodes=
{
nodesData
}
nodes=
{
nodesData
}
edges=
{
edgesData
}
edges=
{
edgesData
}
viewport=
{
data
?.
graph
.
viewport
}
/>
/>
</
FeaturesProvider
>
</
FeaturesProvider
>
</
ReactFlowProvider
>
</
ReactFlowProvider
>
...
...
web/app/components/workflow/operator/zoom-in-out.tsx
View file @
e474e02a
...
@@ -9,6 +9,7 @@ import {
...
@@ -9,6 +9,7 @@ import {
useReactFlow
,
useReactFlow
,
useViewport
,
useViewport
,
}
from
'reactflow'
}
from
'reactflow'
import
{
useWorkflow
}
from
'../hooks'
import
{
import
{
PortalToFollowElem
,
PortalToFollowElem
,
PortalToFollowElemContent
,
PortalToFollowElemContent
,
...
@@ -26,6 +27,7 @@ const ZoomInOut: FC = () => {
...
@@ -26,6 +27,7 @@ const ZoomInOut: FC = () => {
fitView
,
fitView
,
}
=
useReactFlow
()
}
=
useReactFlow
()
const
{
zoom
}
=
useViewport
()
const
{
zoom
}
=
useViewport
()
const
{
handleSyncWorkflowDraft
}
=
useWorkflow
()
const
[
open
,
setOpen
]
=
useState
(
false
)
const
[
open
,
setOpen
]
=
useState
(
false
)
const
ZOOM_IN_OUT_OPTIONS
=
[
const
ZOOM_IN_OUT_OPTIONS
=
[
...
@@ -72,6 +74,8 @@ const ZoomInOut: FC = () => {
...
@@ -72,6 +74,8 @@ const ZoomInOut: FC = () => {
if
(
type
===
'to100'
)
if
(
type
===
'to100'
)
zoomTo
(
1
)
zoomTo
(
1
)
handleSyncWorkflowDraft
()
}
}
return
(
return
(
...
...
web/types/workflow.ts
View file @
e474e02a
import
type
{
Viewport
}
from
'reactflow'
import
type
{
import
type
{
Edge
,
Edge
,
Node
,
Node
,
...
@@ -8,6 +9,7 @@ export type FetchWorkflowDraftResponse = {
...
@@ -8,6 +9,7 @@ export type FetchWorkflowDraftResponse = {
graph
:
{
graph
:
{
nodes
:
Node
[]
nodes
:
Node
[]
edges
:
Edge
[]
edges
:
Edge
[]
viewport
?:
Viewport
}
}
features
?:
any
features
?:
any
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment