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
25b4e68f
Commit
25b4e68f
authored
Feb 19, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete
parent
c9093194
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
18 deletions
+12
-18
utils.ts
web/app/components/workflow/block-selector/utils.ts
+0
-6
node.tsx
web/app/components/workflow/nodes/_base/node.tsx
+1
-2
panel.tsx
web/app/components/workflow/nodes/_base/panel.tsx
+1
-2
constants.ts
web/app/components/workflow/nodes/constants.ts
+2
-2
index.tsx
web/app/components/workflow/nodes/index.tsx
+8
-6
No files found.
web/app/components/workflow/block-selector/utils.ts
deleted
100644 → 0
View file @
c9093194
import
type
{
BlockEnum
}
from
'../types'
import
{
BLOCKS
}
from
'./constants'
export
const
getBlockByType
=
(
type
:
BlockEnum
)
=>
{
return
BLOCKS
.
find
(
block
=>
block
.
type
===
type
)
}
web/app/components/workflow/nodes/_base/node.tsx
View file @
25b4e68f
...
...
@@ -12,7 +12,6 @@ import type { NodeProps } from 'reactflow'
import
{
getOutgoers
}
from
'reactflow'
import
{
useWorkflowContext
}
from
'../../context'
import
BlockSelector
from
'../../block-selector'
import
{
getBlockByType
}
from
'../../block-selector/utils'
import
BlockIcon
from
'../../block-icon'
import
{
Plus
}
from
'@/app/components/base/icons/src/vender/line/general'
...
...
@@ -71,7 +70,7 @@ const BaseNode: FC<BaseNodeProps> = ({
size=
'md'
/>
<
div
className=
'text-[13px] font-semibold text-gray-700'
>
{
getBlockByType
(
currentNode
!
.
data
.
type
)?
.
title
}
{
data
.
title
}
</
div
>
</
div
>
{
cloneElement
(
children
,
{
id
:
nodeId
,
data
})
}
...
...
web/app/components/workflow/nodes/_base/panel.tsx
View file @
25b4e68f
...
...
@@ -9,7 +9,6 @@ import {
import
type
{
NodeProps
}
from
'reactflow'
import
{
useWorkflowContext
}
from
'../../context'
import
BlockIcon
from
'../../block-icon'
import
{
getBlockByType
}
from
'../../block-selector/utils'
import
NextStep
from
'./components/next-step'
import
{
XClose
}
from
'@/app/components/base/icons/src/vender/line/general'
import
{
GitBranch01
}
from
'@/app/components/base/icons/src/vender/line/development'
...
...
@@ -37,7 +36,7 @@ const BasePanel: FC<BasePanelProps> = ({
type=
{
selectedNode
!
.
data
.
type
}
size=
'md'
/>
<
div
className=
'grow py-1 text-base text-gray-900 font-semibold '
>
{
getBlockByType
(
selectedNode
!
.
data
.
type
)?
.
title
}
</
div
>
<
div
className=
'grow py-1 text-base text-gray-900 font-semibold '
>
{
data
.
title
}
</
div
>
<
div
className=
'shrink-0 flex items-center'
>
<
div
className=
'flex items-center justify-center w-6 h-6 cursor-pointer'
...
...
web/app/components/workflow/nodes/constants.ts
View file @
25b4e68f
...
...
@@ -23,7 +23,7 @@ import HttpPanel from './http/panel'
import
ToolNode
from
'./tool/node'
import
ToolPanel
from
'./tool/panel'
export
const
NodeMap
:
Record
<
string
,
ComponentType
>
=
{
export
const
Node
Component
Map
:
Record
<
string
,
ComponentType
>
=
{
[
BlockEnum
.
Start
]:
StartNode
,
[
BlockEnum
.
End
]:
EndNode
,
[
BlockEnum
.
DirectAnswer
]:
DirectAnswerNode
,
...
...
@@ -37,7 +37,7 @@ export const NodeMap: Record<string, ComponentType> = {
[
BlockEnum
.
Tool
]:
ToolNode
,
}
export
const
PanelMap
:
Record
<
string
,
ComponentType
>
=
{
export
const
Panel
Component
Map
:
Record
<
string
,
ComponentType
>
=
{
[
BlockEnum
.
Start
]:
StartPanel
,
[
BlockEnum
.
End
]:
EndPanel
,
[
BlockEnum
.
DirectAnswer
]:
DirectAnswerPanel
,
...
...
web/app/components/workflow/nodes/index.tsx
View file @
25b4e68f
...
...
@@ -6,8 +6,8 @@ import {
}
from
'reactflow'
import
{
useWorkflowContext
}
from
'../context'
import
{
NodeMap
,
PanelMap
,
Node
Component
Map
,
Panel
Component
Map
,
}
from
'./constants'
import
BaseNode
from
'./_base/node'
import
BasePanel
from
'./_base/panel'
...
...
@@ -16,7 +16,7 @@ const CustomNode = ({
id
,
data
,
}:
NodeProps
)
=>
{
const
NodeComponent
=
NodeMap
[
data
.
type
]
const
NodeComponent
=
Node
Component
Map
[
data
.
type
]
return
(
<>
...
...
@@ -40,13 +40,13 @@ const CustomNode = ({
)
}
export
const
Panel
=
()
=>
{
export
const
Panel
=
memo
(
()
=>
{
const
{
selectedNode
}
=
useWorkflowContext
()
if
(
!
selectedNode
)
return
null
const
PanelComponent
=
PanelMap
[
selectedNode
.
data
.
type
]
const
PanelComponent
=
Panel
Component
Map
[
selectedNode
.
data
.
type
]
return
(
<
BasePanel
...
...
@@ -56,6 +56,8 @@ export const Panel = () => {
<
PanelComponent
/>
</
BasePanel
>
)
}
})
Panel
.
displayName
=
'Panel'
export
default
memo
(
CustomNode
)
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