'use client' import type { FC } from 'react' import React, { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import { RiArrowRightSLine, RiCloseLine, RiErrorWarningLine, } from '@remixicon/react' import { ArrowNarrowLeft } from '../../base/icons/src/vender/line/arrows' import TracingPanel from './tracing-panel' import { Iteration } from '@/app/components/base/icons/src/vender/workflow' import cn from '@/utils/classnames' import type { NodeTracing } from '@/types/workflow' const i18nPrefix = 'workflow.singleRun' type Props = { list: NodeTracing[][] onHide: () => void onBack: () => void noWrap?: boolean } const IterationResultPanel: FC = ({ list, onHide, onBack, noWrap, }) => { const { t } = useTranslation() const [expandedIterations, setExpandedIterations] = useState>({}) const toggleIteration = useCallback((index: number) => { setExpandedIterations(prev => ({ ...prev, [index]: !prev[index], })) }, []) const main = ( <>
{t(`${i18nPrefix}.testRunIteration`)}
{t(`${i18nPrefix}.back`)}
{/* List */}
{list.map((iteration, index) => (
toggleIteration(index)} >
{t(`${i18nPrefix}.iteration`)} {index + 1} { iteration.some(item => item.status === 'failed') ? ( ) : (< RiArrowRightSLine className={ cn( 'w-4 h-4 text-text-tertiary transition-transform duration-200 flex-shrink-0', expandedIterations[index] && 'transform rotate-90', )} /> ) }
{expandedIterations[index] &&
}
))}
) const handleNotBubble = useCallback((e: React.MouseEvent) => { // if not do this, it will trigger the message log modal disappear(useClickAway) e.stopPropagation() e.nativeEvent.stopImmediatePropagation() }, []) if (noWrap) return main return (
{main}
) } export default React.memo(IterationResultPanel)