Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: http node key value type dropdown (#35304)

非法操作0fea760143eb
diff --git a/web/app/components/workflow/nodes/http/__tests__/integration.spec.tsx b/web/app/components/workflow/nodes/http/__tests__/integration.spec.tsx
index 99d240c6d6f..93a4d08c3d5 100644
--- a/web/app/components/workflow/nodes/http/__tests__/integration.spec.tsx
+++ b/web/app/components/workflow/nodes/http/__tests__/integration.spec.tsx
@@ -495,8 +495,8 @@ describe('http path', () => {
)
fireEvent.change(screen.getAllByDisplayValue('alice')[0], { target: { value: 'bob' } })
- await user.click(screen.getByText('text'))
- await user.click(screen.getByText('file'))
+ await user.click(screen.getAllByRole('combobox', { name: 'workflow.nodes.http.type' })[0]!)
+ await user.click(screen.getByRole('option', { name: /file/i }))
expect(onChange).toHaveBeenCalled()
})
@@ -558,6 +558,35 @@ describe('http path', () => {
expect(onRemove).toHaveBeenCalled()
})
+ it('should show the full file-type menu and update the row type selection', async () => {
+ const user = userEvent.setup()
+ const onChange = vi.fn()
+ render(
+ <KeyValueItem
+ instanceId="kv-type"
+ nodeId="node-1"
+ readonly={false}
+ canRemove
+ payload={{ id: 'kv-type', key: 'attachment', value: '', type: 'text' } as any}
+ onChange={onChange}
+ onRemove={vi.fn()}
+ isLastItem={false}
+ onAdd={vi.fn()}
+ isSupportFile
+ />,
+ )
+
+ await user.click(screen.getByRole('combobox', { name: 'workflow.nodes.http.type' }))
+
+ const fileOption = screen.getByRole('option', { name: /file/i })
+ expect(screen.getByRole('option', { name: /text/i })).toBeInTheDocument()
+ expect(fileOption.closest('.h-7')).toBeNull()
+
+ await user.click(fileOption)
+
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ type: 'file' }))
+ })
+
it('should update the raw-text body payload', () => {
const onChange = vi.fn()
render(
diff --git a/web/app/components/workflow/nodes/http/components/key-value/key-value-edit/item.tsx b/web/app/components/workflow/nodes/http/components/key-value/key-value-edit/item.tsx
index f2fc2e9e1c3..36e0fccbffc 100644
--- a/web/app/components/workflow/nodes/http/components/key-value/key-value-edit/item.tsx
+++ b/web/app/components/workflow/nodes/http/components/key-value/key-value-edit/item.tsx
@@ -7,7 +7,15 @@ import { produce } from 'immer'
import * as React from 'react'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
-import { PortalSelect } from '@/app/components/base/select'
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectItemIndicator,
+ SelectItemText,
+ SelectTrigger,
+ SelectValue,
+} from '@/app/components/base/ui/select'
import { VarType } from '@/app/components/workflow/types'
import VarReferencePicker from '../../../../_base/components/variable/var-reference-picker'
import InputItem from './input-item'
@@ -80,7 +88,7 @@ const KeyValueItem: FC<Props> = ({
return (
// group class name is for hover row show remove button
- <div className={cn(className, 'h-min-7 group flex border-t border-divider-regular')}>
+ <div className={cn(className, 'group flex min-h-7 border-t border-divider-regular')}>
<div className={cn('shrink-0 border-r border-divider-regular', isSupportFile ? 'w-[140px]' : 'w-1/2')}>
{!keyNotSupportVar
? (
@@ -105,18 +113,28 @@ const KeyValueItem: FC<Props> = ({
</div>
{isSupportFile && (
<div className="w-[70px] shrink-0 border-r border-divider-regular">
- <PortalSelect
- value={payload.type!}
- onSelect={item => handleChange('type')(item.value as string)}
- items={[
- { name: 'text', value: 'text' },
- { name: 'file', value: 'file' },
- ]}
- readonly={readonly}
- triggerClassName="rounded-none h-7 text-text-primary"
- triggerClassNameFn={isOpen => isOpen ? 'bg-state-base-hover' : 'bg-transparent'}
- popupClassName="w-[80px] h-7"
- />
+ <Select
+ value={payload.type ?? 'text'}
+ onValueChange={value => value && handleChange('type')(value)}
+ readOnly={readonly}
+ >
+ <SelectTrigger
+ aria-label={t(`${i18nPrefix}.type`, { ns: 'workflow' })}
+ className="h-7 rounded-none bg-transparent text-text-primary hover:bg-state-base-hover focus-visible:bg-state-base-hover data-popup-open:bg-state-base-hover"
+ >
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent popupClassName="w-[80px]" listClassName="min-w-0">
+ <SelectItem value="text">
+ <SelectItemText>text</SelectItemText>
+ <SelectItemIndicator />
+ </SelectItem>
+ <SelectItem value="file">
+ <SelectItemText>file</SelectItemText>
+ <SelectItemIndicator />
+ </SelectItem>
+ </SelectContent>
+ </Select>
</div>
)}
<div
diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json
index db20c37db54..a53c1b4de91 100644
--- a/web/eslint-suppressions.json
+++ b/web/eslint-suppressions.json
@@ -6209,9 +6209,6 @@
}
},
"app/components/workflow/nodes/http/components/key-value/key-value-edit/item.tsx": {
- "no-restricted-imports": {
- "count": 1
- },
"ts/no-explicit-any": {
"count": 1
}