From 45ef4059f0d37b2eb3f39de0e0f446ac36da92be Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Thu, 7 Mar 2024 11:48:42 +0800 Subject: [PATCH] block-icon --- web/app/components/workflow/block-icon.tsx | 34 ++++++++++++++- .../workflow/block-selector/tools/item.tsx | 1 + .../workflow/block-selector/types.ts | 1 + .../_base/components/next-step/index.tsx | 5 ++- .../nodes/_base/components/next-step/item.tsx | 1 + .../components/workflow/nodes/_base/node.tsx | 42 +++---------------- .../components/workflow/nodes/_base/panel.tsx | 41 +++--------------- 7 files changed, 52 insertions(+), 73 deletions(-) diff --git a/web/app/components/workflow/block-icon.tsx b/web/app/components/workflow/block-icon.tsx index 21fd624fe8..e17975a601 100644 --- a/web/app/components/workflow/block-icon.tsx +++ b/web/app/components/workflow/block-icon.tsx @@ -14,11 +14,13 @@ import { TemplatingTransform, VariableX, } from '@/app/components/base/icons/src/vender/workflow' +import AppIcon from '@/app/components/base/app-icon' type BlockIconProps = { type: BlockEnum size?: string className?: string + icon?: any } const ICON_CONTAINER_CLASSNAME_SIZE_MAP: Record = { sm: 'w-5 h-5 rounded-md shadow-xs', @@ -57,6 +59,7 @@ const BlockIcon: FC = ({ type, size = 'sm', className, + icon, }) => { return (
= ({ ${className} `} > - {getIcon(type, 'w-3.5 h-3.5')} + { + type !== BlockEnum.Tool && ( + getIcon(type, 'w-3.5 h-3.5') + ) + } + { + type === BlockEnum.Tool && icon && ( + <> + { + typeof icon === 'string' + ? ( +
+ ) + : ( + + ) + } + + ) + }
) } diff --git a/web/app/components/workflow/block-selector/tools/item.tsx b/web/app/components/workflow/block-selector/tools/item.tsx index dd5f317a0c..3cef90c33e 100644 --- a/web/app/components/workflow/block-selector/tools/item.tsx +++ b/web/app/components/workflow/block-selector/tools/item.tsx @@ -107,6 +107,7 @@ const Item = ({ tool_name: tool.name, _icon: data.icon, title: tool.label[language], + desc: tool.description[language], })} >
diff --git a/web/app/components/workflow/block-selector/types.ts b/web/app/components/workflow/block-selector/types.ts index c1e543d94f..09fe34c87c 100644 --- a/web/app/components/workflow/block-selector/types.ts +++ b/web/app/components/workflow/block-selector/types.ts @@ -30,5 +30,6 @@ export type ToolDefaultValue = { provider_type: string tool_name: string title: string + desc: string _icon: Collection['icon'] } diff --git a/web/app/components/workflow/nodes/_base/components/next-step/index.tsx b/web/app/components/workflow/nodes/_base/components/next-step/index.tsx index 3d4246022f..34c3e68587 100644 --- a/web/app/components/workflow/nodes/_base/components/next-step/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/next-step/index.tsx @@ -26,7 +26,10 @@ const NextStep = ({ return (
- +
diff --git a/web/app/components/workflow/nodes/_base/components/next-step/item.tsx b/web/app/components/workflow/nodes/_base/components/next-step/item.tsx index 576e25cbac..f88a9c8c33 100644 --- a/web/app/components/workflow/nodes/_base/components/next-step/item.tsx +++ b/web/app/components/workflow/nodes/_base/components/next-step/item.tsx @@ -53,6 +53,7 @@ const Item = ({ }
{data.title}
diff --git a/web/app/components/workflow/nodes/_base/node.tsx b/web/app/components/workflow/nodes/_base/node.tsx index 15c8b0951b..2d1725c424 100644 --- a/web/app/components/workflow/nodes/_base/node.tsx +++ b/web/app/components/workflow/nodes/_base/node.tsx @@ -7,9 +7,7 @@ import { memo, } from 'react' import type { NodeProps } from '../../types' -import { BlockEnum } from '@/app/components/workflow/types' import BlockIcon from '@/app/components/workflow/block-icon' -import AppIcon from '@/app/components/base/app-icon' type BaseNodeProps = { children: ReactElement @@ -31,40 +29,12 @@ const BaseNode: FC = ({ `} >
- { - type !== BlockEnum.Tool && ( - - ) - } - { - type === BlockEnum.Tool && ( - <> - { - typeof data._icon === 'string' - ? ( -
- ) - : ( - - ) - } - - ) - } +
= ({
- { - type !== BlockEnum.Tool && ( - - ) - } - { - type === BlockEnum.Tool && ( - <> - { - typeof data._icon === 'string' - ? ( -
- ) - : ( - - ) - } - - ) - } +