mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 17:15:54 +08:00
fix: file not uploaded caused api error (#3228)
This commit is contained in:
parent
8fcf459285
commit
752f6fb15a
@ -12,6 +12,7 @@ import Split from '@/app/components/workflow/nodes/_base/components/split'
|
|||||||
import { InputVarType, NodeRunningStatus } from '@/app/components/workflow/types'
|
import { InputVarType, NodeRunningStatus } from '@/app/components/workflow/types'
|
||||||
import ResultPanel from '@/app/components/workflow/run/result-panel'
|
import ResultPanel from '@/app/components/workflow/run/result-panel'
|
||||||
import Toast from '@/app/components/base/toast'
|
import Toast from '@/app/components/base/toast'
|
||||||
|
import { TransferMethod } from '@/types/app'
|
||||||
|
|
||||||
const i18nPrefix = 'workflow.singleRun'
|
const i18nPrefix = 'workflow.singleRun'
|
||||||
|
|
||||||
@ -51,7 +52,18 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
|
|||||||
|
|
||||||
const isFinished = runningStatus === NodeRunningStatus.Succeeded || runningStatus === NodeRunningStatus.Failed
|
const isFinished = runningStatus === NodeRunningStatus.Succeeded || runningStatus === NodeRunningStatus.Failed
|
||||||
const isRunning = runningStatus === NodeRunningStatus.Running
|
const isRunning = runningStatus === NodeRunningStatus.Running
|
||||||
|
const isFileLoaded = (() => {
|
||||||
|
// system files
|
||||||
|
const filesForm = forms.find(item => !!item.values['#files#'])
|
||||||
|
if (!filesForm)
|
||||||
|
return true
|
||||||
|
|
||||||
|
const files = filesForm.values['#files#'] as any
|
||||||
|
if (files?.some((item: any) => item.transfer_method === TransferMethod.local_file && !item.upload_file_id))
|
||||||
|
return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
})()
|
||||||
const handleRun = useCallback(() => {
|
const handleRun = useCallback(() => {
|
||||||
let errMsg = ''
|
let errMsg = ''
|
||||||
forms.forEach((form) => {
|
forms.forEach((form) => {
|
||||||
@ -129,7 +141,7 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
|
|||||||
<StopCircle className='w-4 h-4 text-gray-500' />
|
<StopCircle className='w-4 h-4 text-gray-500' />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Button disabled={isRunning} type='primary' className='w-0 grow !h-8 flex items-center space-x-2 text-[13px]' onClick={handleRun}>
|
<Button disabled={!isFileLoaded || isRunning} type='primary' className='w-0 grow !h-8 flex items-center space-x-2 text-[13px]' onClick={handleRun}>
|
||||||
{isRunning && <Loading02 className='animate-spin w-4 h-4 text-white' />}
|
{isRunning && <Loading02 className='animate-spin w-4 h-4 text-white' />}
|
||||||
<div>{t(`${i18nPrefix}.${isRunning ? 'running' : 'startRun'}`)}</div>
|
<div>{t(`${i18nPrefix}.${isRunning ? 'running' : 'startRun'}`)}</div>
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
} from '../store'
|
} from '../store'
|
||||||
import { useWorkflowRun } from '../hooks'
|
import { useWorkflowRun } from '../hooks'
|
||||||
import type { StartNodeType } from '../nodes/start/types'
|
import type { StartNodeType } from '../nodes/start/types'
|
||||||
|
import { TransferMethod } from '../../base/text-generation/types'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import { useFeatures } from '@/app/components/base/features/hooks'
|
import { useFeatures } from '@/app/components/base/features/hooks'
|
||||||
|
|
||||||
@ -75,6 +76,13 @@ const InputsPanel = ({ onRun }: Props) => {
|
|||||||
handleRun({ inputs, files })
|
handleRun({ inputs, files })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const canRun = (() => {
|
||||||
|
if (files?.some(item => (item.transfer_method as any) === TransferMethod.local_file && !item.upload_file_id))
|
||||||
|
return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
})()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className='px-4 pb-2'>
|
<div className='px-4 pb-2'>
|
||||||
@ -97,7 +105,7 @@ const InputsPanel = ({ onRun }: Props) => {
|
|||||||
<div className='flex items-center justify-between px-4 py-2'>
|
<div className='flex items-center justify-between px-4 py-2'>
|
||||||
<Button
|
<Button
|
||||||
type='primary'
|
type='primary'
|
||||||
disabled={workflowRunningData?.result?.status === WorkflowRunningStatus.Running}
|
disabled={!canRun || workflowRunningData?.result?.status === WorkflowRunningStatus.Running}
|
||||||
className='py-0 w-full h-8 rounded-lg text-[13px] font-medium'
|
className='py-0 w-full h-8 rounded-lg text-[13px] font-medium'
|
||||||
onClick={doRun}
|
onClick={doRun}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user