From 3c463c1e3a65a27e599ed83b256970ddbb9e4da4 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 10 Sep 2025 15:49:49 +0800 Subject: [PATCH 1/7] fix: credential in tool node & switch credential in load balancing --- .../switch-credential-in-load-balancing.tsx | 41 +++++++++++-------- .../plugin-auth/authorized-in-node.tsx | 20 ++++++++- web/i18n/en-US/plugin.ts | 1 + web/i18n/zh-Hans/plugin.ts | 1 + 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/switch-credential-in-load-balancing.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/switch-credential-in-load-balancing.tsx index 6ca120aea6..5d2da57adb 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/switch-credential-in-load-balancing.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/switch-credential-in-load-balancing.tsx @@ -37,51 +37,57 @@ const SwitchCredentialInLoadBalancing = ({ onRemove, }: SwitchCredentialInLoadBalancingProps) => { const { t } = useTranslation() - + const notAllowCustomCredential = provider.allow_custom_token === false const handleItemClick = useCallback((credential: Credential) => { setCustomModelCredential(credential) }, [setCustomModelCredential]) const renderTrigger = useCallback(() => { const selectedCredentialId = customModelCredential?.credential_id - const authRemoved = !selectedCredentialId && !!credentials?.length + const currentCredential = credentials?.find(c => c.credential_id === selectedCredentialId) + const empty = !credentials?.length + const authRemoved = selectedCredentialId && !currentCredential && !empty + const unavailable = currentCredential?.not_allowed_to_use + let color = 'green' - if (authRemoved && !customModelCredential?.not_allowed_to_use) + if (authRemoved || unavailable) color = 'red' - if (customModelCredential?.not_allowed_to_use) - color = 'gray' const Item = ( ) - if (customModelCredential?.not_allowed_to_use) { + if (empty && notAllowCustomCredential) { return ( ) } diff --git a/web/app/components/plugins/plugin-auth/authorized-in-node.tsx b/web/app/components/plugins/plugin-auth/authorized-in-node.tsx index 79eef66451..60297094c3 100644 --- a/web/app/components/plugins/plugin-auth/authorized-in-node.tsx +++ b/web/app/components/plugins/plugin-auth/authorized-in-node.tsx @@ -36,14 +36,22 @@ const AuthorizedInNode = ({ disabled, invalidPluginCredentialInfo, notAllowCustomCredential, - } = usePluginAuth(pluginPayload, isOpen || !!credentialId) + } = usePluginAuth(pluginPayload, true) const renderTrigger = useCallback((open?: boolean) => { let label = '' let removed = false let unavailable = false let color = 'green' + let defaultUnavailable = false if (!credentialId) { label = t('plugin.auth.workspaceDefault') + + const defaultCredential = credentials.find(c => c.is_default) + + if (defaultCredential?.not_allowed_to_use) { + color = 'gray' + defaultUnavailable = true + } } else { const credential = credentials.find(c => c.id === credentialId) @@ -63,6 +71,7 @@ const AuthorizedInNode = ({ open && !removed && 'bg-components-button-ghost-bg-hover', removed && 'bg-transparent text-text-destructive', )} + variant={(defaultUnavailable || unavailable) ? 'ghost' : 'secondary'} > {label} { - unavailable && t('plugin.auth.unavailable') + (unavailable || defaultUnavailable) && ( + <> +   + {t('plugin.auth.unavailable')} + + ) } ) }, [credentialId, credentials, t]) + const defaultUnavailable = credentials.find(c => c.is_default)?.not_allowed_to_use const extraAuthorizationItems: Credential[] = [ { id: '__workspace_default__', @@ -88,6 +103,7 @@ const AuthorizedInNode = ({ provider: '', is_default: !credentialId, isWorkspaceDefault: true, + not_allowed_to_use: defaultUnavailable, }, ] const handleAuthorizationItemClick = useCallback((id: string) => { diff --git a/web/i18n/en-US/plugin.ts b/web/i18n/en-US/plugin.ts index 85bbd44bd5..9ac1a7baa0 100644 --- a/web/i18n/en-US/plugin.ts +++ b/web/i18n/en-US/plugin.ts @@ -298,6 +298,7 @@ const translation = { clientInfo: 'As no system client secrets found for this tool provider, setup it manually is required, for redirect_uri, please use', oauthClient: 'OAuth Client', credentialUnavailable: 'Credentials currently unavailable. Please contact admin.', + credentialUnavailableInButton: 'Credential unavailable', customCredentialUnavailable: 'Custom credentials currently unavailable', unavailable: 'Unavailable', }, diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts index e37de6d69f..d815eb9fae 100644 --- a/web/i18n/zh-Hans/plugin.ts +++ b/web/i18n/zh-Hans/plugin.ts @@ -298,6 +298,7 @@ const translation = { clientInfo: '由于未找到此工具提供者的系统客户端密钥,因此需要手动设置,对于 redirect_uri,请使用', oauthClient: 'OAuth 客户端', credentialUnavailable: '自定义凭据当前不可用,请联系管理员。', + credentialUnavailableInButton: '凭据不可用', customCredentialUnavailable: '自定义凭据当前不可用', unavailable: '不可用', }, From ba1a20ee59189cffbee56b0a88c7091560024ff2 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 10 Sep 2025 17:47:31 +0800 Subject: [PATCH 2/7] fix: help url in model modal --- .../model-provider-page/model-modal/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx index 4ffbc8f191..ccf742bb2d 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx @@ -376,16 +376,16 @@ const ModelModal: FC = ({ !provider.help.url && e.preventDefault()} > {provider.help.title?.[language] || provider.help.url[language] || provider.help.title?.en_US || provider.help.url.en_US} - + ) :
} -
+
{ isEditMode && (