From 444ce804ed115e2fe6b771146018f4f276d29343 Mon Sep 17 00:00:00 2001 From: kasun Date: Mon, 20 Jul 2026 16:44:21 +0200 Subject: [PATCH] introduced uiText.ts --- .../components/connections/ConnectModal.tsx | 17 ++++---- .../src/components/connections/Dashboard.tsx | 5 ++- .../components/connections/ServiceCard.tsx | 9 +++-- .../src/components/search/SearchModal.tsx | 13 ++++--- frontend/src/text/uiText.ts | 39 +++++++++++++++++++ 5 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 frontend/src/text/uiText.ts diff --git a/frontend/src/components/connections/ConnectModal.tsx b/frontend/src/components/connections/ConnectModal.tsx index c6b26f0..d8b592c 100644 --- a/frontend/src/components/connections/ConnectModal.tsx +++ b/frontend/src/components/connections/ConnectModal.tsx @@ -1,6 +1,7 @@ import { useEffect, useRef, useState, type SyntheticEvent } from 'react' import { login } from '../../api/connections' import type { LoginRequest, ServiceType } from '../../types/connection' +import { uiText } from '../../text/uiText' import '../ui/Modal.scss' interface Props { @@ -44,7 +45,7 @@ export function ConnectModal({ serviceType, label, onClose, onSuccess }: Readonl await login(req) onSuccess() } catch (err) { - setError(err instanceof Error ? err.message : 'Login failed') + setError(err instanceof Error ? err.message : uiText.connections.connectModal.loginFailed) } finally { setLoading(false) } @@ -53,31 +54,31 @@ export function ConnectModal({ serviceType, label, onClose, onSuccess }: Readonl return (
- - + +
- + setAppUrl(e.target.value)} required />
- + setUsername(e.target.value)} required />
- + setPassword(e.target.value)} required />
{error &&

{error}

}
diff --git a/frontend/src/components/connections/Dashboard.tsx b/frontend/src/components/connections/Dashboard.tsx index 0d2832e..ead03ec 100644 --- a/frontend/src/components/connections/Dashboard.tsx +++ b/frontend/src/components/connections/Dashboard.tsx @@ -5,6 +5,7 @@ import { ServiceCard } from "./ServiceCard" import { ConnectModal } from "./ConnectModal" import "./Dashboard.scss" import { SearchModal } from "../search/SearchModal" +import { uiText } from "../../text/uiText" const SERVICES = [ { serviceType: ServiceType.HOMEBOX, label: 'Homebox', icon: '📦' }, @@ -32,10 +33,10 @@ export function Dashboard() { return (
-

Vaessl Dashboard

+

{uiText.dashboard.title}

-

Services

+

{uiText.dashboard.servicesLabel}

{SERVICES.map(({ serviceType, label, icon }) => ( {label}

- {connected ? 'Connected' : 'Not connected'} + {connected ? uiText.connections.serviceCard.connected : uiText.connections.serviceCard.notConnected} {connected && status?.username && {status.username}} {connected && status?.expiresAt && ( - · expires {formatExpiry(status.expiresAt)} + {uiText.connections.serviceCard.expiresPrefix(formatExpiry(status.expiresAt) ?? '')} )}

- {connected ? 'Disconnect' : 'Connect'} + {connected ? uiText.connections.serviceCard.disconnectButton : uiText.connections.serviceCard.connectButton} - {connected && (Search)} + {connected && ({uiText.connections.serviceCard.searchButton})}
) diff --git a/frontend/src/components/search/SearchModal.tsx b/frontend/src/components/search/SearchModal.tsx index 7bc977f..957016e 100644 --- a/frontend/src/components/search/SearchModal.tsx +++ b/frontend/src/components/search/SearchModal.tsx @@ -3,6 +3,7 @@ import '../ui/Modal.scss' import { type PagedSearchResponse, type ServiceItem, type SearchRequest, type SyncRequest } from '../../types/search' import { syncVectorData, search } from '../../api/searches' import type { ServiceType } from '../../types/connection' +import { uiText } from '../../text/uiText' interface Props { serviceType: ServiceType @@ -48,7 +49,7 @@ export function SearchModal({ serviceType, label, appUrl, username, onClose }: R const res = await search(req) setResults(res) } catch (err) { - setSearchError(err instanceof Error ? err.message : 'Search failed') + setSearchError(err instanceof Error ? err.message : uiText.search.searchFailed) } finally { setLoading(false) } @@ -61,7 +62,7 @@ export function SearchModal({ serviceType, label, appUrl, username, onClose }: R const req: SyncRequest = { appUrl, serviceType, username} await syncVectorData(req) } catch (err) { - setSyncError(err instanceof Error ? err.message: 'Refreshing data failed') + setSyncError(err instanceof Error ? err.message: uiText.search.syncFailed) } finally { setLoading(false) } @@ -70,8 +71,8 @@ export function SearchModal({ serviceType, label, appUrl, username, onClose }: R return (
- - + +
@@ -81,8 +82,8 @@ export function SearchModal({ serviceType, label, appUrl, username, onClose }: R {searchError &&

{searchError}

} {syncError &&

{syncError}

}
- - + +
{results && ( diff --git a/frontend/src/text/uiText.ts b/frontend/src/text/uiText.ts new file mode 100644 index 0000000..cc46c21 --- /dev/null +++ b/frontend/src/text/uiText.ts @@ -0,0 +1,39 @@ +export const uiText = { + modal: { + closeAriaLabel: "Close", + closeSymbol: "×", + }, + dashboard: { + title: "Vaessl Dashboard", + servicesLabel: "Services", + }, + connections: { + connectModal: { + title: (label: string) => `Connect to ${label}`, + appUrlLabel: "App URL", + appUrlPlaceholder: "https://homebox.example.com", + usernameLabel: "Username", + passwordLabel: "Password", + loginFailed: "Login failed", + connectButton: "Connect", + connectingButton: "Connecting…", + }, + serviceCard: { + connected: "Connected", + notConnected: "Not connected", + expiresPrefix: (date: string) => `· expires ${date}`, + disconnectButton: "Disconnect", + connectButton: "Connect", + searchButton: "Search", + }, + }, + search: { + title: (label: string) => `Search in ${label}`, + searchFailed: "Search failed", + syncFailed: "Refreshing data failed", + syncTooltip: (label: string) => + `Syncs your ${label} database for vectorization`, + refreshDataButton: "Refresh Data", + searchButton: "Search", + }, +} as const;