Skip to content

Commit 1c72f41

Browse files
committed
refactor(model-connections): update placeholder text for API key fields
1 parent c7409c8 commit 1c72f41

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

surfsense_web/components/settings/model-connections/bedrock-connect-form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ export function BedrockConnectForm({ onDraftChange }: ProviderConnectFormProps)
8787
<Input
8888
value={accessKeyId}
8989
onChange={(event) => setAccessKeyId(event.target.value)}
90-
placeholder="AKIAIOSFODNN7EXAMPLE"
90+
placeholder="Enter your AWS access key ID"
9191
/>
9292
</div>
9393
<ApiKeyField
9494
value={secretAccessKey}
9595
onChange={setSecretAccessKey}
9696
label="AWS Secret Access Key"
97-
placeholder="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
97+
placeholder="Enter your AWS secret access key"
9898
/>
9999
</>
100100
) : null}

surfsense_web/components/settings/model-connections/default-connect-form.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { useEffect, useState } from "react";
22
import { ApiBaseUrlField, ApiKeyField } from "./connect-fields";
33
import type { ProviderConnectFormProps } from "./provider-metadata";
44

5+
const OPTIONAL_API_KEY_PROVIDERS = new Set(["ollama_chat", "lm_studio", "openai_compatible"]);
6+
57
function baseUrlHint(provider: string) {
68
if (provider === "ollama_chat" || provider === "lm_studio") {
79
return "For local servers, use host.docker.internal instead of localhost.";
@@ -28,13 +30,14 @@ export function DefaultConnectForm({
2830
}: ProviderConnectFormProps) {
2931
const [baseUrl, setBaseUrl] = useState(defaultBaseUrl);
3032
const [apiKey, setApiKey] = useState("");
31-
const isOllama = provider === "ollama_chat";
33+
const isApiKeyOptional = OPTIONAL_API_KEY_PROVIDERS.has(provider);
3234
const hint = baseUrlHint(provider);
33-
const canSubmit = !(baseUrlRequired && !baseUrl.trim());
35+
const apiKeyValue = apiKey.trim();
36+
const canSubmit = !(baseUrlRequired && !baseUrl.trim()) && (isApiKeyOptional || Boolean(apiKeyValue));
3437

3538
useEffect(() => {
36-
onDraftChange({ base_url: baseUrl || null, api_key: apiKey || null, extra: {} }, canSubmit);
37-
}, [apiKey, baseUrl, canSubmit, onDraftChange]);
39+
onDraftChange({ base_url: baseUrl || null, api_key: apiKeyValue || null, extra: {} }, canSubmit);
40+
}, [apiKeyValue, baseUrl, canSubmit, onDraftChange]);
3841

3942
return (
4043
<div className="flex flex-col gap-4">
@@ -47,8 +50,8 @@ export function DefaultConnectForm({
4750
<ApiKeyField
4851
value={apiKey}
4952
onChange={setApiKey}
50-
label={isOllama ? "API Key (optional)" : "API Key"}
51-
placeholder={isOllama ? "Optional for Ollama" : "API key"}
53+
label={isApiKeyOptional ? "API Key (optional)" : "API Key"}
54+
placeholder="Enter your API key"
5255
/>
5356
</div>
5457
);

0 commit comments

Comments
 (0)