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
649c3d07
Commit
649c3d07
authored
Feb 27, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: key value struct
parent
35c56237
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
0 deletions
+108
-0
key-value-item.tsx
...ponents/workflow/nodes/http/components/key-value-item.tsx
+61
-0
key-value-list.tsx
...ponents/workflow/nodes/http/components/key-value-list.tsx
+47
-0
No files found.
web/app/components/workflow/nodes/http/components/key-value-item.tsx
0 → 100644
View file @
649c3d07
'use client'
import
type
{
FC
}
from
'react'
import
React
,
{
useCallback
}
from
'react'
import
{
useBoolean
}
from
'ahooks'
import
type
{
KeyValue
}
from
'../types'
import
{
Trash03
}
from
'@/app/components/base/icons/src/vender/line/general'
type
Props
=
{
payload
:
KeyValue
onChange
:
(
newPayload
:
KeyValue
)
=>
void
onRemove
:
()
=>
void
isLastItem
:
boolean
onAdd
:
()
=>
void
}
const
KeyValueItem
:
FC
<
Props
>
=
({
payload
,
onChange
,
onRemove
,
isLastItem
,
onAdd
,
})
=>
{
const
[
isKeyEditing
,
{
setTrue
:
setIsKeyEditing
,
setFalse
:
setIsKeyEditingFalse
,
}]
=
useBoolean
(
false
)
const
handleKeyChange
=
useCallback
((
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
onChange
({
key
:
e
.
target
.
value
,
value
:
payload
.
value
,
})
},
[])
return
(
<
div
>
<
div
>
{
isKeyEditing
?
(
<
input
type=
'text'
value=
{
payload
.
key
}
onChange=
{
handleKeyChange
}
onBlur=
{
setIsKeyEditingFalse
}
/>
)
:
<
div
onClick=
{
setIsKeyEditing
}
>
{
payload
.
key
}
</
div
>
}
</
div
>
<
div
>
{
payload
.
value
}
<
div
className=
'p-1 cursor-pointer rounded-md hover:bg-black/5'
onClick=
{
onRemove
}
>
<
Trash03
className=
'w-4 h-4'
/>
</
div
>
</
div
>
</
div
>
)
}
export
default
React
.
memo
(
KeyValueItem
)
web/app/components/workflow/nodes/http/components/key-value-list.tsx
0 → 100644
View file @
649c3d07
'use client'
import
type
{
FC
}
from
'react'
import
React
from
'react'
import
type
{
KeyValue
}
from
'../types'
import
KeyValueItem
from
'./key-value-item'
type
Props
=
{
list
:
KeyValue
[]
onChange
:
(
newList
:
KeyValue
[])
=>
void
onAdd
:
()
=>
void
}
const
KeyValueList
:
FC
<
Props
>
=
({
list
,
onChange
,
onAdd
,
})
=>
{
return
(
<
div
>
<
div
>
<
div
>
key
</
div
>
<
div
>
value
</
div
>
</
div
>
{
list
.
map
((
item
,
index
)
=>
(
<
KeyValueItem
key=
{
index
}
payload=
{
item
}
onChange=
{
(
newItem
)
=>
{
const
newList
=
[...
list
]
newList
[
index
]
=
newItem
onChange
(
newList
)
}
}
onRemove=
{
()
=>
{
const
newList
=
[...
list
]
newList
.
splice
(
index
,
1
)
onChange
(
newList
)
}
}
isLastItem=
{
index
===
list
.
length
-
1
}
onAdd=
{
onAdd
}
/>
))
}
</
div
>
)
}
export
default
React
.
memo
(
KeyValueList
)
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