mirror of
https://github.com/langgenius/dify.git
synced 2026-04-20 22:28:09 +08:00
chore: handle bool value in vars
This commit is contained in:
parent
14c62850e0
commit
fbd0effa04
@ -21,6 +21,7 @@ import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
|||||||
import type { VarInInspect } from '@/types/workflow'
|
import type { VarInInspect } from '@/types/workflow'
|
||||||
import { VarInInspectType } from '@/types/workflow'
|
import { VarInInspectType } from '@/types/workflow'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
import BoolValue from '../panel/chat-variable-panel/components/bool-value'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
currentVar: VarInInspect
|
currentVar: VarInInspect
|
||||||
@ -35,6 +36,7 @@ const ValueContent = ({
|
|||||||
const errorMessageRef = useRef<HTMLDivElement>(null)
|
const errorMessageRef = useRef<HTMLDivElement>(null)
|
||||||
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 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]'
|
||||||
@ -72,7 +74,6 @@ const ValueContent = ({
|
|||||||
|
|
||||||
if (showFileEditor)
|
if (showFileEditor)
|
||||||
setFileValue(formatFileValue(currentVar))
|
setFileValue(formatFileValue(currentVar))
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [currentVar.id, currentVar.value])
|
}, [currentVar.id, currentVar.value])
|
||||||
|
|
||||||
const handleTextChange = (value: string) => {
|
const handleTextChange = (value: string) => {
|
||||||
@ -178,6 +179,17 @@ const ValueContent = ({
|
|||||||
onChange={e => handleTextChange(e.target.value)}
|
onChange={e => handleTextChange(e.target.value)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{showBoolEditor && (
|
||||||
|
<div className='w-[295px]'>
|
||||||
|
<BoolValue
|
||||||
|
value={value as boolean}
|
||||||
|
onChange={(newValue) => {
|
||||||
|
setValue(newValue)
|
||||||
|
debounceValueChange(currentVar.id, newValue)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{showJSONEditor && (
|
{showJSONEditor && (
|
||||||
<SchemaEditor
|
<SchemaEditor
|
||||||
readonly={JSONEditorDisabled}
|
readonly={JSONEditorDisabled}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user