From 697baceb5f3fe68ab72e4b1a512609ff4c8a8c17 Mon Sep 17 00:00:00 2001 From: Cole Goldsmith Date: Wed, 19 Nov 2025 13:16:59 -0600 Subject: [PATCH] format --- .../_components/anthropic-settings-dialog.tsx | 267 +++++++++--------- .../_components/ollama-settings-dialog.tsx | 2 +- .../_components/openai-settings-dialog.tsx | 2 +- .../_components/watsonx-settings-dialog.tsx | 4 +- frontend/app/settings/page.tsx | 11 +- 5 files changed, 146 insertions(+), 140 deletions(-) diff --git a/frontend/app/settings/_components/anthropic-settings-dialog.tsx b/frontend/app/settings/_components/anthropic-settings-dialog.tsx index 189d8afe..131515f1 100644 --- a/frontend/app/settings/_components/anthropic-settings-dialog.tsx +++ b/frontend/app/settings/_components/anthropic-settings-dialog.tsx @@ -9,162 +9,161 @@ import type { ProviderHealthResponse } from "@/app/api/queries/useProviderHealth import AnthropicLogo from "@/components/icons/anthropic-logo"; import { Button } from "@/components/ui/button"; import { - Dialog, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, } from "@/components/ui/dialog"; import { - AnthropicSettingsForm, - type AnthropicSettingsFormData, + AnthropicSettingsForm, + type AnthropicSettingsFormData, } from "./anthropic-settings-form"; import { useRouter } from "next/navigation"; const AnthropicSettingsDialog = ({ - open, - setOpen, + open, + setOpen, }: { - open: boolean; - setOpen: (open: boolean) => void; + open: boolean; + setOpen: (open: boolean) => void; }) => { - const queryClient = useQueryClient(); - const [isValidating, setIsValidating] = useState(false); - const [validationError, setValidationError] = useState(null); - const router = useRouter(); + const queryClient = useQueryClient(); + const [isValidating, setIsValidating] = useState(false); + const [validationError, setValidationError] = useState(null); + const router = useRouter(); - const methods = useForm({ - mode: "onSubmit", - defaultValues: { - apiKey: "", - }, - }); + const methods = useForm({ + mode: "onSubmit", + defaultValues: { + apiKey: "", + }, + }); - const { handleSubmit, watch } = methods; - const apiKey = watch("apiKey"); + const { handleSubmit, watch } = methods; + const apiKey = watch("apiKey"); - const { refetch: validateCredentials } = useGetAnthropicModelsQuery( - { - apiKey: apiKey, - }, - { - enabled: false, - }, - ); + const { refetch: validateCredentials } = useGetAnthropicModelsQuery( + { + apiKey: apiKey, + }, + { + enabled: false, + }, + ); - const settingsMutation = useUpdateSettingsMutation({ - onSuccess: () => { - // Update provider health cache to healthy since backend validated the setup - const healthData: ProviderHealthResponse = { - status: "healthy", - message: "Provider is configured and working correctly", - provider: "anthropic", - }; - queryClient.setQueryData(["provider", "health"], healthData); + const settingsMutation = useUpdateSettingsMutation({ + onSuccess: () => { + // Update provider health cache to healthy since backend validated the setup + const healthData: ProviderHealthResponse = { + status: "healthy", + message: "Provider is configured and working correctly", + provider: "anthropic", + }; + queryClient.setQueryData(["provider", "health"], healthData); - toast.message("Anthropic successfully configured", { - description: - "You can now access the provided language models.", - duration: Infinity, - closeButton: true, - icon: , - action: { - label: "Settings", - onClick: () => { - router.push("/settings"); - }, - }, - }); - setOpen(false); - }, - }); + toast.message("Anthropic successfully configured", { + description: "You can now access the provided language models.", + duration: Infinity, + closeButton: true, + icon: , + action: { + label: "Settings", + onClick: () => { + router.push("/settings"); + }, + }, + }); + setOpen(false); + }, + }); - const onSubmit = async (data: AnthropicSettingsFormData) => { - // Clear any previous validation errors - setValidationError(null); + const onSubmit = async (data: AnthropicSettingsFormData) => { + // Clear any previous validation errors + setValidationError(null); - // Only validate if a new API key was entered - if (data.apiKey) { - setIsValidating(true); - const result = await validateCredentials(); - setIsValidating(false); + // Only validate if a new API key was entered + if (data.apiKey) { + setIsValidating(true); + const result = await validateCredentials(); + setIsValidating(false); - if (result.isError) { - setValidationError(result.error); - return; - } - } + if (result.isError) { + setValidationError(result.error); + return; + } + } - const payload: { - anthropic_api_key?: string; - } = {}; + const payload: { + anthropic_api_key?: string; + } = {}; - // Only include api_key if a value was entered - if (data.apiKey) { - payload.anthropic_api_key = data.apiKey; - } + // Only include api_key if a value was entered + if (data.apiKey) { + payload.anthropic_api_key = data.apiKey; + } - // Submit the update - settingsMutation.mutate(payload); - }; + // Submit the update + settingsMutation.mutate(payload); + }; - return ( - - - -
- - -
- -
- Anthropic Setup -
-
+ return ( + + + + + + +
+ +
+ Anthropic Setup +
+
- + - - {settingsMutation.isError && ( - -

- {settingsMutation.error?.message} -

-
- )} -
- - - - - -
-
-
- ); + + {settingsMutation.isError && ( + +

+ {settingsMutation.error?.message} +

+
+ )} +
+ + + + + +
+
+
+ ); }; export default AnthropicSettingsDialog; diff --git a/frontend/app/settings/_components/ollama-settings-dialog.tsx b/frontend/app/settings/_components/ollama-settings-dialog.tsx index 90a1f580..ef47c859 100644 --- a/frontend/app/settings/_components/ollama-settings-dialog.tsx +++ b/frontend/app/settings/_components/ollama-settings-dialog.tsx @@ -35,7 +35,7 @@ const OllamaSettingsDialog = ({ const [isValidating, setIsValidating] = useState(false); const [validationError, setValidationError] = useState(null); const router = useRouter(); - + const { data: settings = {} } = useGetSettingsQuery({ enabled: isAuthenticated || isNoAuthMode, }); diff --git a/frontend/app/settings/_components/openai-settings-dialog.tsx b/frontend/app/settings/_components/openai-settings-dialog.tsx index 1bb57df3..7def5795 100644 --- a/frontend/app/settings/_components/openai-settings-dialog.tsx +++ b/frontend/app/settings/_components/openai-settings-dialog.tsx @@ -32,7 +32,7 @@ const OpenAISettingsDialog = ({ const [isValidating, setIsValidating] = useState(false); const [validationError, setValidationError] = useState(null); const router = useRouter(); - + const methods = useForm({ mode: "onSubmit", defaultValues: { diff --git a/frontend/app/settings/_components/watsonx-settings-dialog.tsx b/frontend/app/settings/_components/watsonx-settings-dialog.tsx index fb9b62f7..1d69e64b 100644 --- a/frontend/app/settings/_components/watsonx-settings-dialog.tsx +++ b/frontend/app/settings/_components/watsonx-settings-dialog.tsx @@ -32,7 +32,7 @@ const WatsonxSettingsDialog = ({ const [isValidating, setIsValidating] = useState(false); const [validationError, setValidationError] = useState(null); const router = useRouter(); - + const methods = useForm({ mode: "onSubmit", defaultValues: { @@ -67,7 +67,7 @@ const WatsonxSettingsDialog = ({ provider: "watsonx", }; queryClient.setQueryData(["provider", "health"], healthData); - + toast.message("IBM watsonx.ai successfully configured", { description: "You can now access the provided language and embedding models.", diff --git a/frontend/app/settings/page.tsx b/frontend/app/settings/page.tsx index d81f204d..ca8158a8 100644 --- a/frontend/app/settings/page.tsx +++ b/frontend/app/settings/page.tsx @@ -785,7 +785,12 @@ function KnowledgeSourcesPage() {
{connector.icon}
@@ -794,7 +799,9 @@ function KnowledgeSourcesPage() { {connector.name} - {connector?.available ? `${connector.name} is configured.` : "Not configured."} + {connector?.available + ? `${connector.name} is configured.` + : "Not configured."}