result-text.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. import type { FileEntity } from '@/app/components/base/file-uploader/types'
  10. type ResultTextProps = {
  11. isRunning?: boolean
  12. outputs?: any
  13. error?: string
  14. onClick?: () => void
  15. allFiles?: FileEntity[]
  16. }
  17. const ResultText: FC<ResultTextProps> = ({
  18. isRunning,
  19. outputs,
  20. error,
  21. onClick,
  22. allFiles,
  23. }) => {
  24. const { t } = useTranslation()
  25. return (
  26. <div className='bg-background-section-burn py-2'>
  27. {isRunning && !outputs && (
  28. <div className='pt-4 pl-[26px]'>
  29. <LoadingAnim type='text' />
  30. </div>
  31. )}
  32. {!isRunning && error && (
  33. <div className='px-4'>
  34. <StatusContainer status='failed'>
  35. {error}
  36. </StatusContainer>
  37. </div>
  38. )}
  39. {!isRunning && !outputs && !error && (
  40. <div className='mt-[120px] px-4 py-2 flex flex-col items-center text-[13px] leading-[18px] text-gray-500'>
  41. <ImageIndentLeft className='w-6 h-6 text-gray-400' />
  42. <div className='mr-2'>{t('runLog.resultEmpty.title')}</div>
  43. <div>
  44. {t('runLog.resultEmpty.tipLeft')}
  45. <span onClick={onClick} className='cursor-pointer text-primary-600'>{t('runLog.resultEmpty.link')}</span>
  46. {t('runLog.resultEmpty.tipRight')}
  47. </div>
  48. </div>
  49. )}
  50. {outputs && (
  51. <div className='px-4 py-2'>
  52. <Markdown content={outputs} />
  53. {!!allFiles?.length && (
  54. <FileList
  55. files={allFiles}
  56. showDeleteAction={false}
  57. showDownloadAction
  58. canPreview
  59. />
  60. )}
  61. </div>
  62. )}
  63. </div>
  64. )
  65. }
  66. export default ResultText