result-panel.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. 'use client'
  2. import type { FC } from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import StatusPanel from './status'
  5. import MetaData from './meta'
  6. import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
  7. import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
  8. import ErrorHandleTip from '@/app/components/workflow/nodes/_base/components/error-handle/error-handle-tip'
  9. type ResultPanelProps = {
  10. inputs?: string
  11. process_data?: string
  12. outputs?: string
  13. status: string
  14. error?: string
  15. elapsed_time?: number
  16. total_tokens?: number
  17. created_at?: number
  18. created_by?: string
  19. finished_at?: number
  20. steps?: number
  21. showSteps?: boolean
  22. exceptionCounts?: number
  23. execution_metadata?: any
  24. }
  25. const ResultPanel: FC<ResultPanelProps> = ({
  26. inputs,
  27. process_data,
  28. outputs,
  29. status,
  30. error,
  31. elapsed_time,
  32. total_tokens,
  33. created_at,
  34. created_by,
  35. steps,
  36. showSteps,
  37. exceptionCounts,
  38. execution_metadata,
  39. }) => {
  40. const { t } = useTranslation()
  41. return (
  42. <div className='bg-components-panel-bg py-2'>
  43. <div className='px-4 py-2'>
  44. <StatusPanel
  45. status={status}
  46. time={elapsed_time}
  47. tokens={total_tokens}
  48. error={error}
  49. exceptionCounts={exceptionCounts}
  50. />
  51. </div>
  52. <div className='px-4 py-2 flex flex-col gap-2'>
  53. <CodeEditor
  54. readOnly
  55. title={<div>{t('workflow.common.input').toLocaleUpperCase()}</div>}
  56. language={CodeLanguage.json}
  57. value={inputs}
  58. isJSONStringifyBeauty
  59. />
  60. {process_data && (
  61. <CodeEditor
  62. readOnly
  63. title={<div>{t('workflow.common.processData').toLocaleUpperCase()}</div>}
  64. language={CodeLanguage.json}
  65. value={process_data}
  66. isJSONStringifyBeauty
  67. />
  68. )}
  69. {(outputs || status === 'running') && (
  70. <CodeEditor
  71. readOnly
  72. title={<div>{t('workflow.common.output').toLocaleUpperCase()}</div>}
  73. language={CodeLanguage.json}
  74. value={outputs}
  75. isJSONStringifyBeauty
  76. tip={<ErrorHandleTip type={execution_metadata?.error_strategy} />}
  77. />
  78. )}
  79. </div>
  80. <div className='px-4 py-2'>
  81. <div className='h-[0.5px] divider-subtle' />
  82. </div>
  83. <div className='px-4 py-2'>
  84. <MetaData
  85. status={status}
  86. executor={created_by}
  87. startTime={created_at}
  88. time={elapsed_time}
  89. tokens={total_tokens}
  90. steps={steps}
  91. showSteps={showSteps}
  92. />
  93. </div>
  94. </div>
  95. )
  96. }
  97. export default ResultPanel