mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-02 05:20:37 +08:00
fix: run button disappeared when where is no inputs in form (#17854)
This commit is contained in:
parent
7ee5cc80a2
commit
bf26f1129e
@ -1,4 +1,4 @@
|
|||||||
import type { FC, FormEvent } from 'react'
|
import type { ChangeEvent, FC, FormEvent } from 'react'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import React, { useCallback } from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
@ -66,17 +66,15 @@ const RunOnce: FC<IRunOnceProps> = ({
|
|||||||
newInputs[item.key] = ''
|
newInputs[item.key] = ''
|
||||||
})
|
})
|
||||||
onInputsChange(newInputs)
|
onInputsChange(newInputs)
|
||||||
}, [promptConfig.prompt_variables])
|
}, [promptConfig.prompt_variables, onInputsChange])
|
||||||
|
|
||||||
if (inputs === null || inputs === undefined || Object.keys(inputs).length === 0)
|
|
||||||
return null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
<section>
|
<section>
|
||||||
{/* input form */}
|
{/* input form */}
|
||||||
<form onSubmit={onSubmit}>
|
<form onSubmit={onSubmit}>
|
||||||
{promptConfig.prompt_variables.map(item => (
|
{(inputs === null || inputs === undefined || Object.keys(inputs).length === 0) ? null
|
||||||
|
: promptConfig.prompt_variables.map(item => (
|
||||||
<div className='mt-4 w-full' key={item.key}>
|
<div className='mt-4 w-full' key={item.key}>
|
||||||
<label className='system-md-semibold flex h-6 items-center text-text-secondary'>{item.name}</label>
|
<label className='system-md-semibold flex h-6 items-center text-text-secondary'>{item.name}</label>
|
||||||
<div className='mt-1'>
|
<div className='mt-1'>
|
||||||
@ -94,7 +92,7 @@ const RunOnce: FC<IRunOnceProps> = ({
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
||||||
value={inputs[item.key]}
|
value={inputs[item.key]}
|
||||||
onChange={(e) => { handleInputsChange({ ...inputsRef.current, [item.key]: e.target.value }) }}
|
onChange={(e: ChangeEvent<HTMLInputElement>) => { handleInputsChange({ ...inputsRef.current, [item.key]: e.target.value }) }}
|
||||||
maxLength={item.max_length || DEFAULT_VALUE_MAX_LEN}
|
maxLength={item.max_length || DEFAULT_VALUE_MAX_LEN}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -103,7 +101,7 @@ const RunOnce: FC<IRunOnceProps> = ({
|
|||||||
className='h-[104px] sm:text-xs'
|
className='h-[104px] sm:text-xs'
|
||||||
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
||||||
value={inputs[item.key]}
|
value={inputs[item.key]}
|
||||||
onChange={(e) => { handleInputsChange({ ...inputsRef.current, [item.key]: e.target.value }) }}
|
onChange={(e: ChangeEvent<HTMLInputElement>) => { handleInputsChange({ ...inputsRef.current, [item.key]: e.target.value }) }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{item.type === 'number' && (
|
{item.type === 'number' && (
|
||||||
@ -111,7 +109,7 @@ const RunOnce: FC<IRunOnceProps> = ({
|
|||||||
type="number"
|
type="number"
|
||||||
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
||||||
value={inputs[item.key]}
|
value={inputs[item.key]}
|
||||||
onChange={(e) => { handleInputsChange({ ...inputsRef.current, [item.key]: e.target.value }) }}
|
onChange={(e: ChangeEvent<HTMLInputElement>) => { handleInputsChange({ ...inputsRef.current, [item.key]: e.target.value }) }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{item.type === 'file' && (
|
{item.type === 'file' && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user