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
8ae46a8a
Commit
8ae46a8a
authored
Mar 12, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
97530776
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
5 deletions
+37
-5
hooks.ts
web/app/components/workflow/hooks.ts
+29
-3
class-list.tsx
...kflow/nodes/question-classifier/components/class-list.tsx
+7
-2
panel.tsx
...p/components/workflow/nodes/question-classifier/panel.tsx
+1
-0
No files found.
web/app/components/workflow/hooks.ts
View file @
8ae46a8a
...
@@ -80,7 +80,7 @@ export const useWorkflow = () => {
...
@@ -80,7 +80,7 @@ export const useWorkflow = () => {
if
(
appId
)
{
if
(
appId
)
{
const
features
=
featuresStore
!
.
getState
().
features
const
features
=
featuresStore
!
.
getState
().
features
const
n
odes
=
produce
(
getNodes
(),
(
draft
)
=>
{
const
producedN
odes
=
produce
(
getNodes
(),
(
draft
)
=>
{
draft
.
forEach
((
node
)
=>
{
draft
.
forEach
((
node
)
=>
{
Object
.
keys
(
node
.
data
).
forEach
((
key
)
=>
{
Object
.
keys
(
node
.
data
).
forEach
((
key
)
=>
{
if
(
key
.
startsWith
(
'_'
))
if
(
key
.
startsWith
(
'_'
))
...
@@ -88,12 +88,17 @@ export const useWorkflow = () => {
...
@@ -88,12 +88,17 @@ export const useWorkflow = () => {
})
})
})
})
})
})
const
producedEdges
=
produce
(
edges
,
(
draft
)
=>
{
draft
.
forEach
((
edge
)
=>
{
delete
edge
.
data
})
})
syncWorkflowDraft
({
syncWorkflowDraft
({
url
:
`/apps/
${
appId
}
/workflows/draft`
,
url
:
`/apps/
${
appId
}
/workflows/draft`
,
params
:
{
params
:
{
graph
:
{
graph
:
{
nodes
,
nodes
:
producedNodes
,
edges
,
edges
:
producedEdges
,
viewport
:
getViewport
(),
viewport
:
getViewport
(),
},
},
features
:
{
features
:
{
...
@@ -599,6 +604,26 @@ export const useWorkflow = () => {
...
@@ -599,6 +604,26 @@ export const useWorkflow = () => {
setEdges
(
newEdges
)
setEdges
(
newEdges
)
},
[
store
])
},
[
store
])
const
handleEdgeDeleteByDeleteBranch
=
useCallback
((
nodeId
:
string
,
branchId
:
string
)
=>
{
const
{
runningStatus
}
=
useStore
.
getState
()
if
(
runningStatus
)
return
const
{
edges
,
setEdges
,
}
=
store
.
getState
()
const
newEdges
=
produce
(
edges
,
(
draft
)
=>
{
const
index
=
draft
.
findIndex
(
edge
=>
edge
.
source
===
nodeId
&&
edge
.
sourceHandle
===
branchId
)
if
(
index
>
-
1
)
draft
.
splice
(
index
,
1
)
})
setEdges
(
newEdges
)
handleSyncWorkflowDraft
()
},
[
store
,
handleSyncWorkflowDraft
])
const
handleEdgeDelete
=
useCallback
(()
=>
{
const
handleEdgeDelete
=
useCallback
(()
=>
{
const
{
runningStatus
}
=
useStore
.
getState
()
const
{
runningStatus
}
=
useStore
.
getState
()
...
@@ -670,6 +695,7 @@ export const useWorkflow = () => {
...
@@ -670,6 +695,7 @@ export const useWorkflow = () => {
handleEdgeEnter
,
handleEdgeEnter
,
handleEdgeLeave
,
handleEdgeLeave
,
handleEdgeDeleteByDeleteBranch
,
handleEdgeDelete
,
handleEdgeDelete
,
handleEdgesChange
,
handleEdgesChange
,
...
...
web/app/components/workflow/nodes/question-classifier/components/class-list.tsx
View file @
8ae46a8a
...
@@ -3,6 +3,7 @@ import type { FC } from 'react'
...
@@ -3,6 +3,7 @@ import type { FC } from 'react'
import
React
,
{
useCallback
}
from
'react'
import
React
,
{
useCallback
}
from
'react'
import
produce
from
'immer'
import
produce
from
'immer'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
useWorkflow
}
from
'../../../hooks'
import
AddButton
from
'../../_base/components/add-button'
import
AddButton
from
'../../_base/components/add-button'
import
Item
from
'./class-item'
import
Item
from
'./class-item'
import
type
{
Topic
}
from
'@/app/components/workflow/nodes/question-classifier/types'
import
type
{
Topic
}
from
'@/app/components/workflow/nodes/question-classifier/types'
...
@@ -10,15 +11,18 @@ import type { Topic } from '@/app/components/workflow/nodes/question-classifier/
...
@@ -10,15 +11,18 @@ import type { Topic } from '@/app/components/workflow/nodes/question-classifier/
const
i18nPrefix
=
'workflow.nodes.questionClassifiers'
const
i18nPrefix
=
'workflow.nodes.questionClassifiers'
type
Props
=
{
type
Props
=
{
id
:
string
list
:
Topic
[]
list
:
Topic
[]
onChange
:
(
list
:
Topic
[])
=>
void
onChange
:
(
list
:
Topic
[])
=>
void
}
}
const
ClassList
:
FC
<
Props
>
=
({
const
ClassList
:
FC
<
Props
>
=
({
id
,
list
,
list
,
onChange
,
onChange
,
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
handleEdgeDeleteByDeleteBranch
}
=
useWorkflow
()
const
handleClassChange
=
useCallback
((
index
:
number
)
=>
{
const
handleClassChange
=
useCallback
((
index
:
number
)
=>
{
return
(
value
:
Topic
)
=>
{
return
(
value
:
Topic
)
=>
{
...
@@ -34,16 +38,17 @@ const ClassList: FC<Props> = ({
...
@@ -34,16 +38,17 @@ const ClassList: FC<Props> = ({
draft
.
push
({
id
:
`
${
Date
.
now
()}
`
,
name
:
''
})
draft
.
push
({
id
:
`
${
Date
.
now
()}
`
,
name
:
''
})
})
})
onChange
(
newList
)
onChange
(
newList
)
},
[
list
,
onChange
,
t
])
},
[
list
,
onChange
])
const
handleRemoveClass
=
useCallback
((
index
:
number
)
=>
{
const
handleRemoveClass
=
useCallback
((
index
:
number
)
=>
{
return
()
=>
{
return
()
=>
{
handleEdgeDeleteByDeleteBranch
(
id
,
list
[
index
].
id
)
const
newList
=
produce
(
list
,
(
draft
)
=>
{
const
newList
=
produce
(
list
,
(
draft
)
=>
{
draft
.
splice
(
index
,
1
)
draft
.
splice
(
index
,
1
)
})
})
onChange
(
newList
)
onChange
(
newList
)
}
}
},
[
list
,
onChange
])
},
[
list
,
onChange
,
handleEdgeDeleteByDeleteBranch
,
id
])
// Todo Remove; edit topic name
// Todo Remove; edit topic name
return
(
return
(
...
...
web/app/components/workflow/nodes/question-classifier/panel.tsx
View file @
8ae46a8a
...
@@ -72,6 +72,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
...
@@ -72,6 +72,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
title=
{
t
(
`${i18nPrefix}.class`
)
}
title=
{
t
(
`${i18nPrefix}.class`
)
}
>
>
<
ClassList
<
ClassList
id=
{
id
}
list=
{
inputs
.
classes
}
list=
{
inputs
.
classes
}
onChange=
{
handleTopicsChange
}
/>
onChange=
{
handleTopicsChange
}
/>
</
Field
>
</
Field
>
...
...
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