You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 2.1KB

5 miesięcy temu
5 miesięcy temu
5 miesięcy temu
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import type { FC } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import { useEffect, useRef, useState } from 'react'
  4. import { useClickAway } from 'ahooks'
  5. import { RiCloseLine } from '@remixicon/react'
  6. import cn from '@/utils/classnames'
  7. import type { IChatItem } from '@/app/components/base/chat/chat/type'
  8. import Run from '@/app/components/workflow/run'
  9. import { useStore } from '@/app/components/app/store'
  10. type MessageLogModalProps = {
  11. currentLogItem?: IChatItem
  12. defaultTab?: string
  13. width: number
  14. fixedWidth?: boolean
  15. onCancel: () => void
  16. }
  17. const MessageLogModal: FC<MessageLogModalProps> = ({
  18. currentLogItem,
  19. defaultTab = 'DETAIL',
  20. width,
  21. fixedWidth,
  22. onCancel,
  23. }) => {
  24. const { t } = useTranslation()
  25. const ref = useRef(null)
  26. const [mounted, setMounted] = useState(false)
  27. const appDetail = useStore(state => state.appDetail)
  28. useClickAway(() => {
  29. if (mounted)
  30. onCancel()
  31. }, ref)
  32. useEffect(() => {
  33. setMounted(true)
  34. }, [])
  35. if (!currentLogItem || !currentLogItem.workflow_run_id)
  36. return null
  37. return (
  38. <div
  39. className={cn('relative z-10 flex flex-col rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg pt-3 shadow-xl')}
  40. style={{
  41. width: fixedWidth ? width : 480,
  42. ...(!fixedWidth
  43. ? {
  44. position: 'fixed',
  45. top: 56 + 8,
  46. left: 8 + (width - 480),
  47. bottom: 16,
  48. }
  49. : {
  50. marginRight: 8,
  51. }),
  52. }}
  53. ref={ref}
  54. >
  55. <h1 className='system-xl-semibold shrink-0 px-4 py-1 text-text-primary'>{t('appLog.runDetail.title')}</h1>
  56. <span className='absolute right-3 top-4 z-20 cursor-pointer p-1' onClick={onCancel}>
  57. <RiCloseLine className='h-4 w-4 text-text-tertiary' />
  58. </span>
  59. <Run
  60. hideResult
  61. activeTab={defaultTab as any}
  62. runDetailUrl={`/apps/${appDetail?.id}/workflow-runs/${currentLogItem.workflow_run_id}`}
  63. tracingListUrl={`/apps/${appDetail?.id}/workflow-runs/${currentLogItem.workflow_run_id}/node-executions`}
  64. />
  65. </div>
  66. )
  67. }
  68. export default MessageLogModal