mirror of
https://github.com/langgenius/dify.git
synced 2026-04-25 09:36:40 +08:00
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[]) => {
|
const checkInputsForm = useCallback((inputs: Record<string, any>, inputsForm: InputForm[]) => {
|
||||||
let hasEmptyInput = ''
|
let hasEmptyInput = ''
|
||||||
let fileIsUploading = false
|
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) {
|
if (requiredVars?.length) {
|
||||||
requiredVars.forEach(({ variable, label, type }) => {
|
requiredVars.forEach(({ variable, label, type }) => {
|
||||||
|
|||||||
@ -31,6 +31,12 @@ export const getProcessedInputs = (inputs: Record<string, any>, inputsForm: Inpu
|
|||||||
|
|
||||||
inputsForm.forEach((item) => {
|
inputsForm.forEach((item) => {
|
||||||
const inputValue = inputs[item.variable]
|
const inputValue = inputs[item.variable]
|
||||||
|
// set boolean type default value
|
||||||
|
if(item.type === InputVarType.boolean) {
|
||||||
|
processedInputs[item.variable] = !!inputValue
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!inputValue)
|
if (!inputValue)
|
||||||
return
|
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 { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import type { FileEntity } from '@/app/components/base/file-uploader/types'
|
import type { FileEntity } from '@/app/components/base/file-uploader/types'
|
||||||
|
import BoolInput from './bool-input'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
payload: InputVar
|
payload: InputVar
|
||||||
@ -92,6 +93,7 @@ const FormItem: FC<Props> = ({
|
|||||||
return ''
|
return ''
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
const isBooleanType = type === InputVarType.boolean
|
||||||
const isArrayLikeType = [InputVarType.contexts, InputVarType.iterator].includes(type)
|
const isArrayLikeType = [InputVarType.contexts, InputVarType.iterator].includes(type)
|
||||||
const isContext = type === InputVarType.contexts
|
const isContext = type === InputVarType.contexts
|
||||||
const isIterator = type === InputVarType.iterator
|
const isIterator = type === InputVarType.iterator
|
||||||
@ -113,7 +115,7 @@ const FormItem: FC<Props> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn(className)}>
|
<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='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>
|
<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>}
|
{!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 && (
|
type === InputVarType.json && (
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user