mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
Show typed human input outputs in panel
This commit is contained in:
parent
acd1641d16
commit
93945d603e
@ -383,4 +383,33 @@ describe('human-input/panel', () => {
|
||||
expect(screen.getByRole('button', { name: 'timeout:readonly' })).toBeInTheDocument()
|
||||
expect(screen.queryByText('form-preview')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders file outputs with file-aware types', () => {
|
||||
mockUseConfig.mockReturnValue(createConfigResult({
|
||||
inputs: createData({
|
||||
inputs: [
|
||||
{
|
||||
type: InputVarType.singleFile,
|
||||
output_variable_name: 'attachment',
|
||||
allowed_file_extensions: [],
|
||||
allowed_file_types: [],
|
||||
allowed_file_upload_methods: [],
|
||||
},
|
||||
{
|
||||
type: InputVarType.multiFiles,
|
||||
output_variable_name: 'attachments',
|
||||
allowed_file_extensions: [],
|
||||
allowed_file_types: [],
|
||||
allowed_file_upload_methods: [],
|
||||
max_upload_count: 3,
|
||||
},
|
||||
],
|
||||
}),
|
||||
}))
|
||||
|
||||
renderPanel()
|
||||
|
||||
expect(screen.getByText('attachment:file:Form input value')).toBeInTheDocument()
|
||||
expect(screen.getByText('attachments:array[file]:Form input value')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { FC } from 'react'
|
||||
import type { HumanInputNodeType } from './types'
|
||||
import type { FormInputItem, HumanInputNodeType } from './types'
|
||||
import type { NodePanelProps, Var } from '@/app/components/workflow/types'
|
||||
import { Button } from '@langgenius/dify-ui/button'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
@ -34,6 +34,16 @@ import { UserActionButtonType } from './types'
|
||||
|
||||
const i18nPrefix = 'nodes.humanInput'
|
||||
|
||||
const getOutputVarType = (input: FormInputItem): VarType => {
|
||||
if (input.type === 'file')
|
||||
return VarType.file
|
||||
|
||||
if (input.type === 'file-list')
|
||||
return VarType.arrayFile
|
||||
|
||||
return VarType.string
|
||||
}
|
||||
|
||||
const Panel: FC<NodePanelProps<HumanInputNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
@ -219,7 +229,7 @@ const Panel: FC<NodePanelProps<HumanInputNodeType>> = ({
|
||||
<VarItem
|
||||
key={input.output_variable_name}
|
||||
name={input.output_variable_name}
|
||||
type={VarType.string}
|
||||
type={getOutputVarType(input)}
|
||||
description="Form input value"
|
||||
/>
|
||||
))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user