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: '不可用',
},