import FileStatusBadge from '@/components/file-status-badge'; import { Button } from '@/components/ui/button'; import { Modal } from '@/components/ui/modal/modal'; import { useTranslate } from '@/hooks/common-hooks'; import React from 'react'; import reactStringReplace from 'react-string-replace'; export interface ILogInfo { taskId?: string; fileName: string; fileSize?: string; source?: string; task?: string; state?: 'Running' | 'Success' | 'Failed' | 'Pending'; startTime?: string; endTime?: string; duration?: string; details: string; } interface ProcessLogModalProps { visible: boolean; onCancel: () => void; logInfo: ILogInfo; } const InfoItem: React.FC<{ label: string; value: string | React.ReactNode; className?: string; }> = ({ label, value, className = '' }) => { return (
{label} {value}
); }; const ProcessLogModal: React.FC = ({ visible, onCancel, logInfo, }) => { const { t } = useTranslate('knowledgeDetails'); const blackKeyList = ['']; const replaceText = (text: string) => { // Remove duplicate \n const nextText = text.replace(/(\n)\1+/g, '$1'); const replacedText = reactStringReplace( nextText, /(\[ERROR\].+\s)/g, (match, i) => { return ( {match} ); }, ); return replacedText; }; return ( } className="process-log-modal" >
{Object.keys(logInfo).map((key) => { if (blackKeyList.includes(key)) { return null; } if (key === 'details') { return (
{replaceText(logInfo.details)}
} />
); } if (key === 'Status') { return (
Status
); } return (
); })}
{/* */} {/*
Details
    {replaceText(logInfo.details)}
*/}
); }; export default ProcessLogModal;