mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
feat: support var arrs
This commit is contained in:
@ -37,6 +37,7 @@ const ValueContent = ({
|
|||||||
const [editorHeight, setEditorHeight] = useState(0)
|
const [editorHeight, setEditorHeight] = useState(0)
|
||||||
const showTextEditor = currentVar.value_type === 'secret' || currentVar.value_type === 'string' || currentVar.value_type === 'number'
|
const showTextEditor = currentVar.value_type === 'secret' || currentVar.value_type === 'string' || currentVar.value_type === 'number'
|
||||||
const showBoolEditor = typeof currentVar.value === 'boolean'
|
const showBoolEditor = typeof currentVar.value === 'boolean'
|
||||||
|
const showBoolArrayEditor = Array.isArray(currentVar.value) && currentVar.value.every(v => typeof v === 'boolean')
|
||||||
const isSysFiles = currentVar.type === VarInInspectType.system && currentVar.name === 'files'
|
const isSysFiles = currentVar.type === VarInInspectType.system && currentVar.name === 'files'
|
||||||
const showJSONEditor = !isSysFiles && (currentVar.value_type === 'object' || currentVar.value_type === 'array[string]' || currentVar.value_type === 'array[number]' || currentVar.value_type === 'array[object]' || currentVar.value_type === 'array[any]')
|
const showJSONEditor = !isSysFiles && (currentVar.value_type === 'object' || currentVar.value_type === 'array[string]' || currentVar.value_type === 'array[number]' || currentVar.value_type === 'array[object]' || currentVar.value_type === 'array[any]')
|
||||||
const showFileEditor = isSysFiles || currentVar.value_type === 'file' || currentVar.value_type === 'array[file]'
|
const showFileEditor = isSysFiles || currentVar.value_type === 'file' || currentVar.value_type === 'array[file]'
|
||||||
@ -182,7 +183,7 @@ const ValueContent = ({
|
|||||||
{showBoolEditor && (
|
{showBoolEditor && (
|
||||||
<div className='w-[295px]'>
|
<div className='w-[295px]'>
|
||||||
<BoolValue
|
<BoolValue
|
||||||
value={value as boolean}
|
value={currentVar.value as boolean}
|
||||||
onChange={(newValue) => {
|
onChange={(newValue) => {
|
||||||
setValue(newValue)
|
setValue(newValue)
|
||||||
debounceValueChange(currentVar.id, newValue)
|
debounceValueChange(currentVar.id, newValue)
|
||||||
@ -190,6 +191,24 @@ const ValueContent = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{
|
||||||
|
showBoolArrayEditor && (
|
||||||
|
<div className='w-[295px] space-y-1'>
|
||||||
|
{currentVar.value.map((v: boolean, i: number) => (
|
||||||
|
<BoolValue
|
||||||
|
key={i}
|
||||||
|
value={v}
|
||||||
|
onChange={(newValue) => {
|
||||||
|
const newArray = [...(currentVar.value as boolean[])]
|
||||||
|
newArray[i] = newValue
|
||||||
|
setValue(newArray)
|
||||||
|
debounceValueChange(currentVar.id, newArray)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
{showJSONEditor && (
|
{showJSONEditor && (
|
||||||
<SchemaEditor
|
<SchemaEditor
|
||||||
readonly={JSONEditorDisabled}
|
readonly={JSONEditorDisabled}
|
||||||
|
|||||||
Reference in New Issue
Block a user