'use client' import type { Collection } from '@/app/components/tools/types' import { cn } from '@langgenius/dify-ui/cn' import { RiLoginCircleLine } from '@remixicon/react' import * as React from 'react' import { useTranslation } from 'react-i18next' import Icon from '@/app/components/plugins/card/base/card-icon' import CornerMark from '@/app/components/plugins/card/base/corner-mark' import { useGetLanguage } from '@/context/i18n' import { renderI18nObject } from '@/i18n-config' const getCollectionPluginIdentity = (collection: Collection) => { const [org, ...nameParts] = collection.plugin_id?.split('/').filter(Boolean) ?? [] if (org && nameParts.length) { return { org, name: nameParts.join('/'), } } return { org: collection.author || '', name: collection.name, } } type IntegrationsToolProviderCardProps = { collection: Collection current?: boolean showBuiltInBadge?: boolean variant?: 'default' | 'labeled' } function IntegrationsToolProviderCard({ collection, current, showBuiltInBadge = false, variant = 'default', }: IntegrationsToolProviderCardProps) { const language = useGetLanguage() const { t } = useTranslation() const title = renderI18nObject(collection.label, language) const description = renderI18nObject(collection.description, language) const { org, name } = getCollectionPluginIdentity(collection) const toolsCount = collection.tools?.length ?? 0 const builtInLabel = t('metadata.datasetMetadata.builtIn', { ns: 'dataset' }) const shouldShowBuiltInBadge = showBuiltInBadge && !collection.plugin_id const isLabeledVariant = variant === 'labeled' if (isLabeledVariant) { return (
{title}
{collection.author && `${t('author', { ns: 'tools' })} ${collection.author}`}
{description}
{collection.labels?.map(label => (
# {label}
))}
) } return (
{shouldShowBuiltInBadge && }
{title}
{description}
{!!org && ( <>
{org}
/
)}
{name}
{toolsCount > 0 && ( <>
ยท
{t('mcp.toolsCount', { ns: 'tools', count: toolsCount })}
)}
) } export default React.memo(IntegrationsToolProviderCard)