Hide API Key and Plugin Key buttons if set server side (#423)

This commit is contained in:
itbm 2023-04-04 23:53:10 +01:00 committed by GitHub
parent d324df1bab
commit fc60f65c74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions

View File

@ -17,7 +17,9 @@ interface Props {
lightMode: 'light' | 'dark'; lightMode: 'light' | 'dark';
selectedConversation: Conversation; selectedConversation: Conversation;
apiKey: string; apiKey: string;
serverSideApiKeyIsSet: boolean;
pluginKeys: PluginKey[]; pluginKeys: PluginKey[];
serverSidePluginKeysSet: boolean;
folders: Folder[]; folders: Folder[];
onCreateFolder: (name: string) => void; onCreateFolder: (name: string) => void;
onDeleteFolder: (folderId: string) => void; onDeleteFolder: (folderId: string) => void;
@ -44,7 +46,9 @@ export const Chatbar: FC<Props> = ({
lightMode, lightMode,
selectedConversation, selectedConversation,
apiKey, apiKey,
serverSideApiKeyIsSet,
pluginKeys, pluginKeys,
serverSidePluginKeysSet,
folders, folders,
onCreateFolder, onCreateFolder,
onDeleteFolder, onDeleteFolder,
@ -198,7 +202,9 @@ export const Chatbar: FC<Props> = ({
<ChatbarSettings <ChatbarSettings
lightMode={lightMode} lightMode={lightMode}
apiKey={apiKey} apiKey={apiKey}
serverSideApiKeyIsSet={serverSideApiKeyIsSet}
pluginKeys={pluginKeys} pluginKeys={pluginKeys}
serverSidePluginKeysSet={serverSidePluginKeysSet}
conversationsCount={conversations.length} conversationsCount={conversations.length}
onToggleLightMode={onToggleLightMode} onToggleLightMode={onToggleLightMode}
onApiKeyChange={onApiKeyChange} onApiKeyChange={onApiKeyChange}

View File

@ -12,7 +12,9 @@ import { PluginKeys } from './PluginKeys';
interface Props { interface Props {
lightMode: 'light' | 'dark'; lightMode: 'light' | 'dark';
apiKey: string; apiKey: string;
serverSideApiKeyIsSet: boolean;
pluginKeys: PluginKey[]; pluginKeys: PluginKey[];
serverSidePluginKeysSet: boolean;
conversationsCount: number; conversationsCount: number;
onToggleLightMode: (mode: 'light' | 'dark') => void; onToggleLightMode: (mode: 'light' | 'dark') => void;
onApiKeyChange: (apiKey: string) => void; onApiKeyChange: (apiKey: string) => void;
@ -26,7 +28,9 @@ interface Props {
export const ChatbarSettings: FC<Props> = ({ export const ChatbarSettings: FC<Props> = ({
lightMode, lightMode,
apiKey, apiKey,
serverSideApiKeyIsSet,
pluginKeys, pluginKeys,
serverSidePluginKeysSet,
conversationsCount, conversationsCount,
onToggleLightMode, onToggleLightMode,
onApiKeyChange, onApiKeyChange,
@ -62,13 +66,17 @@ export const ChatbarSettings: FC<Props> = ({
} }
/> />
{!(serverSideApiKeyIsSet) ? (
<Key apiKey={apiKey} onApiKeyChange={onApiKeyChange} /> <Key apiKey={apiKey} onApiKeyChange={onApiKeyChange} />
) : null}
{!(serverSidePluginKeysSet) ? (
<PluginKeys <PluginKeys
pluginKeys={pluginKeys} pluginKeys={pluginKeys}
onPluginKeyChange={onPluginKeyChange} onPluginKeyChange={onPluginKeyChange}
onClearPluginKey={onClearPluginKey} onClearPluginKey={onClearPluginKey}
/> />
) : null}
</div> </div>
); );
}; };

View File

@ -763,7 +763,9 @@ const Home: React.FC<HomeProps> = ({
lightMode={lightMode} lightMode={lightMode}
selectedConversation={selectedConversation} selectedConversation={selectedConversation}
apiKey={apiKey} apiKey={apiKey}
serverSideApiKeyIsSet={serverSideApiKeyIsSet}
pluginKeys={pluginKeys} pluginKeys={pluginKeys}
serverSidePluginKeysSet={serverSidePluginKeysSet}
folders={folders.filter((folder) => folder.type === 'chat')} folders={folders.filter((folder) => folder.type === 'chat')}
onToggleLightMode={handleLightMode} onToggleLightMode={handleLightMode}
onCreateFolder={(name) => handleCreateFolder(name, 'chat')} onCreateFolder={(name) => handleCreateFolder(name, 'chat')}