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.

action-list.tsx 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React, { useMemo } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import ToolItem from '@/app/components/tools/provider/tool-item'
  4. import {
  5. useAllToolProviders,
  6. useBuiltinTools,
  7. } from '@/service/use-tools'
  8. import type { PluginDetail } from '@/app/components/plugins/types'
  9. type Props = {
  10. detail: PluginDetail
  11. }
  12. const ActionList = ({
  13. detail,
  14. }: Props) => {
  15. const { t } = useTranslation()
  16. const providerBriefInfo = detail.declaration.tool.identity
  17. const providerKey = `${detail.plugin_id}/${providerBriefInfo.name}`
  18. const { data: collectionList = [] } = useAllToolProviders()
  19. const provider = useMemo(() => {
  20. return collectionList.find(collection => collection.name === providerKey)
  21. }, [collectionList, providerKey])
  22. const { data } = useBuiltinTools(providerKey)
  23. if (!data || !provider)
  24. return null
  25. return (
  26. <div className='px-4 pb-4 pt-2'>
  27. <div className='mb-1 py-1'>
  28. <div className='system-sm-semibold-uppercase mb-1 flex h-6 items-center justify-between text-text-secondary'>
  29. {t('plugin.detailPanel.actionNum', { num: data.length, action: data.length > 1 ? 'actions' : 'action' })}
  30. </div>
  31. </div>
  32. <div className='flex flex-col gap-2'>
  33. {data.map(tool => (
  34. <ToolItem
  35. key={`${detail.plugin_id}${tool.name}`}
  36. disabled={false}
  37. collection={provider}
  38. tool={tool}
  39. isBuiltIn={true}
  40. isModel={false}
  41. />
  42. ))}
  43. </div>
  44. </div>
  45. )
  46. }
  47. export default ActionList