From 0aa0541958aa3563ac5e30d05fcb230089dd07de Mon Sep 17 00:00:00 2001 From: oabrivard Date: Thu, 26 Mar 2026 09:35:26 +0100 Subject: [PATCH] refactor: standardize createResource and use Button component Convert LlmLogs from onMount+signals to createResource for idiomatic reactive data fetching. Replace duplicated inline save/add button markup in Settings and Sources with the shared Button component. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/LlmLogs.tsx | 29 ++++++++--------------------- frontend/src/pages/Settings.tsx | 17 +++++------------ frontend/src/pages/Sources.tsx | 17 +++++------------ 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/frontend/src/pages/LlmLogs.tsx b/frontend/src/pages/LlmLogs.tsx index b98d2a3..9288763 100644 --- a/frontend/src/pages/LlmLogs.tsx +++ b/frontend/src/pages/LlmLogs.tsx @@ -1,4 +1,4 @@ -import { type Component, createSignal, onMount, For, Show } from 'solid-js'; +import { type Component, createResource, For, Show } from 'solid-js'; import { useParams, A } from '@solidjs/router'; import { useI18n } from '~/i18n'; import { llmLogsApi } from '~/api/llmLogs'; @@ -36,20 +36,7 @@ const LlmLogs: Component = () => { const { t } = useI18n(); const params = useParams<{ jobId: string }>(); - const [logs, setLogs] = createSignal([]); - const [loading, setLoading] = createSignal(true); - const [error, setError] = createSignal(null); - - onMount(async () => { - try { - const data = await llmLogsApi.getByJobId(params.jobId); - setLogs(data); - } catch { - setError(t('common.error')); - } finally { - setLoading(false); - } - }); + const [logs] = createResource(() => params.jobId, llmLogsApi.getByJobId); return (
@@ -64,23 +51,23 @@ const LlmLogs: Component = () => {

{t('llmLogs.title')}

- }> - + }> +
- {error()} + {t('common.error')}
0} + when={(logs() ?? []).length > 0} fallback={ - +

{t('llmLogs.empty')}

} >
- + {(entry) => (
diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index c6f1751..3d54d33 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -8,6 +8,7 @@ import { createEffect, } from 'solid-js'; import { Settings as SettingsIcon, Save, Plus, Trash2, Info, Download, Upload } from 'lucide-solid'; +import Button from '~/components/ui/Button'; import { settingsApi } from '~/api/settings'; import { configApi } from '~/api/config'; import { apiKeysApi } from '~/api/apiKeys'; @@ -640,21 +641,13 @@ const Settings: Component = () => { {/* Save button */}
- +
diff --git a/frontend/src/pages/Sources.tsx b/frontend/src/pages/Sources.tsx index 19be72c..41aba23 100644 --- a/frontend/src/pages/Sources.tsx +++ b/frontend/src/pages/Sources.tsx @@ -13,6 +13,7 @@ import { Download, Upload, } from 'lucide-solid'; +import Button from '~/components/ui/Button'; import { sourcesApi } from '~/api/sources'; import { useI18n } from '~/i18n'; import { isApiError } from '~/types'; @@ -307,21 +308,13 @@ const Sources: Component = () => { onInput={(e) => setNewUrl(e.currentTarget.value)} />
- + {(msg) => (