diff --git a/web/app/components/plugins/plugin-detail-panel/index.tsx b/web/app/components/plugins/plugin-detail-panel/index.tsx index 3378d75b5b..fcc31b938d 100644 --- a/web/app/components/plugins/plugin-detail-panel/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/index.tsx @@ -33,6 +33,9 @@ const PluginDetailPanel: FC = ({ console.log('tool change', val) setValue(val) } + const testDelete = () => { + setValue(undefined) + } if (!detail) return null @@ -63,6 +66,7 @@ const PluginDetailPanel: FC = ({ testChange(item)} + onDelete={testDelete} /> diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx index 732c94103f..3e7993f761 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx @@ -2,6 +2,7 @@ import type { FC } from 'react' import React, { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' +import Link from 'next/link' import { RiArrowLeftLine, RiArrowRightUpLine, @@ -12,6 +13,7 @@ import { PortalToFollowElemTrigger, } from '@/app/components/base/portal-to-follow-elem' import ToolTrigger from '@/app/components/plugins/plugin-detail-panel/tool-selector/tool-trigger' +import ToolItem from '@/app/components/plugins/plugin-detail-panel/tool-selector/tool-item' import ToolPicker from '@/app/components/workflow/block-selector/tool-picker' import Button from '@/app/components/base/button' import Indicator from '@/app/components/header/indicator' @@ -54,6 +56,7 @@ type Props = { parameters?: Record extra?: Record }) => void + onDelete?: () => void supportAddCustomTool?: boolean scope?: string } @@ -63,6 +66,7 @@ const ToolSelector: FC = ({ placement = 'left', offset = 4, onSelect, + onDelete, scope, }) => { const { t } = useTranslation() @@ -155,12 +159,33 @@ const ToolSelector: FC = ({ className='w-full' onClick={handleTriggerClick} > - + {!value?.provider_name && ( + + )} + {value?.provider_name && ( + setShowSettingAuth(true)} + // uninstalled + errorTip={
+

{t('workflow.nodes.agent.pluginNotInstalled')}

+

{t('workflow.nodes.agent.pluginNotInstalledDesc')}

+

+ {t('workflow.nodes.agent.linkToPlugin')} +

+
} + /> + )}
diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/tool-item.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/tool-item.tsx new file mode 100644 index 0000000000..a20e0d6e6f --- /dev/null +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/tool-item.tsx @@ -0,0 +1,120 @@ +'use client' +import React, { useState } from 'react' +import { useTranslation } from 'react-i18next' +import { + RiDeleteBinLine, + RiEqualizer2Line, + RiErrorWarningFill, +} from '@remixicon/react' +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 ( +
+
+ {typeof icon === 'string' &&
} + {typeof icon !== 'string' && } +
+
+
{providerNameText}
+
{toolName}
+
+
+ {!noAuth && !isError && !uninstalled && ( + + + + )} +
setIsDeleting(true)} + onMouseLeave={() => setIsDeleting(false)} + > + +
+
+ {!isError && !uninstalled && !noAuth && showSwitch && ( + + )} + {!isError && !uninstalled && noAuth && ( + + )} + {!isError && uninstalled && ( + { + e.stopPropagation() + onInstall?.() + }} /> + )} + {isError && ( + +
+ +
+
+ )} +
+ ) +} + +export default ToolItem