import { memo, useEffect, useRef, useState, } from 'react' import cn from 'classnames' import { useTranslation } from 'react-i18next' import OutputPanel from '../run/output-panel' import ResultPanel from '../run/result-panel' import TracingPanel from '../run/tracing-panel' import { useWorkflowRun, } from '../hooks' import { useStore } from '../store' import { WorkflowRunningStatus, } from '../types' import InputsPanel from './inputs-panel' import Loading from '@/app/components/base/loading' import { XClose } from '@/app/components/base/icons/src/vender/line/general' const WorkflowPreview = () => { const { t } = useTranslation() const { handleRunSetting } = useWorkflowRun() const showInputsPanel = useStore(s => s.showInputsPanel) const workflowRunningData = useStore(s => s.workflowRunningData) const [currentTab, setCurrentTab] = useState(showInputsPanel ? 'INPUT' : 'TRACING') const switchTab = async (tab: string) => { setCurrentTab(tab) } const [height, setHieght] = useState(0) const ref = useRef(null) const adjustResultHeight = () => { if (ref.current) setHieght(ref.current?.clientHeight - 16 - 16 - 2 - 1) } useEffect(() => { adjustResultHeight() }, []) return (
{`Test Run${!workflowRunningData?.result.sequence_number ? '' : `#${workflowRunningData?.result.sequence_number}`}`} {showInputsPanel && workflowRunningData?.result?.status !== WorkflowRunningStatus.Running && (
handleRunSetting(true)}>
)}
{showInputsPanel && (
switchTab('INPUT')} >{t('runLog.input')}
)}
{ if (!workflowRunningData) return switchTab('RESULT') }} >{t('runLog.result')}
{ if (!workflowRunningData) return switchTab('DETAIL') }} >{t('runLog.detail')}
{ if (!workflowRunningData) return switchTab('TRACING') }} >{t('runLog.tracing')}
{currentTab === 'INPUT' && ( switchTab('RESULT')} /> )} {currentTab === 'RESULT' && ( )} {currentTab === 'DETAIL' && ( )} {currentTab === 'DETAIL' && !workflowRunningData?.result && (
)} {currentTab === 'TRACING' && ( )} {currentTab === 'TRACING' && !workflowRunningData?.tracing?.length && (
)}
) } export default memo(WorkflowPreview)