mirror of https://github.com/langgenius/dify.git
feat: workflow debug add bool
This commit is contained in:
parent
fcf0ae4c85
commit
fc0dea5647
|
|
@ -12,7 +12,7 @@ export const useCheckInputsForms = () => {
|
|||
const checkInputsForm = useCallback((inputs: Record<string, any>, inputsForm: InputForm[]) => {
|
||||
let hasEmptyInput = ''
|
||||
let fileIsUploading = false
|
||||
const requiredVars = inputsForm.filter(({ required }) => required)
|
||||
const requiredVars = inputsForm.filter(({ required, type }) => required && type !== InputVarType.boolean) // boolean can be not checked
|
||||
|
||||
if (requiredVars?.length) {
|
||||
requiredVars.forEach(({ variable, label, type }) => {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,12 @@ export const getProcessedInputs = (inputs: Record<string, any>, inputsForm: Inpu
|
|||
|
||||
inputsForm.forEach((item) => {
|
||||
const inputValue = inputs[item.variable]
|
||||
// set boolean type default value
|
||||
if(item.type === InputVarType.boolean) {
|
||||
processedInputs[item.variable] = !!inputValue
|
||||
return
|
||||
}
|
||||
|
||||
if (!inputValue)
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
'use client'
|
||||
import Checkbox from '@/app/components/base/checkbox'
|
||||
import type { FC } from 'react'
|
||||
import React, { useCallback } from 'react'
|
||||
|
||||
type Props = {
|
||||
name: string
|
||||
value: boolean
|
||||
onChange: (value: boolean) => void
|
||||
}
|
||||
|
||||
const BoolInput: FC<Props> = ({
|
||||
value,
|
||||
onChange,
|
||||
name,
|
||||
}) => {
|
||||
const handleChange = useCallback(() => {
|
||||
onChange(!value)
|
||||
}, [value, onChange])
|
||||
return (
|
||||
<div className='flex h-6 items-center gap-2'>
|
||||
<Checkbox
|
||||
className='!h-4 !w-4'
|
||||
checked={!!value}
|
||||
onCheck={handleChange}
|
||||
/>
|
||||
<div className='system-sm-medium text-text-secondary'>{name}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default React.memo(BoolInput)
|
||||
|
|
@ -25,6 +25,7 @@ import { BubbleX } from '@/app/components/base/icons/src/vender/line/others'
|
|||
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
||||
import cn from '@/utils/classnames'
|
||||
import type { FileEntity } from '@/app/components/base/file-uploader/types'
|
||||
import BoolInput from './bool-input'
|
||||
|
||||
type Props = {
|
||||
payload: InputVar
|
||||
|
|
@ -92,6 +93,7 @@ const FormItem: FC<Props> = ({
|
|||
return ''
|
||||
})()
|
||||
|
||||
const isBooleanType = type === InputVarType.boolean
|
||||
const isArrayLikeType = [InputVarType.contexts, InputVarType.iterator].includes(type)
|
||||
const isContext = type === InputVarType.contexts
|
||||
const isIterator = type === InputVarType.iterator
|
||||
|
|
@ -113,7 +115,7 @@ const FormItem: FC<Props> = ({
|
|||
|
||||
return (
|
||||
<div className={cn(className)}>
|
||||
{!isArrayLikeType && (
|
||||
{!isArrayLikeType && !isBooleanType && (
|
||||
<div className='system-sm-semibold mb-1 flex h-6 items-center gap-1 text-text-secondary'>
|
||||
<div className='truncate'>{typeof payload.label === 'object' ? nodeKey : payload.label}</div>
|
||||
{!payload.required && <span className='system-xs-regular text-text-tertiary'>{t('workflow.panel.optional')}</span>}
|
||||
|
|
@ -166,6 +168,14 @@ const FormItem: FC<Props> = ({
|
|||
)
|
||||
}
|
||||
|
||||
{ isBooleanType && (
|
||||
<BoolInput
|
||||
name={payload.label as string}
|
||||
value={!!value}
|
||||
onChange={onChange}
|
||||
/>
|
||||
)}
|
||||
|
||||
{
|
||||
type === InputVarType.json && (
|
||||
<CodeEditor
|
||||
|
|
|
|||
Loading…
Reference in New Issue