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 43ce78476e..804bee0157 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 @@ -3,6 +3,7 @@ import type { PluginDetail } from '@/app/components/plugins/types' import type { Emoji } from '@/app/components/tools/types' import type { ToolValue } from '@/app/components/workflow/block-selector/types' import type { ToolWithProvider } from '@/app/components/workflow/types' +import { RiAlertFill } from '@remixicon/react' import * as React from 'react' import { useEffect, useMemo, useState } from 'react' import { createPortal } from 'react-dom' @@ -118,6 +119,7 @@ const ToolBlockComponent: FC = ({ const [ref, isSelected] = useSelectOrDelete(nodeKey, DELETE_TOOL_BLOCK_COMMAND) const language = useGetLanguage() const { t } = useTranslation() + const authBadgeLabel = t('skillEditor.authorizationBadge', { ns: 'workflow' }) const { theme } = useTheme() const toolBlockContext = useToolBlockContext() const isUsingExternalMetadata = Boolean(toolBlockContext?.onMetadataChange) @@ -315,33 +317,46 @@ const ToolBlockComponent: FC = ({ return normalizeProviderIcon(fromMeta) })() + const needAuthorization = useMemo(() => { + return !currentProvider?.is_team_authorization + }, [currentProvider]) + const renderIcon = () => { if (!resolvedIcon) return null - if (typeof resolvedIcon === 'string') { - if (resolvedIcon.startsWith('http') || resolvedIcon.startsWith('/')) { + const iconNode = (() => { + if (typeof resolvedIcon === 'string') { + if (resolvedIcon.startsWith('http') || resolvedIcon.startsWith('/')) { + return ( + + ) + } return ( - ) } return ( ) - } + })() + if (!needAuthorization) + return iconNode return ( - + + {iconNode} + ) } @@ -452,9 +467,6 @@ const ToolBlockComponent: FC = ({ storeApi.getState().pinTab(activeTabId) } - const needAuthorization = useMemo(() => { - return !currentProvider?.is_team_authorization - }, [currentProvider]) const readmeEntrance = useMemo(() => { if (!currentProvider) return null @@ -502,7 +514,8 @@ const ToolBlockComponent: FC = ({ = ({ }} > {renderIcon()} - + {displayLabel} + {needAuthorization && ( + + {authBadgeLabel} + + + )} {useModal && ( = ({ }) => { const [ref, isSelected] = useSelectOrDelete(nodeKey, DELETE_TOOL_BLOCK_COMMAND) const { t } = useTranslation() + const authBadgeLabel = t('skillEditor.authorizationBadge', { ns: 'workflow' }) const language = useGetLanguage() const { theme } = useTheme() const toolBlockContext = useToolBlockContext() @@ -506,30 +507,39 @@ const ToolGroupBlockComponent: FC = ({ const renderIcon = () => { if (!resolvedIcon) return null - if (typeof resolvedIcon === 'string') { - if (resolvedIcon.startsWith('http') || resolvedIcon.startsWith('/')) { + const iconNode = (() => { + if (typeof resolvedIcon === 'string') { + if (resolvedIcon.startsWith('http') || resolvedIcon.startsWith('/')) { + return ( + + ) + } return ( - ) } return ( ) - } + })() + if (!needAuthorization) + return iconNode return ( - + + {iconNode} + ) } @@ -768,7 +778,8 @@ const ToolGroupBlockComponent: FC = ({ = ({ }} > {renderIcon()} - + {providerLabel} - - {displayEnabledCount} - + {needAuthorization + ? ( + + {authBadgeLabel} + + + ) + : ( + + {displayEnabledCount} + + )} {useModal && (