import { memo, 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 { useStore, useWorkflowStore } 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 workflowStore = useWorkflowStore() 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) } return (
{`Test Run${!workflowRunningData?.result.sequence_number ? '' : `#${workflowRunningData?.result.sequence_number}`}`} {showInputsPanel && workflowRunningData?.result?.status !== WorkflowRunningStatus.Running && (
{ workflowStore.setState({ showInputsPanel: false, workflowRunningData: undefined, }) }}>
)}
{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)