diff --git a/web/app/components/plugins/plugin-auth/plugin-auth.tsx b/web/app/components/plugins/plugin-auth/plugin-auth.tsx index 0d34fcefc9..b9bd7339da 100644 --- a/web/app/components/plugins/plugin-auth/plugin-auth.tsx +++ b/web/app/components/plugins/plugin-auth/plugin-auth.tsx @@ -20,6 +20,7 @@ import { PortalToFollowElemContent, PortalToFollowElemTrigger, } from '@/app/components/base/portal-to-follow-elem' +import { SimpleSelect } from '@/app/components/base/select' import Authorize from './authorize' import Authorized from './authorized' import AddApiKeyButton from './authorize/add-api-key-button' @@ -63,7 +64,6 @@ const PluginAuth = ({ const shouldShowGuide = !!showConnectGuide const [showCredentialPanel, setShowCredentialPanel] = useState(false) const [showAddMenu, setShowAddMenu] = useState(false) - const [showEndUserTypeMenu, setShowEndUserTypeMenu] = useState(false) const configuredDisabled = !!endUserCredentialEnabled const availableEndUserTypes = useMemo(() => { const list: { value: string; label: string; icon: ReactNode }[] = [] @@ -89,10 +89,8 @@ const PluginAuth = ({ }, [availableEndUserTypes, endUserCredentialType]) useEffect(() => { - if (!endUserCredentialEnabled) { - setShowEndUserTypeMenu(false) + if (!endUserCredentialEnabled) return - } if (!availableEndUserTypes.length) return const isValid = availableEndUserTypes.some(item => item.value === endUserCredentialType) @@ -102,7 +100,6 @@ const PluginAuth = ({ const handleSelectEndUserType = useCallback((value: string) => { onEndUserCredentialTypeChange?.(value) - setShowEndUserTypeMenu(false) }, [onEndUserCredentialTypeChange]) const containerClassName = useMemo(() => { if (showConnectGuide) @@ -142,15 +139,18 @@ const PluginAuth = ({ }, [credentials, t]) const endUserSwitch = ( -
-
-
- -
-
-
-
- {t('plugin.auth.endUserCredentials.title')} +
+
+ +
+
+
+
+ {t('plugin.auth.endUserCredentials.title')} +
+
+ {t('plugin.auth.endUserCredentials.desc')} +
-
- {t('plugin.auth.endUserCredentials.desc')} -
{ endUserCredentialEnabled && availableEndUserTypes.length > 0 && ( -
-
+
+
{t('plugin.auth.endUserCredentials.typeLabel')}
- - + ({ + value: item.value, + name: item.label, + icon: item.icon, + }))} + defaultValue={endUserCredentialType || availableEndUserTypes[0]?.value} + disabled={disabled} + onSelect={item => handleSelectEndUserType(item.value as string)} + renderTrigger={(value, open) => ( - - -
-
- {availableEndUserTypes.map(item => ( - - ))} + )} + renderOption={({ item, selected }) => ( +
+
+ {item.icon} + {item.name}
+ {selected && }
- - + )} + optionWrapClassName='p-1' + optionClassName='px-3 py-2 rounded-lg' + hideChecked + />
) } @@ -323,19 +316,21 @@ const PluginAuth = ({ { credentials.length === 0 && (
- +
+ +
) }