feat: single run progress

pull/21369/head
Joel 1 year ago
parent e848c0c1d8
commit 62c1c76639

@ -1,6 +1,6 @@
'use client' 'use client'
import type { FC } from 'react' import type { FC } from 'react'
import React, { useCallback } from 'react' import React from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { import {
RiCloseLine, RiCloseLine,
@ -87,7 +87,7 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
return true return true
})() })()
const handleRun = useCallback(() => { const handleRun = () => {
let errMsg = '' let errMsg = ''
forms.forEach((form) => { forms.forEach((form) => {
form.inputs.forEach((input) => { form.inputs.forEach((input) => {
@ -137,7 +137,7 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
} }
onRun(submitData) onRun(submitData)
}, [forms, onRun, t]) }
return ( return (
<div className='absolute inset-0 z-10 rounded-2xl bg-background-overlay-alt'> <div className='absolute inset-0 z-10 rounded-2xl bg-background-overlay-alt'>
<div className='flex h-full flex-col rounded-2xl bg-components-panel-bg'> <div className='flex h-full flex-col rounded-2xl bg-components-panel-bg'>

@ -145,7 +145,7 @@ const BasePanel: FC<BasePanelProps> = ({
showSingleRun, showSingleRun,
hideSingleRun, hideSingleRun,
runningStatus, runningStatus,
handleRun, handleRun: callRunApi,
handleStop, handleStop,
runInputData, runInputData,
runInputDataRef, runInputDataRef,
@ -168,6 +168,11 @@ const BasePanel: FC<BasePanelProps> = ({
}, [doSetRunInputData]) }, [doSetRunInputData])
const [tabType, setTabType] = useState<TabType>(TabType.settings) const [tabType, setTabType] = useState<TabType>(TabType.settings)
const handleRun = async (data: Record<string, any>) => {
setTabType(TabType.lastRun)
callRunApi(data)
hideSingleRun()
}
const hasLastRunData = true // TODO: add disabled logic const hasLastRunData = true // TODO: add disabled logic
return ( return (
@ -302,7 +307,7 @@ const BasePanel: FC<BasePanelProps> = ({
)} )}
{tabType === TabType.lastRun && ( {tabType === TabType.lastRun && (
<LastRun appId={id} /> <LastRun nodeId={id} runningStatus={runningStatus} />
)} )}
{ {

@ -1,20 +1,44 @@
'use client' 'use client'
import ResultPanel from '@/app/components/workflow/run/result-panel' import ResultPanel from '@/app/components/workflow/run/result-panel'
import { useWorkflowStore } from '@/app/components/workflow/store'
import { NodeRunningStatus } from '@/app/components/workflow/types'
import type { FC } from 'react' import type { FC } from 'react'
import React from 'react' import React, { useEffect, useState } from 'react'
type Props = { type Props = {
appId: string nodeId: string
runningStatus: NodeRunningStatus
} }
const LastRun: FC<Props> = ({ const LastRun: FC<Props> = ({
appId, nodeId,
runningStatus,
}) => { }) => {
const workflowStore = useWorkflowStore()
const {
getLastRunNodeInfo,
} = workflowStore.getState()
const [runResult, setRunResult] = useState(getLastRunNodeInfo(nodeId))
const isRunning = runningStatus === NodeRunningStatus.Running
useEffect(() => {
setRunResult(getLastRunNodeInfo(nodeId))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [runningStatus])
if (isRunning)
return <ResultPanel status='running' showSteps={false} />
if (!runResult) {
return (
<div>no data</div>
)
}
return ( return (
<div> <div>
last run: {appId}
<ResultPanel <ResultPanel
status='success' {...runResult as any}
showSteps={false}
/> />
</div> </div>
) )

@ -228,6 +228,7 @@ const useOneStepRun = <T>({
id, id,
data: { data: {
...data, ...data,
_isSingleRun: false,
_singleRunningStatus: NodeRunningStatus.Running, _singleRunningStatus: NodeRunningStatus.Running,
}, },
}) })
@ -250,6 +251,7 @@ const useOneStepRun = <T>({
id, id,
data: { data: {
...data, ...data,
_isSingleRun: false,
_singleRunningStatus: NodeRunningStatus.Succeeded, _singleRunningStatus: NodeRunningStatus.Succeeded,
}, },
}) })
@ -326,6 +328,7 @@ const useOneStepRun = <T>({
id, id,
data: { data: {
...data, ...data,
_isSingleRun: false,
_singleRunningStatus: NodeRunningStatus.Failed, _singleRunningStatus: NodeRunningStatus.Failed,
}, },
}) })
@ -347,6 +350,7 @@ const useOneStepRun = <T>({
id, id,
data: { data: {
...data, ...data,
_isSingleRun: false,
_singleRunningStatus: NodeRunningStatus.Succeeded, _singleRunningStatus: NodeRunningStatus.Succeeded,
}, },
}) })
@ -424,6 +428,7 @@ const useOneStepRun = <T>({
id, id,
data: { data: {
...data, ...data,
_isSingleRun: false,
_singleRunningStatus: NodeRunningStatus.Failed, _singleRunningStatus: NodeRunningStatus.Failed,
}, },
}) })
@ -441,6 +446,7 @@ const useOneStepRun = <T>({
id, id,
data: { data: {
...data, ...data,
_isSingleRun: false,
_singleRunningStatus: NodeRunningStatus.Failed, _singleRunningStatus: NodeRunningStatus.Failed,
}, },
}) })
@ -461,6 +467,7 @@ const useOneStepRun = <T>({
id, id,
data: { data: {
...data, ...data,
_isSingleRun: false,
_singleRunningStatus: NodeRunningStatus.Succeeded, _singleRunningStatus: NodeRunningStatus.Succeeded,
}, },
}) })

@ -17,7 +17,6 @@ import { InputVarType, type NodePanelProps } from '@/app/components/workflow/typ
import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor' import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor'
import useCurrentVars from '../../hooks/use-current-vars'
import StructureOutput from './components/structure-output' import StructureOutput from './components/structure-output'
import Switch from '@/app/components/base/switch' import Switch from '@/app/components/base/switch'
import { RiAlertFill, RiQuestionLine } from '@remixicon/react' import { RiAlertFill, RiQuestionLine } from '@remixicon/react'
@ -31,10 +30,6 @@ const Panel = forwardRef<PanelExposedType, NodePanelProps<LLMNodeType>>(({
panelProps, panelProps,
}, ref) => { }, ref) => {
const { t } = useTranslation() const { t } = useTranslation()
const {
currentVars,
} = useCurrentVars()
console.log(currentVars)
const { const {
readOnly, readOnly,
inputs, inputs,

@ -21,7 +21,7 @@ type ResultPanelProps = {
nodeInfo?: NodeTracing nodeInfo?: NodeTracing
inputs?: string inputs?: string
process_data?: string process_data?: string
outputs?: string outputs?: string | Record<string, any>
status: string status: string
error?: string error?: string
elapsed_time?: number elapsed_time?: number

Loading…
Cancel
Save