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
e624c33d
Commit
e624c33d
authored
Feb 18, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
node props
parent
36664620
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
9 deletions
+21
-9
custom-edge.tsx
web/app/components/workflow/custom-edge.tsx
+1
-0
node.tsx
web/app/components/workflow/nodes/_base/node.tsx
+15
-3
index.tsx
web/app/components/workflow/nodes/index.tsx
+5
-6
No files found.
web/app/components/workflow/custom-edge.tsx
View file @
e624c33d
...
@@ -23,6 +23,7 @@ const CustomEdge = ({
...
@@ -23,6 +23,7 @@ const CustomEdge = ({
targetX
,
targetX
,
targetY
,
targetY
,
borderRadius
:
30
,
borderRadius
:
30
,
offset
:
-
20
,
})
})
return
(
return
(
...
...
web/app/components/workflow/nodes/_base/node.tsx
View file @
e624c33d
...
@@ -2,8 +2,11 @@ import type {
...
@@ -2,8 +2,11 @@ import type {
FC
,
FC
,
ReactNode
,
ReactNode
,
}
from
'react'
}
from
'react'
import
{
memo
}
from
'react'
import
{
memo
,
useMemo
}
from
'react'
import
{
useNodeId
}
from
'reactflow'
import
{
getOutgoers
,
useNodeId
,
}
from
'reactflow'
import
{
useWorkflowContext
}
from
'../../context'
import
{
useWorkflowContext
}
from
'../../context'
import
{
Plus
}
from
'@/app/components/base/icons/src/vender/line/general'
import
{
Plus
}
from
'@/app/components/base/icons/src/vender/line/general'
...
@@ -16,9 +19,17 @@ const BaseNode: FC<BaseNodeProps> = ({
...
@@ -16,9 +19,17 @@ const BaseNode: FC<BaseNodeProps> = ({
})
=>
{
})
=>
{
const
nodeId
=
useNodeId
()
const
nodeId
=
useNodeId
()
const
{
const
{
nodes
,
edges
,
selectedNodeId
,
selectedNodeId
,
handleSelectedNodeIdChange
,
handleSelectedNodeIdChange
,
}
=
useWorkflowContext
()
}
=
useWorkflowContext
()
const
currentNode
=
useMemo
(()
=>
{
return
nodes
.
find
(
node
=>
node
.
id
===
nodeId
)
},
[
nodeId
,
nodes
])
const
outgoers
=
useMemo
(()
=>
{
return
getOutgoers
(
currentNode
!
,
nodes
,
edges
)
},
[
currentNode
,
nodes
,
edges
])
return
(
return
(
<
div
<
div
...
@@ -39,8 +50,9 @@ const BaseNode: FC<BaseNodeProps> = ({
...
@@ -39,8 +50,9 @@ const BaseNode: FC<BaseNodeProps> = ({
</
div
>
</
div
>
<
div
<
div
className=
{
`
className=
{
`
hidden absolute -bottom-2 left-1/2 -translate-x-1/2
group-hover:flex
items-center justify-center
hidden absolute -bottom-2 left-1/2 -translate-x-1/2 items-center justify-center
w-4 h-4 rounded-full bg-primary-600 cursor-pointer z-10
w-4 h-4 rounded-full bg-primary-600 cursor-pointer z-10
${!outgoers.length && 'group-hover:flex'}
`
}
`
}
>
>
<
Plus
className=
'w-2.5 h-2.5 text-white'
/>
<
Plus
className=
'w-2.5 h-2.5 text-white'
/>
...
...
web/app/components/workflow/nodes/index.tsx
View file @
e624c33d
import
{
memo
}
from
'react'
import
{
memo
}
from
'react'
import
type
{
NodeProps
}
from
'reactflow'
import
{
import
{
Handle
,
Handle
,
Position
,
Position
,
useNodeId
,
}
from
'reactflow'
}
from
'reactflow'
import
{
useWorkflowContext
}
from
'../context'
import
{
useWorkflowContext
}
from
'../context'
import
{
import
{
...
@@ -10,11 +10,10 @@ import {
...
@@ -10,11 +10,10 @@ import {
PanelMap
,
PanelMap
,
}
from
'./constants'
}
from
'./constants'
const
CustomNode
=
()
=>
{
const
CustomNode
=
({
const
nodeId
=
useNodeId
()
data
,
const
{
nodes
}
=
useWorkflowContext
()
}:
NodeProps
)
=>
{
const
currentNode
=
nodes
.
find
(
node
=>
node
.
id
===
nodeId
)
const
NodeComponent
=
NodeMap
[
data
.
type
]
const
NodeComponent
=
NodeMap
[
currentNode
!
.
data
.
type
as
string
]
return
(
return
(
<>
<>
...
...
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