result-text.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. 'use client'
  2. import type { FC } from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import { ImageIndentLeft } from '@/app/components/base/icons/src/vender/line/editor'
  5. import { Markdown } from '@/app/components/base/markdown'
  6. import LoadingAnim from '@/app/components/base/chat/chat/loading-anim'
  7. import StatusContainer from '@/app/components/workflow/run/status-container'
  8. import { FileList } from '@/app/components/base/file-uploader'
  9. interface ResultTextProps {
  10. isRunning?: boolean
  11. outputs?: any
  12. error?: string
  13. onClick?: () => void
  14. allFiles?: any[]
  15. }
  16. const ResultText: FC<ResultTextProps> = ({
  17. isRunning,
  18. outputs,
  19. error,
  20. onClick,
  21. allFiles,
  22. }) => {
  23. const { t } = useTranslation()
  24. return (
  25. <div className='bg-background-section-burn'>
  26. {isRunning && !outputs && (
  27. <div className='pt-4 pl-[26px]'>
  28. <LoadingAnim type='text' />
  29. </div>
  30. )}
  31. {!isRunning && error && (
  32. <div className='px-4 py-2'>
  33. <StatusContainer status='failed'>
  34. {error}
  35. </StatusContainer>
  36. </div>
  37. )}
  38. {!isRunning && !outputs && !error && !allFiles?.length && (
  39. <div className='mt-[120px] px-4 py-2 flex flex-col items-center text-[13px] leading-[18px] text-gray-500'>
  40. <ImageIndentLeft className='w-6 h-6 text-gray-400' />
  41. <div className='mr-2'>{t('runLog.resultEmpty.title')}</div>
  42. <div>
  43. {t('runLog.resultEmpty.tipLeft')}
  44. <span onClick={onClick} className='cursor-pointer text-primary-600'>{t('runLog.resultEmpty.link')}</span>
  45. {t('runLog.resultEmpty.tipRight')}
  46. </div>
  47. </div>
  48. )}
  49. {(outputs || !!allFiles?.length) && (
  50. <>
  51. {outputs && (
  52. <div className='px-4 py-2'>
  53. <Markdown content={outputs} />
  54. </div>
  55. )}
  56. {!!allFiles?.length && allFiles.map(item => (
  57. <div key={item.varName} className='px-4 py-2 flex flex-col gap-1 system-xs-regular'>
  58. <div className='py-1 text-text-tertiary '>{item.varName}</div>
  59. <FileList
  60. files={item.list}
  61. showDeleteAction={false}
  62. showDownloadAction
  63. canPreview
  64. />
  65. </div>
  66. ))}
  67. </>
  68. )}
  69. </div>
  70. )
  71. }
  72. export default ResultText