status.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. 'use client'
  2. import type { FC } from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import cn from '@/utils/classnames'
  5. import Indicator from '@/app/components/header/indicator'
  6. import StatusContainer from '@/app/components/workflow/run/status-container'
  7. type ResultProps = {
  8. status: string
  9. time?: number
  10. tokens?: number
  11. error?: string
  12. }
  13. const StatusPanel: FC<ResultProps> = ({
  14. status,
  15. time,
  16. tokens,
  17. error,
  18. }) => {
  19. const { t } = useTranslation()
  20. return (
  21. <StatusContainer status={status}>
  22. <div className='flex'>
  23. <div className='flex-[33%] max-w-[120px]'>
  24. <div className='mb-1 text-text-tertiary system-2xs-medium-uppercase'>{t('runLog.resultPanel.status')}</div>
  25. <div
  26. className={cn(
  27. 'flex items-center gap-1 system-xs-semibold-uppercase',
  28. status === 'succeeded' && 'text-util-colors-green-green-600',
  29. status === 'failed' && 'text-util-colors-red-red-600',
  30. status === 'stopped' && 'text-util-colors-warning-warning-600',
  31. status === 'running' && 'text-util-colors-blue-light-blue-light-600',
  32. )}
  33. >
  34. {status === 'running' && (
  35. <>
  36. <Indicator color={'blue'} />
  37. <span>Running</span>
  38. </>
  39. )}
  40. {status === 'succeeded' && (
  41. <>
  42. <Indicator color={'green'} />
  43. <span>SUCCESS</span>
  44. </>
  45. )}
  46. {status === 'failed' && (
  47. <>
  48. <Indicator color={'red'} />
  49. <span>FAIL</span>
  50. </>
  51. )}
  52. {status === 'stopped' && (
  53. <>
  54. <Indicator color={'yellow'} />
  55. <span>STOP</span>
  56. </>
  57. )}
  58. </div>
  59. </div>
  60. <div className='flex-[33%] max-w-[152px]'>
  61. <div className='mb-1 text-text-tertiary system-2xs-medium-uppercase'>{t('runLog.resultPanel.time')}</div>
  62. <div className='flex items-center gap-1 system-sm-medium text-text-secondary'>
  63. {status === 'running' && (
  64. <div className='w-16 h-2 rounded-sm bg-text-quaternary' />
  65. )}
  66. {status !== 'running' && (
  67. <span>{time ? `${time?.toFixed(3)}s` : '-'}</span>
  68. )}
  69. </div>
  70. </div>
  71. <div className='flex-[33%]'>
  72. <div className='mb-1 text-text-tertiary system-2xs-medium-uppercase'>{t('runLog.resultPanel.tokens')}</div>
  73. <div className='flex items-center gap-1 system-sm-medium text-text-secondary'>
  74. {status === 'running' && (
  75. <div className='w-20 h-2 rounded-sm bg-text-quaternary' />
  76. )}
  77. {status !== 'running' && (
  78. <span>{`${tokens || 0} Tokens`}</span>
  79. )}
  80. </div>
  81. </div>
  82. </div>
  83. {status === 'failed' && error && (
  84. <>
  85. <div className='my-2 h-[0.5px] bg-divider-subtle'/>
  86. <div className='system-xs-regular text-text-destructive'>{error}</div>
  87. </>
  88. )}
  89. </StatusContainer>
  90. )
  91. }
  92. export default StatusPanel