import React, { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { RiArrowRightSLine } from '@remixicon/react' import FileImageRender from './file-image-render' import FileTypeIcon from './file-type-icon' import FileItem from './file-uploader-in-attachment/file-item' import type { FileEntity } from './types' import { getFileAppearanceType, } from './utils' import Tooltip from '@/app/components/base/tooltip' import { SupportUploadFileTypes } from '@/app/components/workflow/types' import cn from '@/utils/classnames' type Props = { fileList: { varName: string list: FileEntity[] }[] isExpanded?: boolean noBorder?: boolean noPadding?: boolean } const FileListInLog = ({ fileList, isExpanded = false, noBorder = false, noPadding = false }: Props) => { const { t } = useTranslation() const [expanded, setExpanded] = useState(isExpanded) const fullList = useMemo(() => { return fileList.reduce((acc: FileEntity[], { list }) => { return [...acc, ...list] }, []) }, [fileList]) if (!fileList.length) return null return (
{expanded && (
setExpanded(!expanded)}>{t('appLog.runDetail.fileListLabel')}
)} {!expanded && (
{fullList.map((file) => { const { id, name, type, supportFileType, base64Url, url } = file const isImageFile = supportFileType === SupportUploadFileTypes.image return ( <> {isImageFile && (
)} {!isImageFile && (
)} ) })}
)}
setExpanded(!expanded)}> {!expanded &&
{t('appLog.runDetail.fileListDetail')}
}
{expanded && (
{fileList.map(item => (
{item.varName}
{item.list.map(file => ( ))}
))}
)}
) } export default FileListInLog