| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  | 'use client' | 
					
						
							|  |  |  | import type { FC } from 'react' | 
					
						
							|  |  |  | import { useTranslation } from 'react-i18next' | 
					
						
							|  |  |  | import { ImageIndentLeft } from '@/app/components/base/icons/src/vender/line/editor' | 
					
						
							|  |  |  | import { Markdown } from '@/app/components/base/markdown' | 
					
						
							| 
									
										
										
										
											2024-06-24 12:29:14 +08:00
										 |  |  | import LoadingAnim from '@/app/components/base/chat/chat/loading-anim' | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  | import StatusContainer from '@/app/components/workflow/run/status-container' | 
					
						
							|  |  |  | import { FileList } from '@/app/components/base/file-uploader' | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  | type ResultTextProps = { | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  |   isRunning?: boolean | 
					
						
							|  |  |  |   outputs?: any | 
					
						
							|  |  |  |   error?: string | 
					
						
							|  |  |  |   onClick?: () => void | 
					
						
							| 
									
										
										
										
											2024-12-05 16:58:39 +08:00
										 |  |  |   allFiles?: any[] | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const ResultText: FC<ResultTextProps> = ({ | 
					
						
							|  |  |  |   isRunning, | 
					
						
							|  |  |  |   outputs, | 
					
						
							|  |  |  |   error, | 
					
						
							|  |  |  |   onClick, | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |   allFiles, | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  | }) => { | 
					
						
							|  |  |  |   const { t } = useTranslation() | 
					
						
							|  |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2024-12-05 16:58:39 +08:00
										 |  |  |     <div className='bg-background-section-burn'> | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  |       {isRunning && !outputs && ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         <div className='pl-[26px] pt-4'> | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  |           <LoadingAnim type='text' /> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       )} | 
					
						
							|  |  |  |       {!isRunning && error && ( | 
					
						
							| 
									
										
										
										
											2024-12-05 16:58:39 +08:00
										 |  |  |         <div className='px-4 py-2'> | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |           <StatusContainer status='failed'> | 
					
						
							|  |  |  |             {error} | 
					
						
							|  |  |  |           </StatusContainer> | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  |         </div> | 
					
						
							|  |  |  |       )} | 
					
						
							| 
									
										
										
										
											2024-12-05 16:58:39 +08:00
										 |  |  |       {!isRunning && !outputs && !error && !allFiles?.length && ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         <div className='mt-[120px] flex flex-col items-center px-4 py-2 text-[13px] leading-[18px] text-gray-500'> | 
					
						
							|  |  |  |           <ImageIndentLeft className='h-6 w-6 text-gray-400' /> | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  |           <div className='mr-2'>{t('runLog.resultEmpty.title')}</div> | 
					
						
							|  |  |  |           <div> | 
					
						
							|  |  |  |             {t('runLog.resultEmpty.tipLeft')} | 
					
						
							|  |  |  |             <span onClick={onClick} className='cursor-pointer text-primary-600'>{t('runLog.resultEmpty.link')}</span> | 
					
						
							|  |  |  |             {t('runLog.resultEmpty.tipRight')} | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       )} | 
					
						
							| 
									
										
										
										
											2024-12-05 16:58:39 +08:00
										 |  |  |       {(outputs || !!allFiles?.length) && ( | 
					
						
							|  |  |  |         <> | 
					
						
							|  |  |  |           {outputs && ( | 
					
						
							|  |  |  |             <div className='px-4 py-2'> | 
					
						
							|  |  |  |               <Markdown content={outputs} /> | 
					
						
							|  |  |  |             </div> | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |           )} | 
					
						
							| 
									
										
										
										
											2024-12-05 16:58:39 +08:00
										 |  |  |           {!!allFiles?.length && allFiles.map(item => ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |             <div key={item.varName} className='system-xs-regular flex flex-col gap-1 px-4 py-2'> | 
					
						
							| 
									
										
										
										
											2024-12-05 16:58:39 +08:00
										 |  |  |               <div className='py-1 text-text-tertiary '>{item.varName}</div> | 
					
						
							|  |  |  |               <FileList | 
					
						
							|  |  |  |                 files={item.list} | 
					
						
							|  |  |  |                 showDeleteAction={false} | 
					
						
							|  |  |  |                 showDownloadAction | 
					
						
							|  |  |  |                 canPreview | 
					
						
							|  |  |  |               /> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           ))} | 
					
						
							|  |  |  |         </> | 
					
						
							| 
									
										
										
										
											2024-04-28 17:37:00 +08:00
										 |  |  |       )} | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default ResultText |