Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

empty.tsx 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use client'
  2. import { useTranslation } from 'react-i18next'
  3. import { ToolTypeEnum } from '../../workflow/block-selector/types'
  4. import { RiArrowRightUpLine } from '@remixicon/react'
  5. import Link from 'next/link'
  6. import cn from '@/utils/classnames'
  7. import { NoToolPlaceholder } from '../../base/icons/src/vender/other'
  8. type Props = {
  9. type?: ToolTypeEnum
  10. isAgent?: boolean
  11. }
  12. const getLink = (type?: ToolTypeEnum) => {
  13. switch (type) {
  14. case ToolTypeEnum.Custom:
  15. return '/tools?category=api'
  16. case ToolTypeEnum.MCP:
  17. return '/tools?category=mcp'
  18. default:
  19. return '/tools?category=api'
  20. }
  21. }
  22. const Empty = ({
  23. type,
  24. isAgent,
  25. }: Props) => {
  26. const { t } = useTranslation()
  27. const hasLink = type && [ToolTypeEnum.Custom, ToolTypeEnum.MCP].includes(type)
  28. const Comp = (hasLink ? Link : 'div') as any
  29. const linkProps = hasLink ? { href: getLink(type), target: '_blank' } : {}
  30. const renderType = isAgent ? 'agent' : type
  31. const hasTitle = t(`tools.addToolModal.${renderType}.title`) !== `tools.addToolModal.${renderType}.title`
  32. return (
  33. <div className='flex h-[336px] flex-col items-center justify-center'>
  34. <NoToolPlaceholder />
  35. <div className='mb-1 mt-2 text-[13px] font-medium leading-[18px] text-text-primary'>
  36. {hasTitle ? t(`tools.addToolModal.${renderType}.title`) : 'No tools available'}
  37. </div>
  38. {(!isAgent && hasTitle) && (
  39. <Comp className={cn('flex items-center text-[13px] leading-[18px] text-text-tertiary', hasLink && 'cursor-pointer hover:text-text-accent')} {...linkProps}>
  40. {t(`tools.addToolModal.${renderType}.tip`)} {hasLink && <RiArrowRightUpLine className='ml-0.5 h-3 w-3' />}
  41. </Comp>
  42. )}
  43. </div>
  44. )
  45. }
  46. export default Empty