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
a5147a38
Commit
a5147a38
authored
Mar 12, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
74bf6cd1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
5 deletions
+68
-5
hooks.ts
web/app/components/workflow/hooks.ts
+3
-1
title-description-input.tsx
...rkflow/nodes/_base/components/title-description-input.tsx
+6
-2
node.tsx
web/app/components/workflow/nodes/_base/node.tsx
+1
-1
panel.tsx
web/app/components/workflow/nodes/_base/panel.tsx
+2
-0
utils.ts
web/app/components/workflow/utils.ts
+52
-1
workflow.ts
web/i18n/en-US/workflow.ts
+2
-0
workflow.ts
web/i18n/zh-Hans/workflow.ts
+2
-0
No files found.
web/app/components/workflow/hooks.ts
View file @
a5147a38
...
@@ -30,7 +30,9 @@ import {
...
@@ -30,7 +30,9 @@ import {
NODE_WIDTH_X_OFFSET
,
NODE_WIDTH_X_OFFSET
,
Y_OFFSET
,
Y_OFFSET
,
}
from
'./constants'
}
from
'./constants'
import
{
getLayoutByDagre
}
from
'./utils'
import
{
getLayoutByDagre
,
}
from
'./utils'
import
{
useStore
}
from
'./store'
import
{
useStore
}
from
'./store'
import
type
{
ToolDefaultValue
}
from
'./block-selector/types'
import
type
{
ToolDefaultValue
}
from
'./block-selector/types'
import
{
syncWorkflowDraft
}
from
'@/service/workflow'
import
{
syncWorkflowDraft
}
from
'@/service/workflow'
...
...
web/app/components/workflow/nodes/_base/components/title-description-input.tsx
View file @
a5147a38
...
@@ -4,6 +4,7 @@ import {
...
@@ -4,6 +4,7 @@ import {
useState
,
useState
,
}
from
'react'
}
from
'react'
import
Textarea
from
'rc-textarea'
import
Textarea
from
'rc-textarea'
import
{
useTranslation
}
from
'react-i18next'
type
InputProps
=
{
type
InputProps
=
{
value
:
string
value
:
string
...
@@ -14,6 +15,8 @@ export const TitleInput = memo(({
...
@@ -14,6 +15,8 @@ export const TitleInput = memo(({
value
,
value
,
onChange
,
onChange
,
}:
InputProps
)
=>
{
}:
InputProps
)
=>
{
const
{
t
}
=
useTranslation
()
return
(
return
(
<
input
<
input
value=
{
value
}
value=
{
value
}
...
@@ -23,7 +26,7 @@ export const TitleInput = memo(({
...
@@ -23,7 +26,7 @@ export const TitleInput = memo(({
hover:bg-gray-50
hover:bg-gray-50
focus:border-gray-300 focus:shadow-xs focus:bg-white caret-[#295EFF]
focus:border-gray-300 focus:shadow-xs focus:bg-white caret-[#295EFF]
`
}
`
}
placeholder=
'Add title...'
placeholder=
{
t
(
'workflow.common.addTitle'
)
||
''
}
/>
/>
)
)
})
})
...
@@ -33,6 +36,7 @@ export const DescriptionInput = memo(({
...
@@ -33,6 +36,7 @@ export const DescriptionInput = memo(({
value
,
value
,
onChange
,
onChange
,
}:
InputProps
)
=>
{
}:
InputProps
)
=>
{
const
{
t
}
=
useTranslation
()
const
[
focus
,
setFocus
]
=
useState
(
false
)
const
[
focus
,
setFocus
]
=
useState
(
false
)
const
handleFocus
=
useCallback
(()
=>
{
const
handleFocus
=
useCallback
(()
=>
{
setFocus
(
true
)
setFocus
(
true
)
...
@@ -60,7 +64,7 @@ export const DescriptionInput = memo(({
...
@@ -60,7 +64,7 @@ export const DescriptionInput = memo(({
appearance-none outline-none resize-none
appearance-none outline-none resize-none
placeholder:text-gray-400 caret-[#295EFF]
placeholder:text-gray-400 caret-[#295EFF]
`
}
`
}
placeholder=
'Add description...'
placeholder=
{
t
(
'workflow.common.addDescription'
)
||
''
}
autoSize
autoSize
/>
/>
</
div
>
</
div
>
...
...
web/app/components/workflow/nodes/_base/node.tsx
View file @
a5147a38
...
@@ -43,7 +43,7 @@ const BaseNode: FC<BaseNodeProps> = ({
...
@@ -43,7 +43,7 @@ const BaseNode: FC<BaseNodeProps> = ({
className=
{
`
className=
{
`
group relative w-[240px] bg-[#fcfdff] shadow-xs
group relative w-[240px] bg-[#fcfdff] shadow-xs
border border-transparent rounded-[15px]
border border-transparent rounded-[15px]
hover:shadow-lg
${!data._runningStatus && 'hover:shadow-lg'}
${data._runningStatus === NodeRunningStatus.Running && '!border-primary-500'}
${data._runningStatus === NodeRunningStatus.Running && '!border-primary-500'}
${data._runningStatus === NodeRunningStatus.Succeeded && '!border-[#12B76A]'}
${data._runningStatus === NodeRunningStatus.Succeeded && '!border-[#12B76A]'}
${data._runningStatus === NodeRunningStatus.Failed && '!border-[#F04438]'}
${data._runningStatus === NodeRunningStatus.Failed && '!border-[#F04438]'}
...
...
web/app/components/workflow/nodes/_base/panel.tsx
View file @
a5147a38
...
@@ -41,6 +41,8 @@ const BasePanel: FC<BasePanelProps> = ({
...
@@ -41,6 +41,8 @@ const BasePanel: FC<BasePanelProps> = ({
handleNodeDataUpdate
,
handleNodeDataUpdate
,
}
=
useWorkflow
()
}
=
useWorkflow
()
const
handleTitleChange
=
useCallback
((
title
:
string
)
=>
{
const
handleTitleChange
=
useCallback
((
title
:
string
)
=>
{
if
(
!
title
)
return
handleNodeDataUpdate
({
id
,
data
:
{
...
data
,
title
}
})
handleNodeDataUpdate
({
id
,
data
:
{
...
data
,
title
}
})
},
[
handleNodeDataUpdate
,
id
,
data
])
},
[
handleNodeDataUpdate
,
id
,
data
])
const
handleDescriptionChange
=
useCallback
((
desc
:
string
)
=>
{
const
handleDescriptionChange
=
useCallback
((
desc
:
string
)
=>
{
...
...
web/app/components/workflow/utils.ts
View file @
a5147a38
...
@@ -171,6 +171,57 @@ export const canRunBySingle = (nodeType: BlockEnum) => {
...
@@ -171,6 +171,57 @@ export const canRunBySingle = (nodeType: BlockEnum) => {
||
nodeType
===
BlockEnum
.
Tool
||
nodeType
===
BlockEnum
.
Tool
}
}
export
const
getVariables
=
(
currentNodeId
:
string
)
=>
{
export
const
getTreeLeafNodes
=
(
nodes
:
Node
[],
edges
:
Edge
[])
=>
{
const
startNode
=
nodes
.
find
(
node
=>
node
.
data
.
type
===
BlockEnum
.
Start
)
if
(
!
startNode
)
return
[]
const
list
:
Node
[]
=
[]
const
preOrder
=
(
root
:
Node
,
callback
:
(
node
:
Node
)
=>
void
)
=>
{
const
outgoers
=
getOutgoers
(
root
,
nodes
,
edges
)
if
(
outgoers
.
length
)
{
outgoers
.
forEach
((
outgoer
)
=>
{
preOrder
(
outgoer
,
callback
)
})
}
else
{
callback
(
root
)
}
}
preOrder
(
startNode
,
(
node
)
=>
{
list
.
push
(
node
)
})
return
list
}
export
const
getBeforeNodesInSameBranch
=
(
nodeId
:
string
,
targetHandle
:
string
,
nodes
:
Node
[],
edges
:
Edge
[])
=>
{
const
currentNode
=
nodes
.
find
(
node
=>
node
.
id
===
nodeId
)
!
const
list
:
Node
[]
=
[]
const
traverse
=
(
root
:
Node
,
callback
:
(
node
:
Node
)
=>
void
)
=>
{
const
connectedEdges
=
getConnectedEdges
([
root
],
edges
)
const
sourceEdge
=
connectedEdges
.
filter
(
edge
=>
edge
.
targetHandle
===
targetHandle
)
const
sourceEdgeLength
=
sourceEdge
.
length
if
(
sourceEdgeLength
===
1
)
{
const
before
=
nodes
.
find
(
node
=>
node
.
id
===
sourceEdge
[
0
].
source
)
if
(
before
)
{
callback
(
before
)
traverse
(
before
,
callback
)
}
}
}
traverse
(
currentNode
,
(
node
)
=>
{
list
.
push
(
node
)
})
const
length
=
list
.
length
if
(
length
&&
list
[
length
-
1
].
data
.
type
===
BlockEnum
.
Start
)
return
list
.
reverse
()
return
[]
}
}
web/i18n/en-US/workflow.ts
View file @
a5147a38
...
@@ -21,6 +21,8 @@ const translation = {
...
@@ -21,6 +21,8 @@ const translation = {
currentDraft
:
'Current Draft'
,
currentDraft
:
'Current Draft'
,
latestPublished
:
'Latest Published'
,
latestPublished
:
'Latest Published'
,
restore
:
'Restore'
,
restore
:
'Restore'
,
addTitle
:
'Add title...'
,
addDescription
:
'Add description...'
,
},
},
singleRun
:
{
singleRun
:
{
testRun
:
'Test Run '
,
testRun
:
'Test Run '
,
...
...
web/i18n/zh-Hans/workflow.ts
View file @
a5147a38
...
@@ -21,6 +21,8 @@ const translation = {
...
@@ -21,6 +21,8 @@ const translation = {
currentDraft
:
'当前草稿'
,
currentDraft
:
'当前草稿'
,
latestPublished
:
'最新发布'
,
latestPublished
:
'最新发布'
,
restore
:
'恢复'
,
restore
:
'恢复'
,
addTitle
:
'添加标题...'
,
addDescription
:
'添加描述...'
,
},
},
singleRun
:
{
singleRun
:
{
testRun
:
'测试运行 '
,
testRun
:
'测试运行 '
,
...
...
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