'use client' import { cn } from '@langgenius/dify-ui/cn' import { RiArrowRightLine, RiArrowRightUpLine } from '@remixicon/react' import { useTranslation } from 'react-i18next' import { buildIntegrationPath } from '@/app/components/integrations/routes' import { useDocLink } from '@/context/i18n' import useTheme from '@/hooks/use-theme' import Link from '@/next/link' import { NoToolPlaceholder } from '../../base/icons/src/vender/other' import { ToolType } from '../../workflow/block-selector/types' type Props = Readonly<{ type?: ToolType isAgent?: boolean }> const workflowToolStepKeys = [ 'workflowToolEmpty.step1', 'workflowToolEmpty.step2', 'workflowToolEmpty.step3', ] as const const getLink = (type?: ToolType) => { switch (type) { case ToolType.Custom: return buildIntegrationPath('custom-tool') case ToolType.MCP: return buildIntegrationPath('mcp') default: return buildIntegrationPath('custom-tool') } } const Empty = ({ type, isAgent }: Props) => { const { t } = useTranslation() const docLink = useDocLink() const { theme } = useTheme() const hasLink = type === ToolType.Custom || type === ToolType.MCP const renderType = isAgent ? ('agent' as const) : type const hasTitle = renderType && t(($) => $[`addToolModal.${renderType}.title`], { ns: 'tools' }) !== `addToolModal.${renderType}.title` const tipClassName = cn( 'flex items-center text-[13px] leading-[18px] text-text-tertiary', hasLink && 'cursor-pointer hover:text-text-accent', ) const tipContent = renderType && ( <> {t(($) => $[`addToolModal.${renderType}.tip`], { ns: 'tools' })}{' '} {hasLink && } ) if (!isAgent && type === ToolType.Workflow) { return (
{t(($) => $['workflowToolEmpty.title'], { ns: 'tools' })}
{t(($) => $['workflowToolEmpty.description'], { ns: 'tools' })}
{workflowToolStepKeys.map((stepKey, index) => (
{index + 1}
{t(($) => $[stepKey], { ns: 'tools' })}
))}
{t(($) => $['workflowToolEmpty.goToStudio'], { ns: 'tools' })}
{t(($) => $['workflowToolEmpty.learnMore'], { ns: 'tools' })}
) } return (
{hasTitle && renderType ? t(($) => $[`addToolModal.${renderType}.title`], { ns: 'tools' }) : 'No tools available'}
{!!(!isAgent && hasTitle && renderType && hasLink) && ( {tipContent} )} {!!(!isAgent && hasTitle && renderType && !hasLink) && (
{tipContent}
)}
) } export default Empty