'use client' import type { FC } from 'react' import type { NodeTracing } from '@/types/workflow' import { RiArrowRightSLine, RiCloseLine, } from '@remixicon/react' import * as React from 'react' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import { Loop } from '@/app/components/base/icons/src/vender/workflow' import { cn } from '@/utils/classnames' import { ArrowNarrowLeft } from '../../base/icons/src/vender/line/arrows' import TracingPanel from './tracing-panel' const i18nPrefix = 'singleRun' type Props = { list: NodeTracing[][] onHide: () => void onBack: () => void noWrap?: boolean } const LoopResultPanel: FC = ({ list, onHide, onBack, noWrap, }) => { const { t } = useTranslation() const [expandedLoops, setExpandedLoops] = useState>([]) const toggleLoop = useCallback((index: number) => { setExpandedLoops(prev => ({ ...prev, [index]: !prev[index], })) }, []) const main = ( <>
{t(`${i18nPrefix}.testRunLoop`, { ns: 'workflow' }) }
{t(`${i18nPrefix}.back`, { ns: 'workflow' })}
{/* List */}
{list.map((loop, index) => (
toggleLoop(index)} >
{t(`${i18nPrefix}.loop`, { ns: 'workflow' })} {' '} {index + 1}
{expandedLoops[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(LoopResultPanel)