mirror of https://github.com/langgenius/dify.git
feat: form data support file type
This commit is contained in:
parent
939df16655
commit
97b2a42cc3
|
|
@ -23,15 +23,17 @@ const allTypes = [
|
|||
BodyType.none,
|
||||
BodyType.formData,
|
||||
BodyType.xWwwFormUrlencoded,
|
||||
BodyType.rawText,
|
||||
BodyType.json,
|
||||
BodyType.rawText,
|
||||
BodyType.binary,
|
||||
]
|
||||
const bodyTextMap = {
|
||||
[BodyType.none]: 'none',
|
||||
[BodyType.formData]: 'form-data',
|
||||
[BodyType.xWwwFormUrlencoded]: 'x-www-form-urlencoded',
|
||||
[BodyType.rawText]: 'raw text',
|
||||
[BodyType.rawText]: 'raw',
|
||||
[BodyType.json]: 'JSON',
|
||||
[BodyType.binary]: 'binary',
|
||||
}
|
||||
|
||||
const EditBody: FC<Props> = ({
|
||||
|
|
@ -125,6 +127,7 @@ const EditBody: FC<Props> = ({
|
|||
list={body}
|
||||
onChange={setBody}
|
||||
onAdd={addBody}
|
||||
isSupportFile={type === BodyType.formData}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ type Props = {
|
|||
list: KeyValue[]
|
||||
onChange: (newList: KeyValue[]) => void
|
||||
onAdd: () => void
|
||||
isSupportFile: boolean
|
||||
// toggleKeyValueEdit: () => void
|
||||
}
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ const KeyValueList: FC<Props> = ({
|
|||
list,
|
||||
onChange,
|
||||
onAdd,
|
||||
isSupportFile,
|
||||
// toggleKeyValueEdit,
|
||||
}) => {
|
||||
// const handleBulkValueChange = useCallback((value: string) => {
|
||||
|
|
@ -48,6 +50,7 @@ const KeyValueList: FC<Props> = ({
|
|||
list={list}
|
||||
onChange={onChange}
|
||||
onAdd={onAdd}
|
||||
isSupportFile={isSupportFile}
|
||||
// onSwitchToBulkEdit={toggleKeyValueEdit}
|
||||
/>
|
||||
// : <BulkEdit
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ type Props = {
|
|||
list: KeyValue[]
|
||||
onChange: (newList: KeyValue[]) => void
|
||||
onAdd: () => void
|
||||
isSupportFile?: boolean
|
||||
// onSwitchToBulkEdit: () => void
|
||||
}
|
||||
|
||||
|
|
@ -25,6 +26,7 @@ const KeyValueList: FC<Props> = ({
|
|||
list,
|
||||
onChange,
|
||||
onAdd,
|
||||
isSupportFile,
|
||||
// onSwitchToBulkEdit,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
|
@ -79,6 +81,7 @@ const KeyValueList: FC<Props> = ({
|
|||
onAdd={onAdd}
|
||||
readonly={readonly}
|
||||
canRemove={list.length > 1}
|
||||
isSupportFile={isSupportFile}
|
||||
/>
|
||||
))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ type Props = {
|
|||
onRemove?: () => void
|
||||
placeholder?: string
|
||||
readOnly?: boolean
|
||||
isSupportFile?: boolean
|
||||
}
|
||||
|
||||
const InputItem: FC<Props> = ({
|
||||
|
|
@ -30,6 +31,7 @@ const InputItem: FC<Props> = ({
|
|||
onRemove,
|
||||
placeholder,
|
||||
readOnly,
|
||||
isSupportFile,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
|
|
@ -39,7 +41,11 @@ const InputItem: FC<Props> = ({
|
|||
const { availableVars, availableNodesWithParent } = useAvailableVarList(nodeId, {
|
||||
onlyLeafNodeVar: false,
|
||||
filterVar: (varPayload: Var) => {
|
||||
return [VarType.string, VarType.number, VarType.secret].includes(varPayload.type)
|
||||
const supportVarTypes = [VarType.string, VarType.number, VarType.secret]
|
||||
if (isSupportFile)
|
||||
supportVarTypes.push(...[VarType.file, VarType.arrayFile])
|
||||
|
||||
return supportVarTypes.includes(varPayload.type)
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ type Props = {
|
|||
onRemove: () => void
|
||||
isLastItem: boolean
|
||||
onAdd: () => void
|
||||
isSupportFile?: boolean
|
||||
}
|
||||
|
||||
const KeyValueItem: FC<Props> = ({
|
||||
|
|
@ -33,6 +34,7 @@ const KeyValueItem: FC<Props> = ({
|
|||
onRemove,
|
||||
isLastItem,
|
||||
onAdd,
|
||||
isSupportFile,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
|
|
@ -71,6 +73,7 @@ const KeyValueItem: FC<Props> = ({
|
|||
onRemove={onRemove}
|
||||
placeholder={t(`${i18nPrefix}.value`)!}
|
||||
readOnly={readonly}
|
||||
isSupportFile={isSupportFile}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export enum BodyType {
|
|||
xWwwFormUrlencoded = 'x-www-form-urlencoded',
|
||||
rawText = 'raw-text',
|
||||
json = 'json',
|
||||
binary = 'binary',
|
||||
}
|
||||
|
||||
export type KeyValue = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue