diff --git a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx index ad5dcc8a28..4b3b76b577 100644 --- a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx +++ b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx @@ -5,7 +5,6 @@ import type { ToolWithProvider } from '@/app/components/workflow/types' import * as React from 'react' import { useEffect, useMemo, useState } from 'react' import { createPortal } from 'react-dom' -import { useTranslation } from 'react-i18next' import AppIcon from '@/app/components/base/app-icon' import { useSelectOrDelete } from '@/app/components/base/prompt-editor/hooks' import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' @@ -28,6 +27,7 @@ import { canFindTool } from '@/utils' import { cn } from '@/utils/classnames' import { basePath } from '@/utils/var' import { DELETE_TOOL_BLOCK_COMMAND } from './index' +import ToolHeader from './tool-header' type ToolBlockComponentProps = { nodeKey: string @@ -85,7 +85,6 @@ const ToolBlockComponent: FC = ({ }) => { const [ref, isSelected] = useSelectOrDelete(nodeKey, DELETE_TOOL_BLOCK_COMMAND) const language = useGetLanguage() - const { t } = useTranslation() const { theme } = useTheme() const [isSettingOpen, setIsSettingOpen] = useState(false) const [toolValue, setToolValue] = useState(null) @@ -127,6 +126,17 @@ const ToolBlockComponent: FC = ({ } }, [currentProvider, currentTool, language, tool]) + const toolDescriptionText = useMemo(() => { + if (toolValue?.tool_description) + return toolValue.tool_description + if (currentTool?.description) { + return typeof currentTool.description === 'object' + ? (currentTool.description?.[language] || '') + : (currentTool.description || '') + } + return '' + }, [currentTool?.description, language, toolValue?.tool_description]) + const toolConfigFromMetadata = useMemo(() => { if (!activeTabId) return undefined @@ -345,14 +355,19 @@ const ToolBlockComponent: FC = ({ {portalContainer && isSettingOpen && createPortal(
-
-
{t('detailPanel.toolSelector.toolSetting', { ns: 'plugin' })}
+
{currentProvider && currentTool && toolValue && ( <> -
{displayLabel}
+ setIsSettingOpen(false)} + /> void +} + +const ToolHeader: FC = ({ + icon, + providerLabel, + toolLabel, + description, + onClose, +}) => { + const renderHeaderIcon = () => { + if (!icon) + return null + if (typeof icon === 'string') { + if (icon.startsWith('http') || icon.startsWith('/')) { + return ( + + + + ) + } + return ( + + ) + } + return ( + + ) + } + + return ( + <> +
+
+
+ {renderHeaderIcon()} + + {providerLabel} + +
+
+
+ + +
+
+
+
+ {toolLabel} +
+
+ {description} +
+
+ + ) +} + +export default ToolHeader