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
7a035882
Commit
7a035882
authored
Feb 20, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: finish choose var
parent
62e2deaf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
4 deletions
+43
-4
var-reference-picker.tsx
.../nodes/_base/components/variable/var-reference-picker.tsx
+8
-1
var-reference-popup.tsx
...w/nodes/_base/components/variable/var-reference-popup.tsx
+32
-3
mock.ts
web/app/components/workflow/nodes/mock.ts
+2
-0
types.ts
web/app/components/workflow/types.ts
+1
-0
No files found.
web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx
View file @
7a035882
...
...
@@ -39,6 +39,7 @@ const VarReferencePicker: FC<Props> = ({
className
,
isShowNodeName
,
value
,
onChange
,
})
=>
{
const
[
open
,
setOpen
]
=
useState
(
false
)
const
hasValue
=
value
.
length
>
0
...
...
@@ -87,7 +88,13 @@ const VarReferencePicker: FC<Props> = ({
zIndex
:
100
,
minWidth
:
227
,
}
}
>
<
VarReferencePopup
vars=
{
mockNodeOutputVars
}
/>
<
VarReferencePopup
vars=
{
mockNodeOutputVars
}
onChange=
{
(
value
)
=>
{
onChange
(
value
)
setOpen
(
false
)
}
}
/>
</
PortalToFollowElemContent
>
</
PortalToFollowElem
>
</
div
>
...
...
web/app/components/workflow/nodes/_base/components/variable/var-reference-popup.tsx
View file @
7a035882
...
...
@@ -2,43 +2,63 @@
import
type
{
FC
}
from
'react'
import
React
,
{
useRef
}
from
'react'
import
{
useHover
}
from
'ahooks'
import
type
{
NodeOutPutVar
,
Var
}
from
'@/app/components/workflow/types'
import
cn
from
'classnames'
import
type
{
NodeOutPutVar
,
ValueSelector
,
Var
}
from
'@/app/components/workflow/types'
import
{
Variable02
}
from
'@/app/components/base/icons/src/vender/solid/development'
import
{
ChevronRight
}
from
'@/app/components/base/icons/src/vender/line/arrows'
type
ObjectChildrenProps
=
{
nodeId
:
string
title
:
string
data
:
Var
[]
objPath
:
string
[]
onChange
:
(
value
:
ValueSelector
)
=>
void
}
type
ItemProps
=
{
nodeId
:
string
title
:
string
objPath
:
string
[]
itemData
:
Var
onChange
:
(
value
:
ValueSelector
)
=>
void
}
const
Item
:
FC
<
ItemProps
>
=
({
nodeId
,
title
,
objPath
,
itemData
,
onChange
,
})
=>
{
const
isObj
=
itemData
.
type
===
'object'
const
itemRef
=
useRef
(
null
)
const
isItemHovering
=
useHover
(
itemRef
)
const
handleChosen
=
(
e
:
React
.
MouseEvent
)
=>
{
e
.
stopPropagation
()
onChange
([
nodeId
,
...
objPath
,
itemData
.
variable
])
}
return
(
<
div
ref=
{
itemRef
}
className=
'relative flex items-center h-6 w-[252px] pl-3 pr-[18px] rounded-md cursor-pointer hover:bg-gray-50'
>
<
div
ref=
{
itemRef
}
className=
{
cn
(
isObj
?
'hover:bg-primary-50 pr-1'
:
'hover:bg-gray-50 pr-[18px]'
,
'relative flex items-center h-6 w-[252px] pl-3 rounded-md cursor-pointer'
)
}
onClick=
{
handleChosen
}
>
<
div
className=
'flex items-center w-0 grow'
>
<
Variable02
className=
'shrink-0 w-3.5 h-3.5 text-primary-500'
/>
<
div
className=
'ml-1 w-0 grow text-ellipsis text-[13px] font-normal text-gray-900'
>
{
itemData
.
variable
}
</
div
>
</
div
>
<
div
className=
'ml-1 shrink-0 text-xs font-normal text-gray-500'
>
{
itemData
.
type
}
</
div
>
{
isObj
&&
(
<
ChevronRight
className=
'ml-0.5 w-3 h-3 text-gray-500'
/>
)
}
{
isObj
&&
isItemHovering
&&
(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
<
ObjectChildren
nodeId=
{
nodeId
}
title=
{
title
}
objPath=
{
[...
objPath
,
itemData
.
variable
]
}
data=
{
itemData
.
children
as
Var
[]
}
onChange=
{
onChange
}
/>
)
}
</
div
>
...
...
@@ -47,8 +67,10 @@ const Item: FC<ItemProps> = ({
const
ObjectChildren
:
FC
<
ObjectChildrenProps
>
=
({
title
,
nodeId
,
objPath
,
data
,
onChange
,
})
=>
{
const
currObjPath
=
objPath
...
...
@@ -59,9 +81,11 @@ const ObjectChildren: FC<ObjectChildrenProps> = ({
data
.
map
((
v
,
i
)
=>
(
<
Item
key=
{
i
}
nodeId=
{
nodeId
}
title=
{
title
}
objPath=
{
objPath
}
itemData=
{
v
}
onChange=
{
onChange
}
/>
))
}
...
...
@@ -71,9 +95,12 @@ const ObjectChildren: FC<ObjectChildrenProps> = ({
type
Props
=
{
vars
:
NodeOutPutVar
[]
onChange
:
(
value
:
ValueSelector
)
=>
void
}
const
VarReferencePopup
:
FC
<
Props
>
=
({
vars
,
onChange
,
})
=>
{
return
(
<
div
className=
'p-1 bg-white rounded-lg border border-gray-200 shadow-lg space-y-1'
>
...
...
@@ -84,8 +111,10 @@ const VarReferencePopup: FC<Props> = ({
<
Item
key=
{
j
}
title=
{
item
.
title
}
nodeId=
{
item
.
nodeId
}
objPath=
{
[]
}
itemData=
{
v
}
onChange=
{
onChange
}
/>
))
}
</
div
>
...
...
web/app/components/workflow/nodes/mock.ts
View file @
7a035882
...
...
@@ -18,6 +18,7 @@ export const mockNodesData: Record<string, any> = {
export
const
mockNodeOutputVars
:
NodeOutPutVar
[]
=
[
{
nodeId
:
'aaa'
,
title
:
'Start'
,
vars
:
[
{
...
...
@@ -31,6 +32,7 @@ export const mockNodeOutputVars: NodeOutPutVar[] = [
],
},
{
nodeId
:
'bbb'
,
title
:
'LLM'
,
vars
:
[
{
...
...
web/app/components/workflow/types.ts
View file @
7a035882
...
...
@@ -90,6 +90,7 @@ export type Var = {
}
export
type
NodeOutPutVar
=
{
nodeId
:
string
title
:
string
vars
:
Var
[]
}
...
...
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