'use client' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { RiDeleteBinLine, RiEqualizer2Line, RiErrorWarningFill, } from '@remixicon/react' import { Group } from '@/app/components/base/icons/src/vender/other' import AppIcon from '@/app/components/base/app-icon' import Switch from '@/app/components/base/switch' import Button from '@/app/components/base/button' import Indicator from '@/app/components/header/indicator' import ActionButton from '@/app/components/base/action-button' import Tooltip from '@/app/components/base/tooltip' import { InstallPluginButton } from '@/app/components/workflow/nodes/_base/components/install-plugin-button' import cn from '@/utils/classnames' type Props = { icon?: any providerName?: string toolName?: string showSwitch?: boolean switchValue?: boolean onSwitchChange?: (value: boolean) => void onDelete?: () => void noAuth?: boolean onAuth?: () => void isError?: boolean errorTip?: any uninstalled?: boolean isInstalling?: boolean onInstall?: () => void open: boolean } const ToolItem = ({ open, icon, providerName, toolName, showSwitch, switchValue, onSwitchChange, onDelete, noAuth, onAuth, uninstalled, isInstalling, onInstall, isError, errorTip, }: Props) => { const { t } = useTranslation() const providerNameText = providerName?.split('/').pop() const isTransparent = uninstalled || isError const [isDeleting, setIsDeleting] = useState(false) return (
{icon && (
{typeof icon === 'string' &&
} {typeof icon !== 'string' && }
)} {!icon && (
)}
{providerNameText}
{toolName}
{!noAuth && !isError && !uninstalled && ( )}
{ e.stopPropagation() onDelete?.() }} onMouseOver={() => setIsDeleting(true)} onMouseLeave={() => setIsDeleting(false)} >
{!isError && !uninstalled && !noAuth && showSwitch && (
e.stopPropagation()}>
)} {!isError && !uninstalled && noAuth && ( )} {!isError && uninstalled && ( { e.stopPropagation() onInstall?.() }} /> )} {isError && (
)}
) } export default ToolItem