record.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { memo, useCallback } from 'react'
  2. import type { WorkflowRunDetailResponse } from '@/models/log'
  3. import Run from '../run'
  4. import { useStore } from '../store'
  5. import { useWorkflowUpdate } from '../hooks'
  6. import { formatWorkflowRunIdentifier } from '../utils'
  7. const Record = () => {
  8. const historyWorkflowData = useStore(s => s.historyWorkflowData)
  9. const { handleUpdateWorkflowCanvas } = useWorkflowUpdate()
  10. const handleResultCallback = useCallback((res: WorkflowRunDetailResponse) => {
  11. const graph = res.graph
  12. handleUpdateWorkflowCanvas({
  13. nodes: graph.nodes,
  14. edges: graph.edges,
  15. viewport: graph.viewport || { x: 0, y: 0, zoom: 1 },
  16. })
  17. }, [handleUpdateWorkflowCanvas])
  18. return (
  19. <div className='flex h-full w-[400px] flex-col rounded-l-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl'>
  20. <div className='system-xl-semibold flex items-center justify-between p-4 pb-0 text-text-primary'>
  21. {`Test Run${formatWorkflowRunIdentifier(historyWorkflowData?.finished_at)}`}
  22. </div>
  23. <Run
  24. runID={historyWorkflowData?.id || ''}
  25. getResultCallback={handleResultCallback}
  26. />
  27. </div>
  28. )
  29. }
  30. export default memo(Record)