您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

empty.tsx 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. import useTheme from '@/hooks/use-theme'
  9. type Props = {
  10. type?: ToolTypeEnum
  11. isAgent?: boolean
  12. }
  13. const getLink = (type?: ToolTypeEnum) => {
  14. switch (type) {
  15. case ToolTypeEnum.Custom:
  16. return '/tools?category=api'
  17. case ToolTypeEnum.MCP:
  18. return '/tools?category=mcp'
  19. default:
  20. return '/tools?category=api'
  21. }
  22. }
  23. const Empty = ({
  24. type,
  25. isAgent,
  26. }: Props) => {
  27. const { t } = useTranslation()
  28. const { theme } = useTheme()
  29. const hasLink = type && [ToolTypeEnum.Custom, ToolTypeEnum.MCP].includes(type)
  30. const Comp = (hasLink ? Link : 'div') as any
  31. const linkProps = hasLink ? { href: getLink(type), target: '_blank' } : {}
  32. const renderType = isAgent ? 'agent' : type
  33. const hasTitle = t(`tools.addToolModal.${renderType}.title`) !== `tools.addToolModal.${renderType}.title`
  34. return (
  35. <div className='flex h-[336px] flex-col items-center justify-center'>
  36. <NoToolPlaceholder className={theme === 'dark' ? 'invert' : ''} />
  37. <div className='mb-1 mt-2 text-[13px] font-medium leading-[18px] text-text-primary'>
  38. {hasTitle ? t(`tools.addToolModal.${renderType}.title`) : 'No tools available'}
  39. </div>
  40. {(!isAgent && hasTitle) && (
  41. <Comp className={cn('flex items-center text-[13px] leading-[18px] text-text-tertiary', hasLink && 'cursor-pointer hover:text-text-accent')} {...linkProps}>
  42. {t(`tools.addToolModal.${renderType}.tip`)} {hasLink && <RiArrowRightUpLine className='ml-0.5 h-3 w-3' />}
  43. </Comp>
  44. )}
  45. </div>
  46. )
  47. }
  48. export default Empty