diff --git a/client/src/components/Nav/Settings.spec.tsx b/client/src/components/Nav/Settings.spec.tsx index 6472d4ff57..20faef2191 100644 --- a/client/src/components/Nav/Settings.spec.tsx +++ b/client/src/components/Nav/Settings.spec.tsx @@ -101,6 +101,16 @@ describe('Settings', () => { expect(screen.getByText('com_nav_setting_api_keys')).toBeInTheDocument(); }); + it('hides the API Keys tab for endpoints with a user-provided baseURL but a fixed API key', () => { + mockUseGetEndpointsQuery.mockReturnValue({ + data: { LiteLLM: { userProvide: false, userProvideURL: true, order: 0 } }, + }); + + renderSettings(); + + expect(screen.queryByText('com_nav_setting_api_keys')).not.toBeInTheDocument(); + }); + it('resets the active tab when loaded config disables About', async () => { const user = userEvent.setup(); const { rerender } = renderSettings(); diff --git a/client/src/components/Nav/Settings.tsx b/client/src/components/Nav/Settings.tsx index 2f49229042..94b863be61 100644 --- a/client/src/components/Nav/Settings.tsx +++ b/client/src/components/Nav/Settings.tsx @@ -24,6 +24,7 @@ import { APIKeys, About, } from './SettingsTabs'; +import { isUserProvidedEndpointConfig } from './SettingsTabs/APIKeys/utils'; import usePersonalizationAccess from '~/hooks/usePersonalizationAccess'; import { useLocalize, TranslationKeys } from '~/hooks'; import { useGetEndpointsQuery, useGetStartupConfig } from '~/data-provider'; @@ -45,18 +46,7 @@ export default function Settings({ open, onOpenChange }: TDialogProps) { } const values = Object.values(endpointsConfig); for (let i = 0; i < values.length; i++) { - const config = values[i]; - if (!config) { - continue; - } - if ( - config.userProvide || - config.userProvideURL || - config.userProvideAccessKeyId || - config.userProvideSecretAccessKey || - config.userProvideSessionToken || - config.userProvideBearerToken - ) { + if (isUserProvidedEndpointConfig(values[i])) { return true; } } diff --git a/client/src/components/Nav/SettingsTabs/APIKeys/APIKeyRow.tsx b/client/src/components/Nav/SettingsTabs/APIKeys/APIKeyRow.tsx index ce9619bb40..8f93a8a5a5 100644 --- a/client/src/components/Nav/SettingsTabs/APIKeys/APIKeyRow.tsx +++ b/client/src/components/Nav/SettingsTabs/APIKeys/APIKeyRow.tsx @@ -1,7 +1,7 @@ import React, { useMemo, useState } from 'react'; import { Button } from '@librechat/client'; import { alternateName, getEndpointField } from 'librechat-data-provider'; -import type { EModelEndpoint, TEndpointsConfig } from 'librechat-data-provider'; +import type { TEndpointsConfig } from 'librechat-data-provider'; import { SetKeyDialog } from '~/components/Input/SetKeyDialog'; import { icons } from '~/hooks/Endpoint/Icons'; import { useUserKey, useLocalize } from '~/hooks'; @@ -62,7 +62,7 @@ const APIKeyRow = ({ endpoint, endpointsConfig }: APIKeyRowProps) => { { + if (!config) { + return false; + } + return ( + !!config.userProvide || + !!config.userProvideAccessKeyId || + !!config.userProvideSecretAccessKey || + !!config.userProvideSessionToken || + !!config.userProvideBearerToken + ); +};