node.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import type { FC } from 'react'
  2. import React from 'react'
  3. import type { ToolNodeType } from './types'
  4. import type { NodeProps } from '@/app/components/workflow/types'
  5. const Node: FC<NodeProps<ToolNodeType>> = ({
  6. data,
  7. }) => {
  8. const { tool_configurations } = data
  9. const toolConfigs = Object.keys(tool_configurations || {})
  10. if (!toolConfigs.length)
  11. return null
  12. return (
  13. <div className='mb-1 px-3 py-1'>
  14. <div className='space-y-0.5'>
  15. {toolConfigs.map((key, index) => (
  16. <div key={index} className='flex items-center h-6 justify-between bg-gray-100 rounded-md px-1 space-x-1 text-xs font-normal text-gray-700'>
  17. <div title={key} className='max-w-[100px] shrink-0 truncate text-xs font-medium text-gray-500 uppercase'>
  18. {key}
  19. </div>
  20. <div title={tool_configurations[key]} className='grow w-0 shrink-0 truncate text-right text-xs font-normal text-gray-700'>
  21. {tool_configurations[key]}
  22. </div>
  23. </div>
  24. ))}
  25. </div>
  26. </div>
  27. )
  28. }
  29. export default React.memo(Node)