mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-07-31 00:43: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 React, { useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@ -66,17 +66,15 @@ const RunOnce: FC<IRunOnceProps> = ({
|
||||
newInputs[item.key] = ''
|
||||
})
|
||||
onInputsChange(newInputs)
|
||||
}, [promptConfig.prompt_variables])
|
||||
|
||||
if (inputs === null || inputs === undefined || Object.keys(inputs).length === 0)
|
||||
return null
|
||||
}, [promptConfig.prompt_variables, onInputsChange])
|
||||
|
||||
return (
|
||||
<div className="">
|
||||
<section>
|
||||
{/* input form */}
|
||||
<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}>
|
||||
<label className='system-md-semibold flex h-6 items-center text-text-secondary'>{item.name}</label>
|
||||
<div className='mt-1'>
|
||||
@ -94,7 +92,7 @@ const RunOnce: FC<IRunOnceProps> = ({
|
||||
type="text"
|
||||
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
||||
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}
|
||||
/>
|
||||
)}
|
||||
@ -103,7 +101,7 @@ const RunOnce: FC<IRunOnceProps> = ({
|
||||
className='h-[104px] sm:text-xs'
|
||||
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
||||
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' && (
|
||||
@ -111,7 +109,7 @@ const RunOnce: FC<IRunOnceProps> = ({
|
||||
type="number"
|
||||
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
|
||||
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' && (
|
||||
|
Loading…
x
Reference in New Issue
Block a user