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
261e56e6
Commit
261e56e6
authored
Mar 05, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
single run
parent
ede0bb53
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
13 deletions
+26
-13
hooks.ts
web/app/components/workflow/hooks.ts
+1
-2
node-control.tsx
...mponents/workflow/nodes/_base/components/node-control.tsx
+14
-1
node.tsx
web/app/components/workflow/nodes/_base/node.tsx
+1
-1
panel.tsx
web/app/components/workflow/nodes/_base/panel.tsx
+2
-4
index.tsx
web/app/components/workflow/nodes/index.tsx
+6
-2
types.ts
web/app/components/workflow/types.ts
+2
-3
No files found.
web/app/components/workflow/hooks.ts
View file @
261e56e6
...
...
@@ -18,7 +18,6 @@ import {
import
type
{
BlockEnum
,
Node
,
SelectedNode
,
}
from
'./types'
import
{
NODES_INITIAL_DATA
}
from
'./constants'
import
{
getLayoutByDagre
}
from
'./utils'
...
...
@@ -258,7 +257,7 @@ export const useWorkflow = () => {
setEdges
(
newEdges
)
},
[
store
])
const
handleNodeDataUpdate
=
useCallback
(({
id
,
data
}:
SelectedNode
)
=>
{
const
handleNodeDataUpdate
=
useCallback
(({
id
,
data
}:
{
id
:
string
;
data
:
Record
<
string
,
any
>
}
)
=>
{
const
{
getNodes
,
setNodes
,
...
...
web/app/components/workflow/nodes/_base/components/node-control.tsx
View file @
261e56e6
import
type
{
FC
}
from
'react'
import
{
memo
}
from
'react'
import
{
useWorkflow
}
from
'../../../hooks'
import
{
DotsHorizontal
,
Loading02
,
...
...
@@ -11,10 +12,14 @@ import {
type
NodeControlProps
=
{
isRunning
?:
boolean
nodeId
:
string
}
const
NodeControl
:
FC
<
NodeControlProps
>
=
({
isRunning
,
nodeId
,
})
=>
{
const
{
handleNodeDataUpdate
}
=
useWorkflow
()
return
(
<
div
className=
'absolute right-0 -top-7 flex items-center px-0.5 h-6 bg-white rounded-lg border-[0.5px] border-gray-100 shadow-xs text-gray-500'
>
{
...
...
@@ -25,7 +30,15 @@ const NodeControl: FC<NodeControlProps> = ({
</
div
>
)
}
<
div
className=
'flex items-center justify-center w-5 h-5 cursor-pointer'
>
<
div
className=
'flex items-center justify-center w-5 h-5 cursor-pointer'
onClick=
{
()
=>
{
handleNodeDataUpdate
({
id
:
nodeId
,
data
:
{
_isSingleRun
:
!
isRunning
},
})
}
}
>
{
isRunning
?
<
Stop
className=
'w-3 h-3'
/>
...
...
web/app/components/workflow/nodes/_base/node.tsx
View file @
261e56e6
...
...
@@ -6,7 +6,7 @@ import {
cloneElement
,
memo
,
}
from
'react'
import
type
{
NodeProps
}
from
'
reactflow
'
import
type
{
NodeProps
}
from
'
../../types
'
import
BlockIcon
from
'../../block-icon'
type
BaseNodeProps
=
{
...
...
web/app/components/workflow/nodes/_base/panel.tsx
View file @
261e56e6
...
...
@@ -6,7 +6,6 @@ import {
cloneElement
,
memo
,
useCallback
,
useState
,
}
from
'react'
import
{
type
Node
}
from
'../../types'
import
{
BlockEnum
}
from
'../../types'
...
...
@@ -39,7 +38,6 @@ const BasePanel: FC<BasePanelProps> = ({
handleNodeSelect
,
handleNodeDataUpdate
,
}
=
useWorkflow
()
const
[
controlSingleRun
,
setControlSingleRun
]
=
useState
(
0
)
const
handleTitleChange
=
useCallback
((
title
:
string
)
=>
{
handleNodeDataUpdate
({
id
,
data
:
{
...
data
,
title
}
})
},
[
handleNodeDataUpdate
,
id
,
data
])
...
...
@@ -68,7 +66,7 @@ const BasePanel: FC<BasePanelProps> = ({
>
<
div
className=
'flex items-center justify-center mr-1 w-6 h-6 rounded-md hover:bg-black/5 cursor-pointer'
onClick=
{
()
=>
!
controlSingleRun
&&
setControlSingleRun
(
Date
.
now
()
)
}
onClick=
{
()
=>
handleNodeDataUpdate
({
id
,
data
:
{
_isSingleRun
:
true
}
}
)
}
>
<
Play
className=
'w-4 h-4 text-gray-500'
/>
</
div
>
...
...
@@ -93,7 +91,7 @@ const BasePanel: FC<BasePanelProps> = ({
</
div
>
</
div
>
<
div
className=
'py-2'
>
{
cloneElement
(
children
,
{
id
,
data
,
controlSingleRun
,
setControlSingleRun
})
}
{
cloneElement
(
children
,
{
id
,
data
})
}
</
div
>
{
data
.
type
!==
BlockEnum
.
End
&&
(
...
...
web/app/components/workflow/nodes/index.tsx
View file @
261e56e6
...
...
@@ -16,6 +16,7 @@ import {
import
NodeControl
from
'./_base/components/node-control'
const
CustomNode
=
memo
((
props
:
NodeProps
)
=>
{
const
nodeId
=
props
.
id
const
nodeData
=
props
.
data
const
NodeComponent
=
NodeComponentMap
[
nodeData
.
type
]
...
...
@@ -43,10 +44,13 @@ const CustomNode = memo((props: NodeProps) => {
)
}
{
nodeData
.
hovering
nodeData
.
_selected
&&
canRunBySingle
(
nodeData
.
type
)
&&
(
<
NodeControl
/>
<
NodeControl
nodeId=
{
nodeId
}
isRunning=
{
nodeData
.
_isSingleRun
}
/>
)
}
</>
...
...
web/app/components/workflow/types.ts
View file @
261e56e6
...
...
@@ -27,6 +27,7 @@ export type CommonNodeType<T = {}> = {
_selected
?:
boolean
_hovering
?:
boolean
_targetBranches
?:
Branch
[]
_isSingleRun
?:
boolean
title
:
string
desc
:
string
type
:
BlockEnum
...
...
@@ -39,12 +40,10 @@ export type CommonEdgeType = {
export
type
Node
=
ReactFlowNode
<
CommonNodeType
>
export
type
SelectedNode
=
Pick
<
Node
,
'id'
|
'data'
>
export
type
NodeProps
<
T
>
=
{
id
:
string
;
data
:
CommonNodeType
<
T
>
}
export
type
NodeProps
<
T
=
unknown
>
=
{
id
:
string
;
data
:
CommonNodeType
<
T
>
}
export
type
NodePanelProps
<
T
>
=
{
id
:
string
data
:
CommonNodeType
<
T
>
controlSingleRun
:
boolean
setControlSingleRun
:
(
value
:
boolean
)
=>
void
}
export
type
Edge
=
ReactFlowEdge
<
CommonEdgeType
>
...
...
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