mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-02 16:19:27 +00:00
fix(websearch): narrow provider key handlers for build
This commit is contained in:
@@ -659,6 +659,7 @@ export default function WebSearchSection() {
|
|||||||
const enabled =
|
const enabled =
|
||||||
config?.providers?.[provider.id]?.enabled ?? provider.defaultEnabled;
|
config?.providers?.[provider.id]?.enabled ?? provider.defaultEnabled;
|
||||||
const tone = getStatusTone(currentStatus, enabled);
|
const tone = getStatusTone(currentStatus, enabled);
|
||||||
|
const apiKeyProviderId = isApiKeyProvider(provider.id) ? provider.id : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -693,7 +694,7 @@ export default function WebSearchSection() {
|
|||||||
}}
|
}}
|
||||||
fields={buildFields(provider)}
|
fields={buildFields(provider)}
|
||||||
>
|
>
|
||||||
{isApiKeyProvider(provider.id) && (
|
{apiKeyProviderId && (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<div>
|
<div>
|
||||||
@@ -718,15 +719,15 @@ export default function WebSearchSection() {
|
|||||||
|
|
||||||
<MaskedInput
|
<MaskedInput
|
||||||
id={`${provider.id}.api-key`}
|
id={`${provider.id}.api-key`}
|
||||||
value={apiKeyDrafts[provider.id] ?? ''}
|
value={apiKeyDrafts[apiKeyProviderId] ?? ''}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setApiKeyDrafts((current) => ({
|
setApiKeyDrafts((current) => ({
|
||||||
...current,
|
...current,
|
||||||
[provider.id]: event.target.value,
|
[apiKeyProviderId]: event.target.value,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
placeholder={
|
placeholder={
|
||||||
config?.apiKeys?.[provider.id]?.configured
|
config?.apiKeys?.[apiKeyProviderId]?.configured
|
||||||
? 'Enter a new key to rotate the stored secret'
|
? 'Enter a new key to rotate the stored secret'
|
||||||
: `Paste ${provider.badge}`
|
: `Paste ${provider.badge}`
|
||||||
}
|
}
|
||||||
@@ -738,24 +739,24 @@ export default function WebSearchSection() {
|
|||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
void saveApiKey(provider.id);
|
void saveApiKey(apiKeyProviderId);
|
||||||
}}
|
}}
|
||||||
disabled={
|
disabled={
|
||||||
saving || !(apiKeyDrafts[provider.id]?.trim() ?? '').length
|
saving || !(apiKeyDrafts[apiKeyProviderId]?.trim() ?? '').length
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{config?.apiKeys?.[provider.id]?.configured
|
{config?.apiKeys?.[apiKeyProviderId]?.configured
|
||||||
? 'Update key'
|
? 'Update key'
|
||||||
: 'Save key'}
|
: 'Save key'}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{(config?.apiKeys?.[provider.id]?.source === 'global_env' ||
|
{(config?.apiKeys?.[apiKeyProviderId]?.source === 'global_env' ||
|
||||||
config?.apiKeys?.[provider.id]?.source === 'both') && (
|
config?.apiKeys?.[apiKeyProviderId]?.source === 'both') && (
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
void removeApiKey(provider.id);
|
void removeApiKey(apiKeyProviderId);
|
||||||
}}
|
}}
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user