From e604fad630fa3b02802319d884270a6f26fbd5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Wed, 29 Jul 2026 10:07:57 +0800 Subject: [PATCH] fix(web): gate plugin auth permission hint (#39721) --- .../plugins/plugin-auth/__tests__/plugin-auth.spec.tsx | 1 + web/app/components/plugins/plugin-auth/plugin-auth.tsx | 3 +++ 2 files changed, 4 insertions(+) diff --git a/web/app/components/plugins/plugin-auth/__tests__/plugin-auth.spec.tsx b/web/app/components/plugins/plugin-auth/__tests__/plugin-auth.spec.tsx index 1423f3896d5..c7175a1ba76 100644 --- a/web/app/components/plugins/plugin-auth/__tests__/plugin-auth.spec.tsx +++ b/web/app/components/plugins/plugin-auth/__tests__/plugin-auth.spec.tsx @@ -68,6 +68,7 @@ describe('PluginAuth', () => { render() expect(screen.getByRole('button', { name: 'plugin.auth.useApiAuth' })).toBeEnabled() + expect(screen.queryByText('plugin.auth.permissionHint.title')).not.toBeInTheDocument() expect(screen.queryByTestId('authorized')).not.toBeInTheDocument() }) diff --git a/web/app/components/plugins/plugin-auth/plugin-auth.tsx b/web/app/components/plugins/plugin-auth/plugin-auth.tsx index 66441fa2d33..d84595809aa 100644 --- a/web/app/components/plugins/plugin-auth/plugin-auth.tsx +++ b/web/app/components/plugins/plugin-auth/plugin-auth.tsx @@ -4,6 +4,7 @@ import { memo } from 'react' import { useTranslation } from 'react-i18next' import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants' import { useModalContext } from '@/context/modal-context' +import { useCredentialPermissions } from '@/hooks/use-credential-permissions' import Authorize from './authorize' import Authorized from './authorized' import { usePluginAuth } from './hooks/use-plugin-auth' @@ -17,6 +18,7 @@ type PluginAuthProps = { const PluginAuth = ({ pluginPayload, children, className }: PluginAuthProps) => { const { t } = useTranslation() const { setShowAccountSettingModal } = useModalContext() + const { canCreateCredential } = useCredentialPermissions() const { isAuthorized, canOAuth, @@ -27,6 +29,7 @@ const PluginAuth = ({ pluginPayload, children, className }: PluginAuthProps) => } = usePluginAuth(pluginPayload, !!pluginPayload.provider) const showPermissionHint = !isAuthorized && + !canCreateCredential && !notAllowCustomCredential && pluginPayload.category === AuthCategory.tool && (canOAuth || canApiKey)