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
cbe7de58
Commit
cbe7de58
authored
Mar 13, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backup draft
parent
801160c4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
30 deletions
+51
-30
index.tsx
web/app/components/workflow/block-selector/index.tsx
+2
-2
custom-edge.tsx
web/app/components/workflow/custom-edge.tsx
+28
-18
use-workflow-run.ts
web/app/components/workflow/hooks/use-workflow-run.ts
+21
-10
No files found.
web/app/components/workflow/block-selector/index.tsx
View file @
cbe7de58
...
...
@@ -61,8 +61,8 @@ const NodeSelector: FC<NodeSelectorProps> = ({
},
[
onOpenChange
])
const
handleTrigger
=
useCallback
<
MouseEventHandler
<
HTMLDivElement
>>
((
e
)
=>
{
e
.
stopPropagation
()
setLocalOpen
(
v
=>
!
v
)
},
[])
handleOpenChange
(
!
open
)
},
[
handleOpenChange
,
open
])
const
handleSelect
=
useCallback
<
OnSelectBlock
>
((
type
,
toolDefaultValue
)
=>
{
handleOpenChange
(
false
)
onSelect
(
type
,
toolDefaultValue
)
...
...
web/app/components/workflow/custom-edge.tsx
View file @
cbe7de58
import
{
memo
}
from
'react'
import
{
memo
,
useCallback
,
useState
,
}
from
'react'
import
type
{
EdgeProps
}
from
'reactflow'
import
{
BaseEdge
,
...
...
@@ -29,6 +33,10 @@ const CustomEdge = ({
targetY
,
targetPosition
:
Position
.
Left
,
})
const
[
open
,
setOpen
]
=
useState
(
false
)
const
handleOpenChange
=
useCallback
((
v
:
boolean
)
=>
{
setOpen
(
v
)
},
[])
return
(
<>
...
...
@@ -41,10 +49,12 @@ const CustomEdge = ({
}
}
/>
<
EdgeLabelRenderer
>
{
data
?.
_hovering
&&
(
<
div
className=
'nopan nodrag'
className=
{
`
nopan nodrag
${data?._hovering ? 'block' : 'hidden'}
${open && '!block'}
`
}
style=
{
{
position
:
'absolute'
,
transform
:
`translate(-50%, -50%) translate(${labelX}px, ${labelY}px)`
,
...
...
@@ -52,12 +62,12 @@ const CustomEdge = ({
}
}
>
<
BlockSelector
open=
{
open
}
onOpenChange=
{
handleOpenChange
}
asChild
onSelect=
{
()
=>
{}
}
/>
</
div
>
)
}
</
EdgeLabelRenderer
>
</>
)
...
...
web/app/components/workflow/hooks/use-workflow-run.ts
View file @
cbe7de58
...
...
@@ -22,6 +22,23 @@ export const useWorkflowRun = () => {
const
reactflow
=
useReactFlow
()
const
workflowContainerRef
=
useRef
<
HTMLDivElement
>
(
null
)
const
handleBackupDraft
=
useCallback
(()
=>
{
const
{
getNodes
,
getEdges
,
getViewport
,
}
=
reactflow
const
{
setBackupDraft
,
}
=
useStore
.
getState
()
setBackupDraft
({
nodes
:
getNodes
(),
edges
:
getEdges
(),
viewport
:
getViewport
(),
})
},
[
reactflow
])
const
handleLoadBackupDraft
=
useCallback
(()
=>
{
const
{
setNodes
,
...
...
@@ -55,9 +72,10 @@ export const useWorkflowRun = () => {
handleLoadBackupDraft
()
}
else
{
handleBackupDraft
()
const
newNodes
=
produce
(
getNodes
(),
(
draft
)
=>
{
draft
.
forEach
((
node
)
=>
{
node
.
data
.
_runningStatus
=
shouldClear
?
undefined
:
NodeRunningStatus
.
Waiting
node
.
data
.
_runningStatus
=
NodeRunningStatus
.
Waiting
})
})
setNodes
(
newNodes
)
...
...
@@ -68,7 +86,7 @@ export const useWorkflowRun = () => {
})
setEdges
(
newEdges
)
}
},
[
store
,
handleLoadBackupDraft
])
},
[
store
,
handleLoadBackupDraft
,
handleBackupDraft
])
const
handleRun
=
useCallback
((
params
:
any
,
callback
?:
IOtherOptions
)
=>
{
const
{
...
...
@@ -77,8 +95,6 @@ export const useWorkflowRun = () => {
edges
,
setEdges
,
}
=
store
.
getState
()
const
{
getViewport
}
=
reactflow
const
{
setBackupDraft
}
=
useStore
.
getState
()
const
appDetail
=
useAppStore
.
getState
().
appDetail
const
workflowContainer
=
document
.
getElementById
(
'workflow-container'
)
...
...
@@ -87,12 +103,6 @@ export const useWorkflowRun = () => {
clientHeight
,
}
=
workflowContainer
!
setBackupDraft
({
nodes
:
getNodes
(),
edges
,
viewport
:
getViewport
(),
})
let
url
=
''
if
(
appDetail
?.
mode
===
'advanced-chat'
)
url
=
`/apps/
${
appDetail
.
id
}
/advanced-chat/workflows/draft/run`
...
...
@@ -164,6 +174,7 @@ export const useWorkflowRun = () => {
},
[
store
,
reactflow
])
return
{
handleBackupDraft
,
handleRunSetting
,
handleRun
,
workflowContainerRef
,
...
...
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