diff --git a/agenta-web/src/components/pages/settings/Secrets/Secrets.tsx b/agenta-web/src/components/pages/settings/Secrets/Secrets.tsx index 8571e2b00..218b291d3 100644 --- a/agenta-web/src/components/pages/settings/Secrets/Secrets.tsx +++ b/agenta-web/src/components/pages/settings/Secrets/Secrets.tsx @@ -8,12 +8,18 @@ const {Title, Text} = Typography export default function Secrets() { const {secrets, handleModifyVaultSecret, handleDeleteVaultSecret} = useVaultSecret() const [llmProviderKeys, setLlmProviderKeys] = useState([]) + const [loadingSecrets, setLoadingSecrets] = useState>({}) const [messageAPI, contextHolder] = message.useMessage() useEffect(() => { setLlmProviderKeys(secrets) }, [secrets]) + const setSecretLoading = (id: string | undefined, isLoading: boolean) => { + if (!id) return + setLoadingSecrets((prev) => ({...prev, [id]: isLoading})) + } + return (
{contextHolder} @@ -49,34 +55,45 @@ export default function Secrets() { data-cy="openai-api-save" type="primary" disabled={!key} + loading={loadingSecrets[secretId || ""] === true} onClick={async () => { - await handleModifyVaultSecret({ - name, - title, - key, - id: secretId, - }) - - messageAPI.success("The secret is saved") + if (!secretId) return + setSecretLoading(secretId, true) + try { + await handleModifyVaultSecret({ + name, + title, + key, + id: secretId, + }) + messageAPI.success("The secret is saved") + } finally { + setSecretLoading(secretId, false) + } }} > Save