release(v3.6.0): i18n EN/VI, offline cache, custom error pages (#55)
- Minimal typed i18n layer (~454 keys) with lazy-loaded Vietnamese dictionary chunk; language switcher in Settings, preference persisted in webapp.prefs - Persist react-query catalog cache to IndexedDB (instant paint on revisit, background revalidation; buster = app version, maxAge 7 days) - Status-aware error pages (400-504, 419, offline, unknown) wired into every route via typed HttpError; route ErrorBoundary with new-version reload; hidden /errors/:code preview route; static 404.html for GitHub Pages - Perf polish: GameThumb onError fallback, lazy settings avatar, DEV-gated react-query devtools - npm audit fix: react-router 7.14.2 -> 7.17.0 (GHSA-8x6r-g9mw-2r78) - Bump version badges, about.ts APP.version, CHANGELOG to 3.6.0 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7202de0ad7
commit
af8dd83157
62 files changed
+2287
-645
No files matched your search
@@ -2,6 +2,51 @@
|
||||
|
||||
All notable changes to this project will be documented here.
|
||||
|
||||
## [3.6.0] - 2026-06-12 (i18n EN/VI + offline cache + custom error pages)
|
||||
|
||||
### Added
|
||||
|
||||
- **Bilingual UI (English / Tiếng Việt)** — a minimal typed i18n layer
|
||||
([`webapp/src/lib/i18n/`](webapp/src/lib/i18n)) with ~340 keys covering every
|
||||
route, dialog, chart, and toast. The Vietnamese dictionary is a **lazy-loaded
|
||||
chunk**: it is only downloaded the first time the language is switched to VI
|
||||
(or on startup when VI is the persisted preference). Switcher lives in
|
||||
Settings → Appearance; the preference persists in `webapp.prefs`.
|
||||
- **Offline-first catalog cache** — the react-query cache for the public
|
||||
catalog queries (`db`, `deleted`, `count-history`) now persists to
|
||||
**IndexedDB** (`@tanstack/react-query-persist-client` +
|
||||
`@tanstack/query-async-storage-persister` + `idb-keyval`). Revisits paint
|
||||
instantly from cache (~2 MB of JSON no longer re-downloaded cold) and
|
||||
revalidate in the background. Cache busts automatically on each release
|
||||
(`buster = APP.version`, `maxAge` 7 days). PAT-gated data is never persisted.
|
||||
- **Custom error pages** — a status-aware
|
||||
[`ErrorPage`](webapp/src/components/error-page.tsx) (400, 401, 403, 404, 408,
|
||||
419, 429, 500, 502, 503, 504, offline, unknown) wired into every route's
|
||||
error branch with the *real* HTTP status (`fetchRaw` now throws a typed
|
||||
`HttpError`), plus:
|
||||
- a route-level **ErrorBoundary** that detects stale-chunk failures after a
|
||||
redeploy and offers a one-click reload ("New version available"),
|
||||
- a hidden `/#/errors/:code` preview route,
|
||||
- a static [`webapp/public/404.html`](webapp/public/404.html) served by
|
||||
GitHub Pages for bad path URLs (bilingual, dark-mode aware, zero JS).
|
||||
|
||||
### Changed
|
||||
|
||||
- `ReactQueryDevtools` is now explicitly gated behind `import.meta.env.DEV`.
|
||||
- Game thumbnails render through a shared
|
||||
[`GameThumb`](webapp/src/components/game-thumb.tsx) that falls back to the
|
||||
muted placeholder when a cover 404s; the Settings avatar is now lazy-loaded.
|
||||
- `idb-keyval` returns (removed as unused in v3.5.2 — it has a real consumer
|
||||
now); `THIRD_PARTY` in `about.ts` lists the three new data-layer deps.
|
||||
|
||||
### Notes
|
||||
|
||||
- The About page's legal/credits data intentionally stays English (controlling
|
||||
language for legal interpretation); Vietnamese policy docs remain under
|
||||
[`docs/i18n/vi/`](docs/i18n/vi).
|
||||
- No Tauri / Rust binary boundary change — `Cargo.toml` / `tauri.conf.json`
|
||||
stay at `0.1.1`.
|
||||
|
||||
## [3.5.2] - 2026-05-23 (Dead-code cleanup — knip + vulture)
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Free Itch.io Games List
|
||||
|
||||
[](https://github.com/poli0981/free-games-itchio-list/)
|
||||
[](https://github.com/poli0981/free-games-itchio-list/)
|
||||
[](https://github.com/poli0981/free-games-itchio-list/stargazers)
|
||||
[](https://github.com/poli0981/free-games-itchio-list/network/members)
|
||||
[](https://github.com/poli0981/free-games-itchio-list/commits/main)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Danh sách Game Itch.io Miễn Phí
|
||||
|
||||
[](https://github.com/poli0981/free-games-itchio-list/)
|
||||
[](https://github.com/poli0981/free-games-itchio-list/)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](README.md)
|
||||
|
||||
|
||||
Generated
+68
-15
@@ -18,13 +18,16 @@
|
||||
"@radix-ui/react-slot": "^1.2.4",
|
||||
"@radix-ui/react-switch": "^1.2.6",
|
||||
"@radix-ui/react-tabs": "^1.1.13",
|
||||
"@tanstack/query-async-storage-persister": "^5.101.0",
|
||||
"@tanstack/react-query": "^5.100.9",
|
||||
"@tanstack/react-query-devtools": "^5.100.9",
|
||||
"@tanstack/react-query-persist-client": "^5.101.0",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@tanstack/react-virtual": "^3.13.24",
|
||||
"@tauri-apps/plugin-opener": "^2.0.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"idb-keyval": "^6.2.5",
|
||||
"lucide-react": "^1.14.0",
|
||||
"openpgp": "^6.3.0",
|
||||
"react": "^19.2.5",
|
||||
@@ -2745,10 +2748,24 @@
|
||||
"integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tanstack/query-async-storage-persister": {
|
||||
"version": "5.101.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/query-async-storage-persister/-/query-async-storage-persister-5.101.0.tgz",
|
||||
"integrity": "sha512-8Y8pwMVPh4kqU9m+MhbDYBuub+i5T2M9P/0+Ae3KccX1BwMIp6AdFAx3zDgLoZcEVI830mbJYf0sjAgsawCWVw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/query-core": "5.101.0",
|
||||
"@tanstack/query-persist-client-core": "5.101.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/query-core": {
|
||||
"version": "5.100.9",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.100.9.tgz",
|
||||
"integrity": "sha512-SJSFw1S8+kQ0+knv/XGfrbocWoAlT7vDKsSImtLx3ZPQmEcR46hkDjLSvynSy25N8Ms4tIEini1FuBd5k7IscQ==",
|
||||
"version": "5.101.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.101.0.tgz",
|
||||
"integrity": "sha512-cQetA74EB+seWySv1TTKr828TnP0u39m6LykwDXIo84SNortpDkp30TMEjkqtYCNP9c40uT/iwl6MLiufEt0Ow==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
@@ -2765,13 +2782,26 @@
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/react-query": {
|
||||
"version": "5.100.9",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.100.9.tgz",
|
||||
"integrity": "sha512-Oa44XkaI3kCNN6ME0KByU3xT3SEUNOMfZpHxL6+wFoTm+OeUFYHKdeYVe0aOXlRDm/f15sgLwEt2HDorIdW8+A==",
|
||||
"node_modules/@tanstack/query-persist-client-core": {
|
||||
"version": "5.101.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/query-persist-client-core/-/query-persist-client-core-5.101.0.tgz",
|
||||
"integrity": "sha512-LH99WepGVLwlLfuOcQcPK7f3Xg/Gf+xlMMIj9xWu/8oQ3egnDzjr+a4HvEmi6PGob5SmGXvmDKZaH5+In9dzjw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/query-core": "5.100.9"
|
||||
"@tanstack/query-core": "5.101.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/react-query": {
|
||||
"version": "5.101.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.101.0.tgz",
|
||||
"integrity": "sha512-rLlJXSpkqfizLWgkR5+eLeIk0MvTx/meEIR7LRjxic+qxiQP8zVjq7BqQkiCMNLQBlLfuOLqqr6KO5GtrDlmSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/query-core": "5.101.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
@@ -2798,6 +2828,23 @@
|
||||
"react": "^18 || ^19"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/react-query-persist-client": {
|
||||
"version": "5.101.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-query-persist-client/-/react-query-persist-client-5.101.0.tgz",
|
||||
"integrity": "sha512-AUcdBgz8V6sM9axzdqkVmWjYSOETkhr6yAZSBnEFyZT2jo6vkFq3UrpRuxGs6fmhKMWv8FA+ZJGcbaKPaoAElQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/query-persist-client-core": "5.101.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tanstack/react-query": "^5.101.0",
|
||||
"react": "^18 || ^19"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/react-table": {
|
||||
"version": "8.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.21.3.tgz",
|
||||
@@ -4628,6 +4675,12 @@
|
||||
"hermes-estree": "0.25.1"
|
||||
}
|
||||
},
|
||||
"node_modules/idb-keyval": {
|
||||
"version": "6.2.5",
|
||||
"resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-6.2.5.tgz",
|
||||
"integrity": "sha512-eKQkTnS0relYsSOYomx8ozIbmdsQCKUdhyuIaQ2DZgKuaxtyQQMkyD/wlnQN32pO3yutN1b1L8uqwcDKaJd7/Q==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/ignore": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||
@@ -5862,9 +5915,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "7.14.2",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.14.2.tgz",
|
||||
"integrity": "sha512-yCqNne6I8IB6rVCH7XUvlBK7/QKyqypBFGv+8dj4QBFJiiRX+FG7/nkdAvGElyvVZ/HQP5N19wzteuTARXi5Gw==",
|
||||
"version": "7.17.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.17.0.tgz",
|
||||
"integrity": "sha512-FDELK7rTMlCHO5+reyXsPlmfr7N1F91lPHsWYfMEGQm/KQ+F4JFM8jGoeQDmDvdTs93Fw9aSilH+uKRb4/jXvQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cookie": "^1.0.1",
|
||||
@@ -5884,12 +5937,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-router-dom": {
|
||||
"version": "7.14.2",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.14.2.tgz",
|
||||
"integrity": "sha512-YZcM5ES8jJSM+KrJ9BdvHHqlnGTg5tH3sC5ChFRj4inosKctdyzBDhOyyHdGk597q2OT6NTrCA1OvB/YDwfekQ==",
|
||||
"version": "7.17.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.17.0.tgz",
|
||||
"integrity": "sha512-fyU2yjGups/hE6Xz0I5ZYbVL8Gx29eCjgpHaRaTaVU+OOAdfRX05KsvyRm0GO8YQwOkhpU3MurW1jyMUJn+zSw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"react-router": "7.14.2"
|
||||
"react-router": "7.17.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
|
||||
@@ -24,13 +24,16 @@
|
||||
"@radix-ui/react-slot": "^1.2.4",
|
||||
"@radix-ui/react-switch": "^1.2.6",
|
||||
"@radix-ui/react-tabs": "^1.1.13",
|
||||
"@tanstack/query-async-storage-persister": "^5.101.0",
|
||||
"@tanstack/react-query": "^5.100.9",
|
||||
"@tanstack/react-query-devtools": "^5.100.9",
|
||||
"@tanstack/react-query-persist-client": "^5.101.0",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@tanstack/react-virtual": "^3.13.24",
|
||||
"@tauri-apps/plugin-opener": "^2.0.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"idb-keyval": "^6.2.5",
|
||||
"lucide-react": "^1.14.0",
|
||||
"openpgp": "^6.3.0",
|
||||
"react": "^19.2.5",
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
GitHub Pages custom 404. Served for any missing *path* on the Pages origin
|
||||
(the SPA itself uses HashRouter, so bad in-app routes are handled by the
|
||||
React catch-all instead). Self-contained on purpose: no JS, no external
|
||||
assets, colors mirror webapp/src/index.css tokens via prefers-color-scheme.
|
||||
-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="robots" content="noindex" />
|
||||
<title>404 — Itch.io Free Games Database</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: hsl(0 0% 100%);
|
||||
--fg: hsl(240 10% 3.9%);
|
||||
--muted: hsl(240 3.8% 46.1%);
|
||||
--border: hsl(240 5.9% 90%);
|
||||
--card: hsl(0 0% 100%);
|
||||
--btn-bg: hsl(240 5.9% 10%);
|
||||
--btn-fg: hsl(0 0% 98%);
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--bg: hsl(240 10% 3.9%);
|
||||
--fg: hsl(0 0% 98%);
|
||||
--muted: hsl(240 5% 64.9%);
|
||||
--border: hsl(240 3.7% 15.9%);
|
||||
--card: hsl(240 10% 3.9%);
|
||||
--btn-bg: hsl(0 0% 98%);
|
||||
--btn-fg: hsl(240 5.9% 10%);
|
||||
}
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100dvh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--bg);
|
||||
color: var(--fg);
|
||||
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
.card {
|
||||
max-width: 28rem;
|
||||
width: 100%;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.5rem;
|
||||
background: var(--card);
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
.code {
|
||||
font-size: 4rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.025em;
|
||||
margin: 0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em; margin: 0.5rem 0 0; }
|
||||
p { color: var(--muted); font-size: 0.875rem; line-height: 1.5; margin: 0.75rem 0 0; }
|
||||
.vi { font-style: normal; }
|
||||
a.btn {
|
||||
display: inline-block;
|
||||
margin-top: 1.5rem;
|
||||
padding: 0.625rem 1.25rem;
|
||||
border-radius: 0.375rem;
|
||||
background: var(--btn-bg);
|
||||
color: var(--btn-fg);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
}
|
||||
a.btn:hover { opacity: 0.9; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="card">
|
||||
<p class="code">404</p>
|
||||
<h1>Page not found</h1>
|
||||
<p>The page you're looking for doesn't exist or has been moved.</p>
|
||||
<p lang="vi" class="vi">Trang bạn tìm không tồn tại hoặc đã bị di chuyển.</p>
|
||||
<a class="btn" href="./">Open the app · Mở ứng dụng</a>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
+19
-14
@@ -2,6 +2,7 @@ import { lazy, Suspense, useEffect, useRef } from 'react'
|
||||
import { Routes, Route, useLocation } from 'react-router-dom'
|
||||
import { Sidebar, MobileTopBar } from '@/components/sidebar'
|
||||
import ScrollToTop from '@/components/scroll-to-top'
|
||||
import { RouteErrorBoundary } from '@/components/error-boundary'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { useThemeEffect } from '@/hooks/useThemeEffect'
|
||||
import { useDensityEffect } from '@/hooks/useDensityEffect'
|
||||
@@ -16,6 +17,7 @@ const Charts = lazy(() => import('@/routes/charts'))
|
||||
const Workflows = lazy(() => import('@/routes/workflows'))
|
||||
const Settings = lazy(() => import('@/routes/settings'))
|
||||
const About = lazy(() => import('@/routes/about'))
|
||||
const ErrorPreview = lazy(() => import('@/routes/error-preview'))
|
||||
|
||||
function RouteFallback() {
|
||||
return (
|
||||
@@ -54,20 +56,23 @@ export default function App() {
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<MobileTopBar />
|
||||
<main ref={mainRef} className="flex-1 overflow-y-auto">
|
||||
<Suspense fallback={<RouteFallback />}>
|
||||
<Routes>
|
||||
<Route path="/" element={<Dashboard />} />
|
||||
<Route path="/games" element={<Games />} />
|
||||
<Route path="/games/:slug" element={<GameDetail />} />
|
||||
<Route path="/add" element={<Add />} />
|
||||
<Route path="/charts" element={<Charts />} />
|
||||
<Route path="/workflows" element={<Workflows />} />
|
||||
<Route path="/deleted" element={<Deleted />} />
|
||||
<Route path="/settings" element={<Settings />} />
|
||||
<Route path="/about" element={<About />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
<RouteErrorBoundary>
|
||||
<Suspense fallback={<RouteFallback />}>
|
||||
<Routes>
|
||||
<Route path="/" element={<Dashboard />} />
|
||||
<Route path="/games" element={<Games />} />
|
||||
<Route path="/games/:slug" element={<GameDetail />} />
|
||||
<Route path="/add" element={<Add />} />
|
||||
<Route path="/charts" element={<Charts />} />
|
||||
<Route path="/workflows" element={<Workflows />} />
|
||||
<Route path="/deleted" element={<Deleted />} />
|
||||
<Route path="/settings" element={<Settings />} />
|
||||
<Route path="/about" element={<About />} />
|
||||
<Route path="/errors/:code" element={<ErrorPreview />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
</RouteErrorBoundary>
|
||||
</main>
|
||||
<ScrollToTop targetRef={mainRef} />
|
||||
</div>
|
||||
|
||||
@@ -27,6 +27,7 @@ import { atomicCommit, bulkDeleteGames } from '@/lib/github/git-data'
|
||||
import { useAllGames } from '@/hooks/useGames'
|
||||
import { rebalance } from '@/lib/github/data-store'
|
||||
import { PATHS } from '@/lib/config'
|
||||
import { useT, type MessageKey } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
|
||||
interface BulkDeleteDialogProps {
|
||||
@@ -38,7 +39,15 @@ interface BulkDeleteDialogProps {
|
||||
|
||||
const REASONS = ['Manual cleanup', 'Quality issue', 'Duplicate', 'Other']
|
||||
|
||||
const REASON_LABELS: Record<string, MessageKey> = {
|
||||
'Manual cleanup': 'bulk.reason.manualCleanup',
|
||||
'Quality issue': 'bulk.reason.qualityIssue',
|
||||
Duplicate: 'bulk.reason.duplicate',
|
||||
Other: 'bulk.reason.other',
|
||||
}
|
||||
|
||||
export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: BulkDeleteDialogProps) {
|
||||
const t = useT()
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const all = useAllGames()
|
||||
const qc = useQueryClient()
|
||||
@@ -51,9 +60,9 @@ export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: B
|
||||
const canDelete = confirm.toLowerCase() === expected
|
||||
|
||||
async function handleDelete() {
|
||||
if (!pat) return toast.error('Unlock your PAT in Settings.')
|
||||
if (!all.data) return toast.error('Game cache not ready.')
|
||||
if (!canDelete) return toast.error(`Type '${expected}' to confirm.`)
|
||||
if (!pat) return toast.error(t('bulk.toast.unlockPat'))
|
||||
if (!all.data) return toast.error(t('bulk.toast.cacheNotReady'))
|
||||
if (!canDelete) return toast.error(t('bulk.delete.confirmToast', { expected }))
|
||||
setBusy(true)
|
||||
try {
|
||||
const octokit = createOctokit()
|
||||
@@ -71,7 +80,7 @@ export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: B
|
||||
|
||||
pushUndo({
|
||||
id: commitSha,
|
||||
label: `Bulk-delete of ${urls.length} games`,
|
||||
label: t('bulk.undo.deleteLabel', { n: urls.length }),
|
||||
timestamp: Date.now(),
|
||||
reverse: async () => {
|
||||
const { games } = (await qc.ensureQueryData({
|
||||
@@ -93,14 +102,18 @@ export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: B
|
||||
})
|
||||
|
||||
toast.success(
|
||||
`${urls.length} games deleted across ${touchedFiles.length} file(s) (${commitSha.slice(0, 7)}).`,
|
||||
t('bulk.toast.deleted', {
|
||||
n: urls.length,
|
||||
files: touchedFiles.length,
|
||||
sha: commitSha.slice(0, 7),
|
||||
}),
|
||||
)
|
||||
await qc.invalidateQueries({ queryKey: ['db'] })
|
||||
onComplete()
|
||||
onOpenChange(false)
|
||||
setConfirm('')
|
||||
} catch (e) {
|
||||
toast.error(`Delete failed: ${(e as Error).message}`)
|
||||
toast.error(t('bulk.toast.deleteFailed', { msg: (e as Error).message }))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
@@ -110,12 +123,8 @@ export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: B
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Delete {selected.length} games</DialogTitle>
|
||||
<DialogDescription>
|
||||
One atomic commit removes the records from data_game/ chunks (rebalanced) and appends
|
||||
entries to scripts/deleted_games.json. Use the undo button after committing to roll
|
||||
back. This is reversible only via undo or git revert.
|
||||
</DialogDescription>
|
||||
<DialogTitle>{t('bulk.delete.title', { n: selected.length })}</DialogTitle>
|
||||
<DialogDescription>{t('bulk.delete.desc')}</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="max-h-40 overflow-y-auto rounded-md border bg-muted/30 p-2 text-xs">
|
||||
@@ -126,14 +135,16 @@ export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: B
|
||||
</li>
|
||||
))}
|
||||
{selected.length > 50 && (
|
||||
<li className="text-muted-foreground">… and {selected.length - 50} more</li>
|
||||
<li className="text-muted-foreground">
|
||||
{t('bulk.delete.more', { n: selected.length - 50 })}
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label>Reason</Label>
|
||||
<Label>{t('bulk.delete.reason')}</Label>
|
||||
<Select value={reason} onValueChange={setReason}>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
@@ -141,7 +152,7 @@ export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: B
|
||||
<SelectContent>
|
||||
{REASONS.map((r) => (
|
||||
<SelectItem key={r} value={r}>
|
||||
{r}
|
||||
{t(REASON_LABELS[r])}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
@@ -150,7 +161,8 @@ export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: B
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label>
|
||||
Type <code className="font-mono">{expected}</code> to confirm
|
||||
{t('bulk.delete.typePrefix')} <code className="font-mono">{expected}</code>{' '}
|
||||
{t('bulk.delete.typeSuffix')}
|
||||
</Label>
|
||||
<Input
|
||||
value={confirm}
|
||||
@@ -163,11 +175,11 @@ export function BulkDeleteDialog({ open, onOpenChange, selected, onComplete }: B
|
||||
|
||||
<DialogFooter>
|
||||
<Button variant="ghost" onClick={() => onOpenChange(false)} disabled={busy}>
|
||||
Cancel
|
||||
{t('common.cancel')}
|
||||
</Button>
|
||||
<Button variant="destructive" onClick={handleDelete} disabled={busy || !canDelete}>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
{busy ? 'Deleting...' : `Delete ${selected.length}`}
|
||||
{busy ? t('bulk.delete.deleting') : t('bulk.delete.cta', { n: selected.length })}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
@@ -27,6 +27,7 @@ import { useUndo } from '@/stores/undo'
|
||||
import { createOctokit } from '@/lib/github/client'
|
||||
import { bulkUpdateGames, type BulkEditPatch } from '@/lib/github/git-data'
|
||||
import { useAllGames } from '@/hooks/useGames'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
|
||||
interface BulkEditDialogProps {
|
||||
@@ -39,6 +40,7 @@ interface BulkEditDialogProps {
|
||||
const SAFE_OPTIONS = ['?', 'Yes', 'No', 'Caution'] as const
|
||||
|
||||
export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: BulkEditDialogProps) {
|
||||
const t = useT()
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const all = useAllGames()
|
||||
const qc = useQueryClient()
|
||||
@@ -51,6 +53,15 @@ export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: Bul
|
||||
const [notesVal, setNotesVal] = useState('')
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
const safeLabel = (o: string) =>
|
||||
o === 'Yes'
|
||||
? t('common.yes')
|
||||
: o === 'No'
|
||||
? t('common.no')
|
||||
: o === 'Caution'
|
||||
? t('bulk.safe.caution')
|
||||
: o
|
||||
|
||||
function buildPatch(): Partial<Pick<Game, 'safe_virus' | 'notes' | 'nsfw'>> {
|
||||
const p: Partial<Pick<Game, 'safe_virus' | 'notes' | 'nsfw'>> = {}
|
||||
if (editSafe) p.safe_virus = safeVal
|
||||
@@ -60,11 +71,11 @@ export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: Bul
|
||||
}
|
||||
|
||||
async function handleApply() {
|
||||
if (!pat) return toast.error('Unlock your PAT in Settings.')
|
||||
if (!all.data) return toast.error('Game cache not ready.')
|
||||
if (!pat) return toast.error(t('bulk.toast.unlockPat'))
|
||||
if (!all.data) return toast.error(t('bulk.toast.cacheNotReady'))
|
||||
const patch = buildPatch()
|
||||
if (Object.keys(patch).length === 0) {
|
||||
return toast.error('Toggle at least one field to update.')
|
||||
return toast.error(t('bulk.toast.noField'))
|
||||
}
|
||||
setBusy(true)
|
||||
try {
|
||||
@@ -89,7 +100,7 @@ export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: Bul
|
||||
|
||||
pushUndo({
|
||||
id: commitSha,
|
||||
label: `Bulk-edit of ${selected.length} games`,
|
||||
label: t('bulk.undo.editLabel', { n: selected.length }),
|
||||
timestamp: Date.now(),
|
||||
reverse: async () => {
|
||||
const { games } = (await qc.ensureQueryData({
|
||||
@@ -106,13 +117,17 @@ export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: Bul
|
||||
})
|
||||
|
||||
toast.success(
|
||||
`${selected.length} games updated in ${touchedFiles.length} file(s) (${commitSha.slice(0, 7)}).`,
|
||||
t('bulk.toast.updated', {
|
||||
n: selected.length,
|
||||
files: touchedFiles.length,
|
||||
sha: commitSha.slice(0, 7),
|
||||
}),
|
||||
)
|
||||
await qc.invalidateQueries({ queryKey: ['db'] })
|
||||
onComplete()
|
||||
onOpenChange(false)
|
||||
} catch (e) {
|
||||
toast.error(`Bulk-edit failed: ${(e as Error).message}`)
|
||||
toast.error(t('bulk.toast.editFailed', { msg: (e as Error).message }))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
@@ -122,18 +137,15 @@ export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: Bul
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Bulk Edit ({selected.length} games)</DialogTitle>
|
||||
<DialogDescription>
|
||||
Toggle a field on the left to apply the same value to every selected game. Untoggled
|
||||
fields stay as they are.
|
||||
</DialogDescription>
|
||||
<DialogTitle>{t('bulk.edit.title', { n: selected.length })}</DialogTitle>
|
||||
<DialogDescription>{t('bulk.edit.desc')}</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<Checkbox checked={editSafe} onCheckedChange={(v) => setEditSafe(!!v)} className="mt-2" />
|
||||
<div className="flex-1 space-y-1.5">
|
||||
<Label>Safe / virus</Label>
|
||||
<Label>{t('bulk.field.safeVirus')}</Label>
|
||||
<Select value={safeVal} onValueChange={setSafeVal} disabled={!editSafe}>
|
||||
<SelectTrigger className="w-40">
|
||||
<SelectValue />
|
||||
@@ -141,7 +153,7 @@ export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: Bul
|
||||
<SelectContent>
|
||||
{SAFE_OPTIONS.map((o) => (
|
||||
<SelectItem key={o} value={o}>
|
||||
{o}
|
||||
{safeLabel(o)}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
@@ -154,20 +166,22 @@ export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: Bul
|
||||
<div className="flex flex-1 items-center gap-3">
|
||||
<Label>NSFW</Label>
|
||||
<Switch checked={nsfwVal} onCheckedChange={setNsfwVal} disabled={!editNsfw} />
|
||||
<span className="text-sm text-muted-foreground">{nsfwVal ? 'Yes' : 'No'}</span>
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{nsfwVal ? t('common.yes') : t('common.no')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-start gap-3">
|
||||
<Checkbox checked={editNotes} onCheckedChange={(v) => setEditNotes(!!v)} className="mt-2" />
|
||||
<div className="flex-1 space-y-1.5">
|
||||
<Label>Notes (replaces existing)</Label>
|
||||
<Label>{t('bulk.field.notesReplace')}</Label>
|
||||
<Textarea
|
||||
value={notesVal}
|
||||
onChange={(e) => setNotesVal(e.target.value)}
|
||||
disabled={!editNotes}
|
||||
rows={3}
|
||||
placeholder="Same notes for every selected game"
|
||||
placeholder={t('bulk.edit.notesPlaceholder')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -175,11 +189,11 @@ export function BulkEditDialog({ open, onOpenChange, selected, onComplete }: Bul
|
||||
|
||||
<DialogFooter>
|
||||
<Button variant="ghost" onClick={() => onOpenChange(false)} disabled={busy}>
|
||||
Cancel
|
||||
{t('common.cancel')}
|
||||
</Button>
|
||||
<Button onClick={handleApply} disabled={busy || !pat}>
|
||||
<Save className="h-4 w-4" />
|
||||
{busy ? 'Applying...' : 'Apply to selected'}
|
||||
{busy ? t('bulk.edit.applying') : t('bulk.edit.apply')}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||
import { countBy, topN } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function AvgSessionChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => topN(countBy(games, 'average_session'), 8), [games])
|
||||
return (
|
||||
<ChartCard title="Average Session Length">
|
||||
<ChartCard title={t('charts.avgSession.title')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={data}>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||
import { deletionReasonCounts } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { DeletedGameEntry } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function DeletionReasonsChart({ deleted }: { deleted: DeletedGameEntry[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => deletionReasonCounts(deleted), [deleted])
|
||||
return (
|
||||
<ChartCard title="Deletion Reasons" description="Why games left the catalog">
|
||||
<ChartCard title={t('charts.deletionReasons.title')} description={t('charts.deletionReasons.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<Pie data={data} dataKey="count" nameKey="key" innerRadius="50%" outerRadius="80%" paddingAngle={2}>
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||
import { deletionsByMonth } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { DeletedGameEntry } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function DeletionsOverTimeChart({ deleted }: { deleted: DeletedGameEntry[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => deletionsByMonth(deleted), [deleted])
|
||||
return (
|
||||
<ChartCard title="Deletions Over Time" description="Games removed per month">
|
||||
<ChartCard title={t('charts.deletionsOverTime.title')} description={t('charts.deletionsOverTime.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={data}>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { CountHistoryPoint } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function GameCountChart({ history }: { history: CountHistoryPoint[] }) {
|
||||
const t = useT()
|
||||
return (
|
||||
<ChartCard title="Game Count Over Time" description="Total games in the catalog by day">
|
||||
<ChartCard title={t('charts.gameCount.title')} description={t('charts.gameCount.desc')}>
|
||||
{history.length === 0 ? (
|
||||
<p className="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||
No history data yet.
|
||||
{t('charts.gameCount.empty')}
|
||||
</p>
|
||||
) : (
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||
import { countBy, topN } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function GenreChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => topN(countBy(games, 'genre'), 15), [games])
|
||||
return (
|
||||
<ChartCard title="Genres" description="Top 15 by game count">
|
||||
<ChartCard title={t('charts.genre.title')} description={t('charts.genre.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={data} layout="vertical" margin={{ left: 20 }}>
|
||||
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMemo } from 'react'
|
||||
import { ResponsiveContainer, Tooltip, Treemap } from 'recharts'
|
||||
import { genreTreemapData } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
@@ -41,12 +42,13 @@ function TreemapCell(props: TreemapCellProps) {
|
||||
}
|
||||
|
||||
export function GenreTreemapChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => genreTreemapData(games, 12), [games])
|
||||
// Recharts' Treemap data prop demands an index signature; our typed nodes
|
||||
// are valid treemap data at runtime, so cast through unknown.
|
||||
const treemapData = data as unknown as React.ComponentProps<typeof Treemap>['data']
|
||||
return (
|
||||
<ChartCard title="Genre Treemap" description="Top 12 genres sized by game count">
|
||||
<ChartCard title={t('charts.genreTreemap.title')} description={t('charts.genreTreemap.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<Treemap data={treemapData} dataKey="size" nameKey="name" content={<TreemapCell />}>
|
||||
<Tooltip
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { computeKpis } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import { formatNumber } from '@/lib/utils'
|
||||
import type { DeletedGameEntry, Game } from '@/types/game'
|
||||
|
||||
@@ -10,13 +11,14 @@ interface KpiCardsProps {
|
||||
}
|
||||
|
||||
export function KpiCards({ games, deleted }: KpiCardsProps) {
|
||||
const t = useT()
|
||||
const kpis = useMemo(() => computeKpis(games, deleted), [games, deleted])
|
||||
const items = [
|
||||
{ label: 'Total games', value: formatNumber(kpis.totalGames) },
|
||||
{ label: 'Online (HTML5)', value: formatNumber(kpis.onlineCount) },
|
||||
{ label: 'NSFW', value: formatNumber(kpis.nsfwCount) },
|
||||
{ label: 'Deleted (total)', value: formatNumber(kpis.totalDeleted) },
|
||||
{ label: 'Avg rating', value: kpis.avgRating.toFixed(2) },
|
||||
{ label: t('charts.kpi.totalGames'), value: formatNumber(kpis.totalGames) },
|
||||
{ label: t('charts.kpi.online'), value: formatNumber(kpis.onlineCount) },
|
||||
{ label: t('charts.kpi.nsfw'), value: formatNumber(kpis.nsfwCount) },
|
||||
{ label: t('charts.kpi.deletedTotal'), value: formatNumber(kpis.totalDeleted) },
|
||||
{ label: t('charts.kpi.avgRating'), value: kpis.avgRating.toFixed(2) },
|
||||
]
|
||||
return (
|
||||
<div className="grid grid-cols-2 gap-4 md:grid-cols-5">
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||
import { countByArray, topN } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function LanguagesChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => topN(countByArray(games, 'languages'), 10), [games])
|
||||
return (
|
||||
<ChartCard title="Top 10 Languages">
|
||||
<ChartCard title={t('charts.languages.title')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={data}>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||
import { topMadeWith } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function MadeWithChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => topMadeWith(games, 8), [games])
|
||||
return (
|
||||
<ChartCard title="Game Engines" description="Primary engine per game (made_with[0])">
|
||||
<ChartCard title={t('charts.madeWith.title')} description={t('charts.madeWith.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<Pie data={data} dataKey="count" nameKey="key" innerRadius="50%" outerRadius="80%" paddingAngle={2}>
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||
import { classifyOnline } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function OnlineOfflineChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const split = useMemo(() => classifyOnline(games), [games])
|
||||
const data = [
|
||||
{ key: 'Online (HTML5)', count: split.online },
|
||||
{ key: 'Offline only', count: split.offline },
|
||||
{ key: t('charts.onlineOffline.online'), count: split.online },
|
||||
{ key: t('charts.onlineOffline.offline'), count: split.offline },
|
||||
]
|
||||
return (
|
||||
<ChartCard title="Online vs Offline" description="HTML5 means playable in the browser">
|
||||
<ChartCard title={t('charts.onlineOffline.title')} description={t('charts.onlineOffline.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<Pie data={data} dataKey="count" nameKey="key" innerRadius="50%" outerRadius="80%">
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||
import { countByArray } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function PlatformChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => countByArray(games, 'platforms'), [games])
|
||||
return (
|
||||
<ChartCard title="Platforms" description="Counted per game (a game may target several)">
|
||||
<ChartCard title={t('charts.platform.title')} description={t('charts.platform.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<Pie
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||
import { ratingHistogram } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function RatingChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => ratingHistogram(games, 10), [games])
|
||||
return (
|
||||
<ChartCard title="Rating Histogram" description="Bins of 0.5 stars from 0 to 5">
|
||||
<ChartCard title={t('charts.rating.title')} description={t('charts.rating.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={data}>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import { formatNumber } from '@/lib/utils'
|
||||
import type { DeletedGameEntry } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
|
||||
export function RecentDeletedChart({ deleted }: { deleted: DeletedGameEntry[] }) {
|
||||
const t = useT()
|
||||
const recent = useMemo(
|
||||
() =>
|
||||
[...deleted]
|
||||
@@ -14,13 +16,13 @@ export function RecentDeletedChart({ deleted }: { deleted: DeletedGameEntry[] })
|
||||
)
|
||||
return (
|
||||
<ChartCard
|
||||
title="Recent Deletions"
|
||||
description={`Last ${recent.length} of ${formatNumber(deleted.length)} total`}
|
||||
title={t('charts.recentDeleted.title')}
|
||||
description={t('charts.recentDeleted.desc', { shown: recent.length, total: formatNumber(deleted.length) })}
|
||||
>
|
||||
<div className="h-full overflow-y-auto pr-2">
|
||||
<ul className="space-y-1.5 text-sm">
|
||||
{recent.length === 0 ? (
|
||||
<p className="text-muted-foreground">No deletions logged.</p>
|
||||
<p className="text-muted-foreground">{t('charts.recentDeleted.empty')}</p>
|
||||
) : (
|
||||
recent.map((d) => (
|
||||
<li
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||
import { countBy } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function StatusChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => countBy(games, 'status'), [games])
|
||||
return (
|
||||
<ChartCard title="Status Mix" description="Released vs prototype/in-progress">
|
||||
<ChartCard title={t('charts.status.title')} description={t('charts.status.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<Pie data={data} dataKey="count" nameKey="key" outerRadius="80%">
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||
import { topByRatingCount } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
import { PALETTE } from './palette'
|
||||
|
||||
export function TopRatedCountChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => topByRatingCount(games, 10), [games])
|
||||
return (
|
||||
<ChartCard title="Most Rated Games" description="Top 10 by number of ratings">
|
||||
<ChartCard title={t('charts.topRatedCount.title')} description={t('charts.topRatedCount.desc')}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={data} layout="vertical" margin={{ left: 20 }}>
|
||||
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
import { useMemo } from 'react'
|
||||
import { countByArray, topN } from '@/lib/analytics'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
import { ChartCard } from './chart-card'
|
||||
|
||||
export function TopTagsChart({ games }: { games: Game[] }) {
|
||||
const t = useT()
|
||||
const data = useMemo(() => topN(countByArray(games, 'tags'), 30), [games])
|
||||
return (
|
||||
<ChartCard title="Top 30 Tags" description="Word-cloud-style ranking (sized by count)">
|
||||
<ChartCard title={t('charts.topTags.title')} description={t('charts.topTags.desc')}>
|
||||
<div className="flex h-full flex-wrap content-start items-baseline gap-2 overflow-y-auto p-2">
|
||||
{data.map((t) => {
|
||||
const fontSize = computeTagFontSize(t.count, data[0]?.count ?? 1)
|
||||
{data.map((tag) => {
|
||||
const fontSize = computeTagFontSize(tag.count, data[0]?.count ?? 1)
|
||||
return (
|
||||
<span
|
||||
key={t.key}
|
||||
key={tag.key}
|
||||
style={{ fontSize: `${fontSize}px`, lineHeight: 1.1 }}
|
||||
className="font-medium text-foreground/80 hover:text-foreground"
|
||||
title={`${t.count} games`}
|
||||
title={t('charts.topTags.tagTitle', { count: tag.count })}
|
||||
>
|
||||
{t.key}
|
||||
{tag.key}
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -2,8 +2,10 @@ import { Link } from 'react-router-dom'
|
||||
import type { ColumnDef, FilterFn, RowData } from '@tanstack/react-table'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { GameThumb } from '@/components/game-thumb'
|
||||
import type { Game } from '@/types/game'
|
||||
import { slugify } from '@/lib/utils'
|
||||
import { t } from '@/lib/i18n'
|
||||
import { SortableHeader } from './sortable-header'
|
||||
|
||||
declare module '@tanstack/react-table' {
|
||||
@@ -37,14 +39,14 @@ export const gameColumns: ColumnDef<Game>[] = [
|
||||
(table.getIsSomePageRowsSelected() && 'indeterminate')
|
||||
}
|
||||
onCheckedChange={(v) => table.toggleAllRowsSelected(!!v)}
|
||||
aria-label="Select all"
|
||||
aria-label={t('table.selectAll')}
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onCheckedChange={(v) => row.toggleSelected(!!v)}
|
||||
aria-label="Select row"
|
||||
aria-label={t('table.selectRow')}
|
||||
/>
|
||||
),
|
||||
},
|
||||
@@ -56,21 +58,18 @@ export const gameColumns: ColumnDef<Game>[] = [
|
||||
enableColumnFilter: false,
|
||||
size: 80,
|
||||
meta: { priority: 1 },
|
||||
cell: ({ row }) =>
|
||||
row.original.thumbnail ? (
|
||||
<img
|
||||
src={row.original.thumbnail}
|
||||
alt=""
|
||||
width={64}
|
||||
height={40}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchPriority="low"
|
||||
className="h-10 w-16 rounded object-cover"
|
||||
/>
|
||||
) : (
|
||||
<div aria-hidden="true" className="h-10 w-16 rounded bg-muted" />
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<GameThumb
|
||||
src={row.original.thumbnail}
|
||||
alt=""
|
||||
width={64}
|
||||
height={40}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchPriority="low"
|
||||
className="h-10 w-16 rounded object-cover"
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'name',
|
||||
@@ -78,7 +77,7 @@ export const gameColumns: ColumnDef<Game>[] = [
|
||||
meta: { priority: 1 },
|
||||
header: ({ column }) => (
|
||||
<SortableHeader
|
||||
label="Name"
|
||||
label={t('table.name')}
|
||||
sorted={column.getIsSorted()}
|
||||
onClick={(e) => column.toggleSorting(undefined, e.shiftKey)}
|
||||
/>
|
||||
@@ -98,7 +97,7 @@ export const gameColumns: ColumnDef<Game>[] = [
|
||||
meta: { priority: 3 },
|
||||
header: ({ column }) => (
|
||||
<SortableHeader
|
||||
label="Dev"
|
||||
label={t('table.dev')}
|
||||
sorted={column.getIsSorted()}
|
||||
onClick={(e) => column.toggleSorting(undefined, e.shiftKey)}
|
||||
/>
|
||||
@@ -110,15 +109,15 @@ export const gameColumns: ColumnDef<Game>[] = [
|
||||
{
|
||||
id: 'genre',
|
||||
accessorKey: 'genre',
|
||||
header: 'Genre',
|
||||
header: () => t('table.genre'),
|
||||
meta: { priority: 2 },
|
||||
filterFn: arrayIncludesAny,
|
||||
cell: ({ row }) => <Badge variant="secondary">{row.original.genre || 'Unknown'}</Badge>,
|
||||
cell: ({ row }) => <Badge variant="secondary">{row.original.genre || t('common.unknown')}</Badge>,
|
||||
},
|
||||
{
|
||||
id: 'platforms',
|
||||
accessorKey: 'platforms',
|
||||
header: 'Platforms',
|
||||
header: () => t('table.platforms'),
|
||||
enableSorting: false,
|
||||
meta: { priority: 3 },
|
||||
filterFn: arrayIncludesAny,
|
||||
@@ -138,7 +137,7 @@ export const gameColumns: ColumnDef<Game>[] = [
|
||||
meta: { priority: 2 },
|
||||
header: ({ column }) => (
|
||||
<SortableHeader
|
||||
label="Rating"
|
||||
label={t('table.rating')}
|
||||
sorted={column.getIsSorted()}
|
||||
onClick={(e) => column.toggleSorting(undefined, e.shiftKey)}
|
||||
/>
|
||||
@@ -160,32 +159,32 @@ export const gameColumns: ColumnDef<Game>[] = [
|
||||
{
|
||||
id: 'status',
|
||||
accessorKey: 'status',
|
||||
header: 'Status',
|
||||
header: () => t('table.status'),
|
||||
meta: { priority: 3 },
|
||||
filterFn: arrayIncludesAny,
|
||||
cell: ({ row }) => (
|
||||
<Badge variant={row.original.status === 'Released' ? 'default' : 'secondary'}>
|
||||
{row.original.status || 'Unknown'}
|
||||
{row.original.status || t('common.unknown')}
|
||||
</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'nsfw',
|
||||
accessorKey: 'nsfw',
|
||||
header: 'NSFW',
|
||||
header: () => t('table.nsfw'),
|
||||
meta: { priority: 2 },
|
||||
filterFn: arrayIncludesAny,
|
||||
cell: ({ row }) =>
|
||||
row.original.nsfw === 'Yes' ? (
|
||||
<Badge variant="destructive">NSFW</Badge>
|
||||
) : (
|
||||
<span className="text-xs text-muted-foreground">No</span>
|
||||
<span className="text-xs text-muted-foreground">{t('common.no')}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'safe_virus',
|
||||
accessorKey: 'safe_virus',
|
||||
header: 'Safe',
|
||||
header: () => t('table.safe'),
|
||||
meta: { priority: 3 },
|
||||
filterFn: arrayIncludesAny,
|
||||
cell: ({ row }) => (
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
SelectValue,
|
||||
} from '@/components/ui/select'
|
||||
import { formatNumber } from '@/lib/utils'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
const PAGE_SIZE_OPTIONS = [50, 100, 200, 500] as const
|
||||
|
||||
@@ -17,6 +18,7 @@ interface DataTablePaginationProps<TData> {
|
||||
}
|
||||
|
||||
export function DataTablePagination<TData>({ table }: DataTablePaginationProps<TData>) {
|
||||
const t = useT()
|
||||
const { pageIndex, pageSize } = table.getState().pagination
|
||||
const filteredRows = table.getFilteredRowModel().rows.length
|
||||
const pageCount = table.getPageCount()
|
||||
@@ -27,13 +29,17 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 px-1 py-2">
|
||||
<div className="text-sm text-muted-foreground">
|
||||
{filteredRows === 0
|
||||
? 'No results'
|
||||
: `Showing ${formatNumber(start)}–${formatNumber(end)} of ${formatNumber(filteredRows)}`}
|
||||
? t('table.noResults')
|
||||
: t('table.showingRange', {
|
||||
start: formatNumber(start),
|
||||
end: formatNumber(end),
|
||||
total: formatNumber(filteredRows),
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<p className="text-sm">Rows per page</p>
|
||||
<p className="text-sm">{t('table.rowsPerPage')}</p>
|
||||
<Select
|
||||
value={`${pageSize}`}
|
||||
onValueChange={(v) => table.setPageSize(Number(v))}
|
||||
@@ -52,7 +58,7 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
|
||||
</div>
|
||||
|
||||
<div className="text-sm tabular-nums">
|
||||
Page {pageCount === 0 ? 0 : pageIndex + 1} of {pageCount}
|
||||
{t('table.pageOf', { page: pageCount === 0 ? 0 : pageIndex + 1, total: pageCount })}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
@@ -62,7 +68,7 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
|
||||
className="h-8 w-8"
|
||||
onClick={() => table.setPageIndex(0)}
|
||||
disabled={!table.getCanPreviousPage()}
|
||||
aria-label="First page"
|
||||
aria-label={t('table.firstPage')}
|
||||
>
|
||||
<ChevronsLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
@@ -72,7 +78,7 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
|
||||
className="h-8 w-8"
|
||||
onClick={() => table.previousPage()}
|
||||
disabled={!table.getCanPreviousPage()}
|
||||
aria-label="Previous page"
|
||||
aria-label={t('table.prevPage')}
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
@@ -82,7 +88,7 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
|
||||
className="h-8 w-8"
|
||||
onClick={() => table.nextPage()}
|
||||
disabled={!table.getCanNextPage()}
|
||||
aria-label="Next page"
|
||||
aria-label={t('table.nextPage')}
|
||||
>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</Button>
|
||||
@@ -92,7 +98,7 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
|
||||
className="h-8 w-8"
|
||||
onClick={() => table.setPageIndex(pageCount - 1)}
|
||||
disabled={!table.getCanNextPage()}
|
||||
aria-label="Last page"
|
||||
aria-label={t('table.lastPage')}
|
||||
>
|
||||
<ChevronsRight className="h-4 w-4" />
|
||||
</Button>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { FacetedFilter, type FacetOption } from './faceted-filter'
|
||||
import type { Table } from '@tanstack/react-table'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
interface DataTableToolbarProps<TData> {
|
||||
table: Table<TData>
|
||||
@@ -17,6 +18,7 @@ export function DataTableToolbar<TData>({
|
||||
onGlobalFilterChange,
|
||||
facets,
|
||||
}: DataTableToolbarProps<TData>) {
|
||||
const t = useT()
|
||||
const isFiltered = table.getState().columnFilters.length > 0 || globalFilter.length > 0
|
||||
|
||||
return (
|
||||
@@ -24,7 +26,7 @@ export function DataTableToolbar<TData>({
|
||||
<div className="relative min-w-[240px] flex-1">
|
||||
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="Search name, dev, description..."
|
||||
placeholder={t('table.searchPlaceholder')}
|
||||
value={globalFilter}
|
||||
onChange={(e) => onGlobalFilterChange(e.target.value)}
|
||||
className="h-9 pl-9"
|
||||
@@ -47,7 +49,7 @@ export function DataTableToolbar<TData>({
|
||||
onGlobalFilterChange('')
|
||||
}}
|
||||
>
|
||||
Reset
|
||||
{t('table.reset')}
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -17,6 +17,7 @@ import { useVirtualizer } from '@tanstack/react-virtual'
|
||||
import { DataTablePagination } from './data-table-pagination'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useIsMobile } from '@/lib/use-is-mobile'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
const ROW_HEIGHT = 56
|
||||
|
||||
@@ -63,6 +64,7 @@ export function DataTable<TData>({
|
||||
getRowId,
|
||||
renderMobileList,
|
||||
}: DataTableProps<TData>) {
|
||||
const t = useT()
|
||||
const isMobile = useIsMobile()
|
||||
const enablePagination = !!pagination && !!onPaginationChange
|
||||
const table = useReactTable({
|
||||
@@ -162,7 +164,7 @@ export function DataTable<TData>({
|
||||
{rows.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={columns.length} className="h-24 text-center text-muted-foreground">
|
||||
No results.
|
||||
{t('table.noResults')}
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Button } from '@/components/ui/button'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
export interface FacetOption {
|
||||
value: string
|
||||
@@ -20,6 +21,7 @@ interface FacetedFilterProps<TData> {
|
||||
}
|
||||
|
||||
export function FacetedFilter<TData>({ column, title, options }: FacetedFilterProps<TData>) {
|
||||
const t = useT()
|
||||
const rawFilterValue = column?.getFilterValue() as string[] | undefined
|
||||
const selected = useMemo(() => new Set(rawFilterValue ?? []), [rawFilterValue])
|
||||
|
||||
@@ -52,7 +54,7 @@ export function FacetedFilter<TData>({ column, title, options }: FacetedFilterPr
|
||||
</div>
|
||||
<div className="max-h-72 overflow-y-auto p-1">
|
||||
{options.length === 0 ? (
|
||||
<p className="p-3 text-sm text-muted-foreground">No options</p>
|
||||
<p className="p-3 text-sm text-muted-foreground">{t('table.noOptions')}</p>
|
||||
) : (
|
||||
options.map((opt) => {
|
||||
const isSelected = selected.has(opt.value)
|
||||
@@ -82,7 +84,7 @@ export function FacetedFilter<TData>({ column, title, options }: FacetedFilterPr
|
||||
onClick={() => column?.setFilterValue(undefined)}
|
||||
className="w-full rounded-sm px-2 py-1.5 text-center text-sm hover:bg-accent"
|
||||
>
|
||||
Clear filters
|
||||
{t('table.clearFilters')}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -2,8 +2,10 @@ import { Link } from 'react-router-dom'
|
||||
import type { Row } from '@tanstack/react-table'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { GameThumb } from '@/components/game-thumb'
|
||||
import type { Game } from '@/types/game'
|
||||
import { slugify } from '@/lib/utils'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
interface MobileCardListProps {
|
||||
rows: Row<Game>[]
|
||||
@@ -11,10 +13,11 @@ interface MobileCardListProps {
|
||||
}
|
||||
|
||||
export function MobileCardList({ rows, selectable }: MobileCardListProps) {
|
||||
const t = useT()
|
||||
if (rows.length === 0) {
|
||||
return (
|
||||
<div className="rounded-md border bg-card p-6 text-center text-sm text-muted-foreground">
|
||||
No results.
|
||||
{t('table.noResults')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -32,7 +35,7 @@ export function MobileCardList({ rows, selectable }: MobileCardListProps) {
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onCheckedChange={(v) => row.toggleSelected(!!v)}
|
||||
aria-label={`Select ${g.name}`}
|
||||
aria-label={t('table.selectGame', { name: g.name })}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@@ -40,22 +43,15 @@ export function MobileCardList({ rows, selectable }: MobileCardListProps) {
|
||||
to={`/games/${encodeURIComponent(slug)}`}
|
||||
className="flex min-w-0 flex-1 gap-3"
|
||||
>
|
||||
{g.thumbnail ? (
|
||||
<img
|
||||
src={g.thumbnail}
|
||||
alt=""
|
||||
width={72}
|
||||
height={56}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
className="h-14 w-[72px] shrink-0 rounded object-cover"
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="h-14 w-[72px] shrink-0 rounded bg-muted"
|
||||
/>
|
||||
)}
|
||||
<GameThumb
|
||||
src={g.thumbnail || undefined}
|
||||
alt=""
|
||||
width={72}
|
||||
height={56}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
className="h-14 w-[72px] shrink-0 rounded object-cover"
|
||||
/>
|
||||
<div className="min-w-0 flex-1 space-y-1">
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<h3 className="line-clamp-2 text-sm font-medium leading-tight">
|
||||
|
||||
@@ -18,6 +18,7 @@ import { useAuth } from '@/stores/auth'
|
||||
import { createOctokit } from '@/lib/github/client'
|
||||
import { updateGameInChunk } from '@/lib/github/contents'
|
||||
import { useAllGames } from '@/hooks/useGames'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
|
||||
interface EditGameFormProps {
|
||||
@@ -30,6 +31,7 @@ const SAFE_OPTIONS = ['?', 'Yes', 'No', 'Caution'] as const
|
||||
const NOTES_MAX = 500
|
||||
|
||||
export function EditGameForm({ game, onCancel, onSaved }: EditGameFormProps) {
|
||||
const t = useT()
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const all = useAllGames()
|
||||
const qc = useQueryClient()
|
||||
@@ -43,17 +45,26 @@ export function EditGameForm({ game, onCancel, onSaved }: EditGameFormProps) {
|
||||
notes !== (game.notes || '') ||
|
||||
nsfw !== (game.nsfw === 'Yes')
|
||||
|
||||
const safeLabel = (o: string) =>
|
||||
o === 'Yes'
|
||||
? t('common.yes')
|
||||
: o === 'No'
|
||||
? t('common.no')
|
||||
: o === 'Caution'
|
||||
? t('editForm.safe.caution')
|
||||
: o
|
||||
|
||||
async function handleSave() {
|
||||
if (!pat) {
|
||||
toast.error('Unlock your PAT in Settings first.')
|
||||
toast.error(t('editForm.toast.unlockPat'))
|
||||
return
|
||||
}
|
||||
if (!all.data) {
|
||||
toast.error('Game cache not loaded yet.')
|
||||
toast.error(t('editForm.toast.cacheNotLoaded'))
|
||||
return
|
||||
}
|
||||
if (notes.length > NOTES_MAX) {
|
||||
toast.error(`Notes too long (${notes.length}/${NOTES_MAX}).`)
|
||||
toast.error(t('editForm.toast.notesTooLong', { len: notes.length, max: NOTES_MAX }))
|
||||
return
|
||||
}
|
||||
setBusy(true)
|
||||
@@ -70,15 +81,15 @@ export function EditGameForm({ game, onCancel, onSaved }: EditGameFormProps) {
|
||||
},
|
||||
`chore(webapp): update annotations for ${game.name}`,
|
||||
)
|
||||
toast.success(`Saved to ${chunkFile} (${commitSha.slice(0, 7)})`)
|
||||
toast.success(t('editForm.toast.saved', { file: chunkFile, sha: commitSha.slice(0, 7) }))
|
||||
await qc.invalidateQueries({ queryKey: ['db'] })
|
||||
onSaved()
|
||||
} catch (err) {
|
||||
const msg = (err as Error).message
|
||||
if (msg.includes('does not match') || msg.includes('409')) {
|
||||
toast.error('Conflict: file changed on the remote. Refresh and re-edit.')
|
||||
toast.error(t('editForm.toast.conflict'))
|
||||
} else {
|
||||
toast.error(`Save failed: ${msg}`)
|
||||
toast.error(t('editForm.toast.saveFailed', { msg }))
|
||||
}
|
||||
} finally {
|
||||
setBusy(false)
|
||||
@@ -88,14 +99,12 @@ export function EditGameForm({ game, onCancel, onSaved }: EditGameFormProps) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Edit Annotations</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Three user-editable fields. Everything else is auto-fetched and read-only.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('editForm.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('editForm.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="safe-virus">Safe / virus</Label>
|
||||
<Label htmlFor="safe-virus">{t('editForm.field.safeVirus')}</Label>
|
||||
<Select value={safeVirus} onValueChange={setSafeVirus}>
|
||||
<SelectTrigger id="safe-virus" className="w-40">
|
||||
<SelectValue />
|
||||
@@ -103,7 +112,7 @@ export function EditGameForm({ game, onCancel, onSaved }: EditGameFormProps) {
|
||||
<SelectContent>
|
||||
{SAFE_OPTIONS.map((opt) => (
|
||||
<SelectItem key={opt} value={opt}>
|
||||
{opt}
|
||||
{safeLabel(opt)}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
@@ -113,13 +122,13 @@ export function EditGameForm({ game, onCancel, onSaved }: EditGameFormProps) {
|
||||
<div className="flex items-center gap-3">
|
||||
<Switch id="nsfw" checked={nsfw} onCheckedChange={setNsfw} />
|
||||
<Label htmlFor="nsfw" className="cursor-pointer">
|
||||
NSFW (override auto-detection)
|
||||
{t('editForm.field.nsfw')}
|
||||
</Label>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<div className="flex items-baseline justify-between">
|
||||
<Label htmlFor="notes">Notes</Label>
|
||||
<Label htmlFor="notes">{t('editForm.field.notes')}</Label>
|
||||
<span
|
||||
className={
|
||||
notes.length > NOTES_MAX
|
||||
@@ -135,23 +144,21 @@ export function EditGameForm({ game, onCancel, onSaved }: EditGameFormProps) {
|
||||
value={notes}
|
||||
onChange={(e) => setNotes(e.target.value)}
|
||||
rows={4}
|
||||
placeholder="Free-form notes (markdown allowed)"
|
||||
placeholder={t('editForm.notesPlaceholder')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 pt-2">
|
||||
<Button onClick={handleSave} disabled={!dirty || busy || !pat}>
|
||||
<Save className="h-4 w-4" />
|
||||
{busy ? 'Saving...' : 'Save'}
|
||||
{busy ? t('editForm.saving') : t('common.save')}
|
||||
</Button>
|
||||
<Button variant="ghost" onClick={onCancel} disabled={busy}>
|
||||
<X className="h-4 w-4" />
|
||||
Cancel
|
||||
{t('common.cancel')}
|
||||
</Button>
|
||||
{!pat && (
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Unlock your PAT in Settings to enable Save.
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">{t('editForm.unlockHint')}</span>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Component, type ReactNode } from 'react'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import { RotateCw } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { ErrorPage } from '@/components/error-page'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
// Vite emits hashed chunk filenames; after a redeploy the old hashes 404 and
|
||||
// React.lazy rejects with one of these messages (browser-dependent).
|
||||
const CHUNK_ERR =
|
||||
/failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed|chunkloaderror/i
|
||||
|
||||
function ReloadAction() {
|
||||
const t = useT()
|
||||
return (
|
||||
<Button onClick={() => window.location.reload()}>
|
||||
<RotateCw className="h-4 w-4" />
|
||||
{t('error.actions.reload')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
interface BoundaryState {
|
||||
error: Error | null
|
||||
}
|
||||
|
||||
class AppErrorBoundary extends Component<{ children: ReactNode }, BoundaryState> {
|
||||
state: BoundaryState = { error: null }
|
||||
|
||||
static getDerivedStateFromError(error: Error): BoundaryState {
|
||||
return { error }
|
||||
}
|
||||
|
||||
render() {
|
||||
const { error } = this.state
|
||||
if (!error) return this.props.children
|
||||
const isChunk = CHUNK_ERR.test(error.message)
|
||||
return (
|
||||
<ErrorPage
|
||||
variant={isChunk ? 'chunk' : undefined}
|
||||
status={isChunk ? undefined : 500}
|
||||
details={error.message}
|
||||
actions={<ReloadAction />}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Route-level boundary: keyed by pathname so navigating away resets it
|
||||
* (which also retries a previously failed lazy import).
|
||||
*/
|
||||
export function RouteErrorBoundary({ children }: { children: ReactNode }) {
|
||||
const location = useLocation()
|
||||
return <AppErrorBoundary key={location.pathname}>{children}</AppErrorBoundary>
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import {
|
||||
Bug,
|
||||
CircleAlert,
|
||||
CloudOff,
|
||||
FileWarning,
|
||||
Gauge,
|
||||
Home,
|
||||
Hourglass,
|
||||
Lock,
|
||||
RefreshCw,
|
||||
SearchX,
|
||||
ServerCrash,
|
||||
ShieldAlert,
|
||||
TimerOff,
|
||||
TimerReset,
|
||||
Unplug,
|
||||
WifiOff,
|
||||
type LucideIcon,
|
||||
} from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { ExtLink } from '@/components/ext-link'
|
||||
import { ERROR_TEMPLATE_URL } from '@/lib/about'
|
||||
import { useT, type MessageKey } from '@/lib/i18n'
|
||||
|
||||
interface ErrorMeta {
|
||||
icon: LucideIcon
|
||||
title: MessageKey
|
||||
desc: MessageKey
|
||||
}
|
||||
|
||||
// Keyed by HTTP status (as string) plus the two non-HTTP variants.
|
||||
const META: Record<string, ErrorMeta> = {
|
||||
'400': { icon: FileWarning, title: 'error.400.title', desc: 'error.400.desc' },
|
||||
'401': { icon: Lock, title: 'error.401.title', desc: 'error.401.desc' },
|
||||
'403': { icon: ShieldAlert, title: 'error.403.title', desc: 'error.403.desc' },
|
||||
'404': { icon: SearchX, title: 'error.404.title', desc: 'error.404.desc' },
|
||||
'408': { icon: TimerOff, title: 'error.408.title', desc: 'error.408.desc' },
|
||||
'419': { icon: TimerReset, title: 'error.419.title', desc: 'error.419.desc' },
|
||||
'429': { icon: Gauge, title: 'error.429.title', desc: 'error.429.desc' },
|
||||
'500': { icon: ServerCrash, title: 'error.500.title', desc: 'error.500.desc' },
|
||||
'502': { icon: Unplug, title: 'error.502.title', desc: 'error.502.desc' },
|
||||
'503': { icon: CloudOff, title: 'error.503.title', desc: 'error.503.desc' },
|
||||
'504': { icon: Hourglass, title: 'error.504.title', desc: 'error.504.desc' },
|
||||
offline: { icon: WifiOff, title: 'error.offline.title', desc: 'error.offline.desc' },
|
||||
chunk: { icon: RefreshCw, title: 'error.chunk.title', desc: 'error.chunk.desc' },
|
||||
unknown: { icon: CircleAlert, title: 'error.unknown.title', desc: 'error.unknown.desc' },
|
||||
}
|
||||
|
||||
export interface ErrorPageProps {
|
||||
/** HTTP status code; unmapped codes fall back to the "unknown" treatment. */
|
||||
status?: number
|
||||
/** Non-HTTP variants (network down, stale chunk after redeploy). Wins over `status`. */
|
||||
variant?: 'offline' | 'chunk'
|
||||
/** Override the mapped title/description (e.g. game-not-found). */
|
||||
title?: string
|
||||
description?: string
|
||||
/** Raw error message, shown collapsed under "Technical details". */
|
||||
details?: string
|
||||
onRetry?: () => void
|
||||
/** Replaces the default "Back to dashboard" action. */
|
||||
actions?: ReactNode
|
||||
}
|
||||
|
||||
export function ErrorPage({
|
||||
status,
|
||||
variant,
|
||||
title,
|
||||
description,
|
||||
details,
|
||||
onRetry,
|
||||
actions,
|
||||
}: ErrorPageProps) {
|
||||
const t = useT()
|
||||
const meta = META[variant ?? String(status ?? '')] ?? META.unknown
|
||||
const Icon = meta.icon
|
||||
return (
|
||||
<div className="flex h-full min-h-[60vh] items-center justify-center p-6">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardContent className="flex flex-col items-center gap-4 p-8 text-center">
|
||||
<Icon className="h-12 w-12 text-muted-foreground" aria-hidden="true" />
|
||||
{!variant && status !== undefined && (
|
||||
<p className="text-6xl font-bold tabular-nums tracking-tight">{status}</p>
|
||||
)}
|
||||
<h1 className="text-2xl font-semibold tracking-tight">{title ?? t(meta.title)}</h1>
|
||||
<p className="text-sm text-muted-foreground">{description ?? t(meta.desc)}</p>
|
||||
{details && (
|
||||
<details className="w-full text-left">
|
||||
<summary className="cursor-pointer text-xs text-muted-foreground">
|
||||
{t('error.actions.details')}
|
||||
</summary>
|
||||
<pre className="mt-2 max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs">
|
||||
{details}
|
||||
</pre>
|
||||
</details>
|
||||
)}
|
||||
<div className="flex flex-wrap items-center justify-center gap-2 pt-2">
|
||||
{onRetry && (
|
||||
<Button onClick={onRetry}>
|
||||
<RefreshCw className="h-4 w-4" />
|
||||
{t('common.retry')}
|
||||
</Button>
|
||||
)}
|
||||
{actions ?? (
|
||||
<Button variant={onRetry ? 'outline' : 'default'} asChild>
|
||||
<Link to="/">
|
||||
<Home className="h-4 w-4" />
|
||||
{t('error.actions.home')}
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
<Button variant="ghost" size="sm" asChild>
|
||||
<ExtLink href={ERROR_TEMPLATE_URL}>
|
||||
<Bug className="h-4 w-4" />
|
||||
{t('error.actions.report')}
|
||||
</ExtLink>
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { useState } from 'react'
|
||||
import type { ImgHTMLAttributes } from 'react'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
interface GameThumbProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'src' | 'onError'> {
|
||||
src: string | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Game cover image that degrades to the muted placeholder when the URL is
|
||||
* empty or the image fails to load (itch.zone covers occasionally 404).
|
||||
* Failure is tracked per-src so recycled rows (sort/filter) recover.
|
||||
*/
|
||||
export function GameThumb({ src, alt = '', className, ...rest }: GameThumbProps) {
|
||||
const [failedSrc, setFailedSrc] = useState<string | null>(null)
|
||||
if (!src || failedSrc === src) {
|
||||
return <div aria-hidden="true" className={cn('bg-muted', className)} />
|
||||
}
|
||||
return (
|
||||
<img
|
||||
src={src}
|
||||
alt={alt}
|
||||
className={className}
|
||||
onError={() => setFailedSrc(src)}
|
||||
{...rest}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { ErrorPage } from '@/components/error-page'
|
||||
import { errorStatus, isNetworkError } from '@/lib/http-error'
|
||||
|
||||
interface RouteErrorProps {
|
||||
error: unknown
|
||||
onRetry?: () => void
|
||||
}
|
||||
|
||||
/** Maps a thrown query/fetch error to the matching full-pane error page. */
|
||||
export function RouteError({ error, onRetry }: RouteErrorProps) {
|
||||
const status = errorStatus(error)
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return (
|
||||
<ErrorPage
|
||||
status={status}
|
||||
variant={status === undefined && isNetworkError(error) ? 'offline' : undefined}
|
||||
details={message}
|
||||
onRetry={onRetry}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { ArrowUp } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
interface ScrollToTopProps {
|
||||
// The scroll container to watch — the app scrolls <main>, not window.
|
||||
@@ -8,6 +9,7 @@ interface ScrollToTopProps {
|
||||
}
|
||||
|
||||
export default function ScrollToTop({ targetRef }: ScrollToTopProps) {
|
||||
const t = useT()
|
||||
const [visible, setVisible] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -24,7 +26,7 @@ export default function ScrollToTop({ targetRef }: ScrollToTopProps) {
|
||||
return (
|
||||
<Button
|
||||
size="icon"
|
||||
aria-label="Scroll to top"
|
||||
aria-label={t('common.scrollToTop')}
|
||||
onClick={() => targetRef.current?.scrollTo({ top: 0, behavior: 'smooth' })}
|
||||
className="fixed bottom-6 right-6 z-50 h-11 w-11 rounded-full shadow-lg"
|
||||
>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Textarea } from '@/components/ui/textarea'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import { useAuth } from '@/stores/auth'
|
||||
import { useGpg } from '@/stores/gpg'
|
||||
import { usePrefs } from '@/stores/prefs'
|
||||
@@ -21,6 +22,7 @@ function formatFingerprint(fp: string): string {
|
||||
}
|
||||
|
||||
export function GpgCard() {
|
||||
const t = useT()
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const gpg = useGpg()
|
||||
const prefs = usePrefs()
|
||||
@@ -41,11 +43,11 @@ export function GpgCard() {
|
||||
|
||||
async function handleImport() {
|
||||
if (!armoredInput.trim()) {
|
||||
toast.error('Paste or upload an armored GPG private key.')
|
||||
toast.error(t('gpg.toast.pasteKey'))
|
||||
return
|
||||
}
|
||||
if (webappPassphrase.length < 8) {
|
||||
toast.error('Confirm your webapp passphrase (min 8 chars) to encrypt the key locally.')
|
||||
toast.error(t('gpg.toast.confirmPassphrase'))
|
||||
return
|
||||
}
|
||||
setBusy(true)
|
||||
@@ -68,9 +70,9 @@ export function GpgCard() {
|
||||
setArmoredInput('')
|
||||
setGpgPassphrase('')
|
||||
setWebappPassphrase('')
|
||||
toast.success(`Imported ${formatFingerprint(fingerprint)} — signing enabled.`)
|
||||
toast.success(t('gpg.toast.imported', { fingerprint: formatFingerprint(fingerprint) }))
|
||||
} catch (err) {
|
||||
toast.error(`Import failed: ${(err as Error).message}`)
|
||||
toast.error(t('gpg.toast.importFailed', { message: (err as Error).message }))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
@@ -79,11 +81,11 @@ export function GpgCard() {
|
||||
async function handleUnlock() {
|
||||
const packed = readEncryptedGpg()
|
||||
if (!packed) {
|
||||
toast.error('No GPG key stored.')
|
||||
toast.error(t('gpg.toast.noStoredKey'))
|
||||
return
|
||||
}
|
||||
if (!unlockPassphrase) {
|
||||
toast.error('Enter your webapp passphrase.')
|
||||
toast.error(t('gpg.toast.enterPassphrase'))
|
||||
return
|
||||
}
|
||||
setBusy(true)
|
||||
@@ -94,9 +96,9 @@ export function GpgCard() {
|
||||
const { key, fingerprint, uid, emails } = await loadPrivateKey(decryptedArmored, null)
|
||||
gpg.setKey(key, fingerprint, uid, emails)
|
||||
setUnlockPassphrase('')
|
||||
toast.success(`Signing unlocked (${formatFingerprint(fingerprint)}).`)
|
||||
toast.success(t('gpg.toast.unlocked', { fingerprint: formatFingerprint(fingerprint) }))
|
||||
} catch (err) {
|
||||
toast.error(`Unlock failed: ${(err as Error).message}`)
|
||||
toast.error(t('gpg.toast.unlockFailed', { message: (err as Error).message }))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
@@ -104,14 +106,14 @@ export function GpgCard() {
|
||||
|
||||
function handleLock() {
|
||||
gpg.lock()
|
||||
toast.info('Signing locked. Re-enter your passphrase to unlock.')
|
||||
toast.info(t('gpg.toast.locked'))
|
||||
}
|
||||
|
||||
function handleRemove() {
|
||||
if (!confirm('Remove the encrypted GPG key from this browser? You will need to re-import it.'))
|
||||
if (!confirm(t('gpg.confirm.remove')))
|
||||
return
|
||||
gpg.remove()
|
||||
toast.success('GPG key removed.')
|
||||
toast.success(t('gpg.toast.removed'))
|
||||
}
|
||||
|
||||
async function handleCopyPublic() {
|
||||
@@ -119,11 +121,9 @@ export function GpgCard() {
|
||||
try {
|
||||
const armored = gpg.privateKey.toPublic().armor()
|
||||
await navigator.clipboard.writeText(armored)
|
||||
toast.success(
|
||||
'Public key copied. Paste it into github.com/settings/keys → New GPG key.',
|
||||
)
|
||||
toast.success(t('gpg.toast.publicCopied'))
|
||||
} catch (err) {
|
||||
toast.error(`Copy failed: ${(err as Error).message}`)
|
||||
toast.error(t('gpg.toast.copyFailed', { message: (err as Error).message }))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,12 +148,10 @@ export function GpgCard() {
|
||||
const pubArmored = gpg.privateKey.toPublic().armor()
|
||||
const ok = await verifyDetached(pubArmored, canonical, sig)
|
||||
toast[ok ? 'success' : 'error'](
|
||||
ok
|
||||
? 'Round-trip verified: signing is wired correctly.'
|
||||
: 'Signature failed verification — please re-import the key.',
|
||||
ok ? t('gpg.toast.testOk') : t('gpg.toast.testFail'),
|
||||
)
|
||||
} catch (err) {
|
||||
toast.error(`Test sign failed: ${(err as Error).message}`)
|
||||
toast.error(t('gpg.toast.testError', { message: (err as Error).message }))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
@@ -164,28 +162,26 @@ export function GpgCard() {
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 text-base">
|
||||
<KeyRound className="h-4 w-4" />
|
||||
Commit signing (GPG)
|
||||
{t('gpg.title')}
|
||||
</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Sign every commit this app makes so they show as <b>Verified</b> on GitHub. The private
|
||||
key is decrypted once at import and re-encrypted with your webapp passphrase (AES-GCM)
|
||||
before being stored in localStorage — same scheme as the PAT.
|
||||
{t('gpg.desc.1')} <b>Verified</b> {t('gpg.desc.2')}
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-5">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<div className="text-sm">
|
||||
Status:{' '}
|
||||
{t('gpg.status')}{' '}
|
||||
{gpg.privateKey ? (
|
||||
<Badge variant="default">
|
||||
<Unlock className="mr-1 h-3 w-3" /> Unlocked
|
||||
<Unlock className="mr-1 h-3 w-3" /> {t('gpg.status.unlocked')}
|
||||
</Badge>
|
||||
) : gpg.hasStoredGpg ? (
|
||||
<Badge variant="secondary">
|
||||
<Lock className="mr-1 h-3 w-3" /> Saved (locked)
|
||||
<Lock className="mr-1 h-3 w-3" /> {t('gpg.status.savedLocked')}
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="outline">No key imported</Badge>
|
||||
<Badge variant="outline">{t('gpg.status.noKey')}</Badge>
|
||||
)}
|
||||
</div>
|
||||
{gpg.fingerprint && (
|
||||
@@ -205,9 +201,9 @@ export function GpgCard() {
|
||||
{gpg.hasStoredGpg && (
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="gpg-enabled">Sign commits</Label>
|
||||
<Label htmlFor="gpg-enabled">{t('gpg.signCommits')}</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Turn off to keep the key imported but commit unsigned.
|
||||
{t('gpg.signCommits.desc')}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
@@ -224,40 +220,40 @@ export function GpgCard() {
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button onClick={handleTestSign} disabled={busy} variant="outline" size="sm">
|
||||
<ShieldCheck className="h-4 w-4" />
|
||||
Test sign
|
||||
{t('gpg.testSign')}
|
||||
</Button>
|
||||
<Button onClick={handleCopyPublic} disabled={busy} variant="outline" size="sm">
|
||||
Copy public key
|
||||
{t('gpg.copyPublic')}
|
||||
</Button>
|
||||
<Button onClick={handleLock} variant="outline" size="sm">
|
||||
<Lock className="h-4 w-4" />
|
||||
Lock
|
||||
{t('gpg.lock')}
|
||||
</Button>
|
||||
<Button onClick={handleRemove} variant="destructive" size="sm">
|
||||
<Trash2 className="h-4 w-4" />
|
||||
Remove key
|
||||
{t('gpg.removeKey')}
|
||||
</Button>
|
||||
</div>
|
||||
) : gpg.hasStoredGpg ? (
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="gpg-unlock-pass">Webapp passphrase</Label>
|
||||
<Label htmlFor="gpg-unlock-pass">{t('gpg.webappPassphrase')}</Label>
|
||||
<Input
|
||||
id="gpg-unlock-pass"
|
||||
type="password"
|
||||
value={unlockPassphrase}
|
||||
onChange={(e) => setUnlockPassphrase(e.target.value)}
|
||||
placeholder="The passphrase that encrypts your PAT"
|
||||
placeholder={t('gpg.unlockPlaceholder')}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleUnlock()}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button onClick={handleUnlock} disabled={busy}>
|
||||
<Unlock className="h-4 w-4" />
|
||||
Unlock
|
||||
{t('gpg.unlock')}
|
||||
</Button>
|
||||
<Button onClick={handleRemove} variant="ghost" size="sm">
|
||||
Remove key
|
||||
{t('gpg.removeKey')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -265,11 +261,11 @@ export function GpgCard() {
|
||||
<div className="space-y-3">
|
||||
{!pat && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Unlock your PAT first so we can use the same passphrase to encrypt the key.
|
||||
{t('gpg.patFirst')}
|
||||
</p>
|
||||
)}
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="gpg-armored">Armored private key</Label>
|
||||
<Label htmlFor="gpg-armored">{t('gpg.armoredKey')}</Label>
|
||||
<Textarea
|
||||
id="gpg-armored"
|
||||
rows={6}
|
||||
@@ -285,7 +281,7 @@ export function GpgCard() {
|
||||
onClick={() => fileRef.current?.click()}
|
||||
type="button"
|
||||
>
|
||||
Upload .asc / .key
|
||||
{t('gpg.upload')}
|
||||
</Button>
|
||||
<input
|
||||
ref={fileRef}
|
||||
@@ -295,43 +291,43 @@ export function GpgCard() {
|
||||
onChange={handleFileUpload}
|
||||
/>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Or paste from <code>gpg --export-secret-keys --armor <key-id></code>
|
||||
{t('gpg.pasteFrom')} <code>gpg --export-secret-keys --armor <key-id></code>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="gpg-pass">GPG key passphrase</Label>
|
||||
<Label htmlFor="gpg-pass">{t('gpg.keyPassphrase')}</Label>
|
||||
<Input
|
||||
id="gpg-pass"
|
||||
type="password"
|
||||
value={gpgPassphrase}
|
||||
onChange={(e) => setGpgPassphrase(e.target.value)}
|
||||
placeholder="Leave blank if the key has no passphrase"
|
||||
placeholder={t('gpg.keyPassphrasePlaceholder')}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="gpg-wapp-pass">Webapp passphrase</Label>
|
||||
<Label htmlFor="gpg-wapp-pass">{t('gpg.webappPassphrase')}</Label>
|
||||
<Input
|
||||
id="gpg-wapp-pass"
|
||||
type="password"
|
||||
value={webappPassphrase}
|
||||
onChange={(e) => setWebappPassphrase(e.target.value)}
|
||||
placeholder="Same passphrase used for your PAT — min 8 chars"
|
||||
placeholder={t('gpg.webappPassphrasePlaceholder')}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Used to AES-GCM-encrypt the (already-decrypted) key in localStorage.
|
||||
{t('gpg.webappPassphraseDesc')}
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={handleImport} disabled={busy}>
|
||||
<KeyRound className="h-4 w-4" />
|
||||
Import key
|
||||
{t('gpg.importKey')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Separator />
|
||||
<p className="text-xs text-muted-foreground">
|
||||
The public half of this key must be uploaded to{' '}
|
||||
{t('gpg.footer.1')}{' '}
|
||||
<a
|
||||
href="https://github.com/settings/keys"
|
||||
target="_blank"
|
||||
@@ -340,8 +336,7 @@ export function GpgCard() {
|
||||
>
|
||||
github.com/settings/keys
|
||||
</a>{' '}
|
||||
for the Verified badge to appear. Use <b>Copy public key</b> above (when unlocked) — it
|
||||
puts the armored public block on your clipboard.
|
||||
{t('gpg.footer.2')} <b>{t('gpg.copyPublic')}</b> {t('gpg.footer.3')}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -355,12 +350,13 @@ function EmailMatchInfo({
|
||||
emails: string[]
|
||||
authorEmail: string
|
||||
}) {
|
||||
const t = useT()
|
||||
const trimmed = authorEmail.trim().toLowerCase()
|
||||
const matches = trimmed && emails.some((e) => e.toLowerCase() === trimmed)
|
||||
const noOverride = !trimmed
|
||||
return (
|
||||
<div className="space-y-1.5 rounded-md border bg-muted/30 p-3 text-xs">
|
||||
<div className="font-medium">Key UIDs (one of these must be your commit author email)</div>
|
||||
<div className="font-medium">{t('gpg.uids.title')}</div>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{emails.map((e) => (
|
||||
<Badge
|
||||
@@ -374,19 +370,19 @@ function EmailMatchInfo({
|
||||
</div>
|
||||
{noOverride ? (
|
||||
<p className="text-muted-foreground">
|
||||
No override set in <b>Commit author</b>. The first UID will be used automatically.
|
||||
{t('gpg.uids.noOverride.1')} <b>{t('gpg.commitAuthor')}</b>{t('gpg.uids.noOverride.2')}
|
||||
</p>
|
||||
) : matches ? (
|
||||
<p className="text-green-700 dark:text-green-500">
|
||||
✓ <span className="font-mono">{authorEmail}</span> matches a UID — commits will Verify.
|
||||
✓ <span className="font-mono">{authorEmail}</span> {t('gpg.uids.matches')}
|
||||
</p>
|
||||
) : (
|
||||
<p className="flex items-start gap-1.5 text-amber-700 dark:text-amber-400">
|
||||
<AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
|
||||
<span>
|
||||
<span className="font-mono">{authorEmail}</span> is not in this key's UIDs. GitHub will
|
||||
show <b>"could not be verified"</b> even with a valid signature. Update <b>Commit
|
||||
author</b> above to one of the badges, or clear it to auto-use the primary UID.
|
||||
<span className="font-mono">{authorEmail}</span> {t('gpg.uids.mismatch.1')}{' '}
|
||||
<b>"could not be verified"</b> {t('gpg.uids.mismatch.2')}{' '}
|
||||
<b>{t('gpg.commitAuthor')}</b> {t('gpg.uids.mismatch.3')}
|
||||
</span>
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -24,24 +24,25 @@ import { SyncButton } from '@/components/sync-button'
|
||||
import { useAuth } from '@/stores/auth'
|
||||
import { usePrefs } from '@/stores/prefs'
|
||||
import { isTauri } from '@/lib/runtime'
|
||||
import { useT, type MessageKey } from '@/lib/i18n'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
interface NavItem {
|
||||
to: string
|
||||
label: string
|
||||
label: MessageKey
|
||||
icon: LucideIcon
|
||||
end?: boolean
|
||||
}
|
||||
|
||||
const NAV_ITEMS: NavItem[] = [
|
||||
{ to: '/', label: 'Dashboard', icon: LayoutDashboard, end: true },
|
||||
{ to: '/games', label: 'Games', icon: Gamepad2 },
|
||||
{ to: '/add', label: 'Add Game', icon: Plus },
|
||||
{ to: '/charts', label: 'Charts', icon: BarChart3 },
|
||||
{ to: '/workflows', label: 'Workflows', icon: Workflow },
|
||||
{ to: '/deleted', label: 'Deleted', icon: Trash2 },
|
||||
{ to: '/settings', label: 'Settings', icon: Settings },
|
||||
{ to: '/about', label: 'About', icon: Info },
|
||||
{ to: '/', label: 'nav.dashboard', icon: LayoutDashboard, end: true },
|
||||
{ to: '/games', label: 'nav.games', icon: Gamepad2 },
|
||||
{ to: '/add', label: 'nav.addGame', icon: Plus },
|
||||
{ to: '/charts', label: 'nav.charts', icon: BarChart3 },
|
||||
{ to: '/workflows', label: 'nav.workflows', icon: Workflow },
|
||||
{ to: '/deleted', label: 'nav.deleted', icon: Trash2 },
|
||||
{ to: '/settings', label: 'nav.settings', icon: Settings },
|
||||
{ to: '/about', label: 'nav.about', icon: Info },
|
||||
]
|
||||
|
||||
interface SidebarBodyProps {
|
||||
@@ -56,6 +57,7 @@ function SidebarHeader({
|
||||
variant,
|
||||
onToggleCollapsed,
|
||||
}: Pick<SidebarBodyProps, 'collapsed' | 'variant' | 'onToggleCollapsed'>) {
|
||||
const t = useT()
|
||||
const user = useAuth((s) => s.user)
|
||||
const hasStoredPat = useAuth((s) => s.hasStoredPat)
|
||||
return (
|
||||
@@ -75,7 +77,7 @@ function SidebarHeader({
|
||||
<img
|
||||
src={user.avatar_url}
|
||||
alt={user.login}
|
||||
title={`Signed in as ${user.login}`}
|
||||
title={t('sidebar.signedInAs', { login: user.login })}
|
||||
width={24}
|
||||
height={24}
|
||||
loading="lazy"
|
||||
@@ -83,9 +85,9 @@ function SidebarHeader({
|
||||
className="h-6 w-6 rounded-full"
|
||||
/>
|
||||
) : hasStoredPat ? (
|
||||
<span title="PAT saved but locked" className="h-2 w-2 rounded-full bg-yellow-500" />
|
||||
<span title={t('sidebar.patLocked')} className="h-2 w-2 rounded-full bg-yellow-500" />
|
||||
) : (
|
||||
<span title="No PAT saved" className="h-2 w-2 rounded-full bg-muted-foreground/40" />
|
||||
<span title={t('sidebar.noPat')} className="h-2 w-2 rounded-full bg-muted-foreground/40" />
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
@@ -96,8 +98,8 @@ function SidebarHeader({
|
||||
size="icon"
|
||||
onClick={onToggleCollapsed}
|
||||
className={cn('h-8 w-8', !collapsed && 'ml-1')}
|
||||
title={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
|
||||
aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
|
||||
title={collapsed ? t('sidebar.expand') : t('sidebar.collapse')}
|
||||
aria-label={collapsed ? t('sidebar.expand') : t('sidebar.collapse')}
|
||||
>
|
||||
{collapsed ? <PanelLeft className="h-4 w-4" /> : <PanelLeftClose className="h-4 w-4" />}
|
||||
</Button>
|
||||
@@ -107,6 +109,7 @@ function SidebarHeader({
|
||||
}
|
||||
|
||||
function SidebarNav({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
const t = useT()
|
||||
const isCompact = variant === 'desktop' && collapsed
|
||||
return (
|
||||
<nav className={cn('flex flex-1 flex-col gap-1 p-2', !isCompact && 'p-3')}>
|
||||
@@ -116,7 +119,7 @@ function SidebarNav({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
to={to}
|
||||
end={end}
|
||||
onClick={onNavigate}
|
||||
title={isCompact ? label : undefined}
|
||||
title={isCompact ? t(label) : undefined}
|
||||
className={({ isActive }) =>
|
||||
cn(
|
||||
'flex items-center rounded-md text-sm transition-colors',
|
||||
@@ -128,7 +131,7 @@ function SidebarNav({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
}
|
||||
>
|
||||
<Icon className="h-4 w-4" />
|
||||
{!isCompact && label}
|
||||
{!isCompact && t(label)}
|
||||
</NavLink>
|
||||
))}
|
||||
</nav>
|
||||
@@ -136,6 +139,7 @@ function SidebarNav({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
}
|
||||
|
||||
function SidebarFooter({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
const t = useT()
|
||||
const user = useAuth((s) => s.user)
|
||||
const hasStoredPat = useAuth((s) => s.hasStoredPat)
|
||||
const isCompact = variant === 'desktop' && collapsed
|
||||
@@ -148,7 +152,7 @@ function SidebarFooter({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
>
|
||||
{isTauri() && !isCompact && (
|
||||
<div className="rounded-md bg-secondary px-2 py-1 text-xs text-secondary-foreground">
|
||||
Desktop mode (Tauri)
|
||||
{t('sidebar.desktopMode')}
|
||||
</div>
|
||||
)}
|
||||
{isCompact ? (
|
||||
@@ -158,8 +162,8 @@ function SidebarFooter({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
<NavLink
|
||||
to="/about#support"
|
||||
onClick={onNavigate}
|
||||
title="Support the project"
|
||||
aria-label="Support the project"
|
||||
title={t('sidebar.support')}
|
||||
aria-label={t('sidebar.support')}
|
||||
className="flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"
|
||||
>
|
||||
<Heart className="h-4 w-4" />
|
||||
@@ -168,7 +172,7 @@ function SidebarFooter({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
<img
|
||||
src={user.avatar_url}
|
||||
alt={user.login}
|
||||
title={`Signed in as ${user.login}`}
|
||||
title={t('sidebar.signedInAs', { login: user.login })}
|
||||
width={24}
|
||||
height={24}
|
||||
loading="lazy"
|
||||
@@ -176,9 +180,9 @@ function SidebarFooter({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
className="h-6 w-6 rounded-full"
|
||||
/>
|
||||
) : hasStoredPat ? (
|
||||
<span title="PAT saved but locked" className="h-2 w-2 rounded-full bg-yellow-500" />
|
||||
<span title={t('sidebar.patLocked')} className="h-2 w-2 rounded-full bg-yellow-500" />
|
||||
) : (
|
||||
<span title="No PAT saved" className="h-2 w-2 rounded-full bg-muted-foreground/40" />
|
||||
<span title={t('sidebar.noPat')} className="h-2 w-2 rounded-full bg-muted-foreground/40" />
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
@@ -190,7 +194,7 @@ function SidebarFooter({ collapsed, variant, onNavigate }: SidebarBodyProps) {
|
||||
className="flex items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"
|
||||
>
|
||||
<Heart className="h-3.5 w-3.5" />
|
||||
Support the project
|
||||
{t('sidebar.support')}
|
||||
</NavLink>
|
||||
<ExtLink
|
||||
href="https://github.com/poli0981/free-games-itchio-list"
|
||||
@@ -230,6 +234,7 @@ export function Sidebar() {
|
||||
}
|
||||
|
||||
export function MobileTopBar() {
|
||||
const t = useT()
|
||||
const [open, setOpen] = useState(false)
|
||||
const location = useLocation()
|
||||
useEffect(() => {
|
||||
@@ -242,14 +247,14 @@ export function MobileTopBar() {
|
||||
<header className="flex h-12 items-center justify-between gap-2 border-b bg-card px-2 md:hidden">
|
||||
<Sheet open={open} onOpenChange={setOpen}>
|
||||
<SheetTrigger asChild>
|
||||
<Button variant="ghost" size="icon" aria-label="Open navigation" className="h-10 w-10">
|
||||
<Button variant="ghost" size="icon" aria-label={t('sidebar.openNav')} className="h-10 w-10">
|
||||
<Menu className="h-5 w-5" />
|
||||
</Button>
|
||||
</SheetTrigger>
|
||||
<SheetContent side="left" className="w-64 p-0">
|
||||
<SheetTitle className="sr-only">Navigation</SheetTitle>
|
||||
<SheetTitle className="sr-only">{t('sidebar.navigation')}</SheetTitle>
|
||||
<SheetDescription className="sr-only">
|
||||
Browse routes, support links, and account status.
|
||||
{t('sidebar.navDescription')}
|
||||
</SheetDescription>
|
||||
<SidebarBody variant="mobile" onNavigate={() => setOpen(false)} />
|
||||
</SheetContent>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { RefreshCw } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useAuth } from '@/stores/auth'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
interface SyncButtonProps {
|
||||
className?: string
|
||||
@@ -12,6 +13,7 @@ interface SyncButtonProps {
|
||||
}
|
||||
|
||||
export function SyncButton({ className, showLabel = false }: SyncButtonProps) {
|
||||
const t = useT()
|
||||
const qc = useQueryClient()
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const fetching = useIsFetching({ queryKey: ['db'] })
|
||||
@@ -25,12 +27,12 @@ export function SyncButton({ className, showLabel = false }: SyncButtonProps) {
|
||||
await qc.invalidateQueries({ queryKey: ['deleted'] })
|
||||
if (pat) {
|
||||
await qc.invalidateQueries({ queryKey: ['workflows'] })
|
||||
toast.success('Synced (authenticated, bypasses CDN cache)')
|
||||
toast.success(t('sync.toast.authenticated'))
|
||||
} else {
|
||||
toast.success('Synced from CDN (raw.githubusercontent.com)')
|
||||
toast.success(t('sync.toast.cdn'))
|
||||
}
|
||||
} catch (e) {
|
||||
toast.error(`Sync failed: ${(e as Error).message}`)
|
||||
toast.error(t('sync.toast.failed', { message: (e as Error).message }))
|
||||
} finally {
|
||||
setPending(false)
|
||||
}
|
||||
@@ -44,10 +46,10 @@ export function SyncButton({ className, showLabel = false }: SyncButtonProps) {
|
||||
onClick={sync}
|
||||
disabled={busy}
|
||||
className={cn('w-full justify-start gap-3', className)}
|
||||
title={pat ? 'Refresh data (authenticated)' : 'Refresh data (CDN)'}
|
||||
title={pat ? t('sync.title.authenticated') : t('sync.title.cdn')}
|
||||
>
|
||||
<RefreshCw className={cn('h-4 w-4', busy && 'animate-spin')} />
|
||||
<span className="text-sm">{busy ? 'Syncing...' : 'Sync data'}</span>
|
||||
<span className="text-sm">{busy ? t('sync.syncing') : t('sync.label')}</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
@@ -59,7 +61,7 @@ export function SyncButton({ className, showLabel = false }: SyncButtonProps) {
|
||||
onClick={sync}
|
||||
disabled={busy}
|
||||
className={cn('h-8 w-8', className)}
|
||||
title={pat ? 'Refresh data (authenticated)' : 'Refresh data (CDN)'}
|
||||
title={pat ? t('sync.title.authenticated') : t('sync.title.cdn')}
|
||||
>
|
||||
<RefreshCw className={cn('h-4 w-4', busy && 'animate-spin')} />
|
||||
</Button>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Moon, Sun, Monitor } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useThemeStore, type Theme } from '@/stores/theme'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useT, type MessageKey } from '@/lib/i18n'
|
||||
|
||||
const ORDER: Theme[] = ['light', 'dark', 'system']
|
||||
const ICONS: Record<Theme, React.ComponentType<{ className?: string }>> = {
|
||||
@@ -9,10 +10,10 @@ const ICONS: Record<Theme, React.ComponentType<{ className?: string }>> = {
|
||||
dark: Moon,
|
||||
system: Monitor,
|
||||
}
|
||||
const LABELS: Record<Theme, string> = {
|
||||
light: 'Light',
|
||||
dark: 'Dark',
|
||||
system: 'System',
|
||||
const LABEL_KEYS: Record<Theme, MessageKey> = {
|
||||
light: 'theme.light',
|
||||
dark: 'theme.dark',
|
||||
system: 'theme.system',
|
||||
}
|
||||
|
||||
interface ThemeToggleProps {
|
||||
@@ -21,9 +22,11 @@ interface ThemeToggleProps {
|
||||
}
|
||||
|
||||
export function ThemeToggle({ className, showLabel = true }: ThemeToggleProps) {
|
||||
const t = useT()
|
||||
const theme = useThemeStore((s) => s.theme)
|
||||
const setTheme = useThemeStore((s) => s.setTheme)
|
||||
const Icon = ICONS[theme]
|
||||
const label = t(LABEL_KEYS[theme])
|
||||
|
||||
function cycle() {
|
||||
const next = ORDER[(ORDER.indexOf(theme) + 1) % ORDER.length]
|
||||
@@ -37,7 +40,7 @@ export function ThemeToggle({ className, showLabel = true }: ThemeToggleProps) {
|
||||
size="icon"
|
||||
onClick={cycle}
|
||||
className={cn('h-8 w-8', className)}
|
||||
title={`Theme: ${LABELS[theme]} (click to cycle)`}
|
||||
title={t('theme.toggleTitle', { label })}
|
||||
>
|
||||
<Icon className="h-4 w-4" />
|
||||
</Button>
|
||||
@@ -50,10 +53,10 @@ export function ThemeToggle({ className, showLabel = true }: ThemeToggleProps) {
|
||||
size="sm"
|
||||
onClick={cycle}
|
||||
className={cn('w-full justify-start gap-3', className)}
|
||||
title={`Theme: ${LABELS[theme]} (click to cycle)`}
|
||||
title={t('theme.toggleTitle', { label })}
|
||||
>
|
||||
<Icon className="h-4 w-4" />
|
||||
<span className="text-sm">{LABELS[theme]}</span>
|
||||
<span className="text-sm">{label}</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
@@ -4,8 +4,10 @@ import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { useUndo } from '@/stores/undo'
|
||||
import { useState } from 'react'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
export function UndoTray() {
|
||||
const t = useT()
|
||||
const ops = useUndo((s) => s.ops)
|
||||
const remove = useUndo((s) => s.remove)
|
||||
const [pending, setPending] = useState<string | null>(null)
|
||||
@@ -18,10 +20,10 @@ export function UndoTray() {
|
||||
setPending(id)
|
||||
try {
|
||||
await op.reverse()
|
||||
toast.success(`Undone: ${op.label}`)
|
||||
toast.success(t('undo.toast.done', { label: op.label }))
|
||||
remove(id)
|
||||
} catch (e) {
|
||||
toast.error(`Undo failed: ${(e as Error).message}`)
|
||||
toast.error(t('undo.toast.failed', { message: (e as Error).message }))
|
||||
} finally {
|
||||
setPending(null)
|
||||
}
|
||||
@@ -31,7 +33,7 @@ export function UndoTray() {
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="flex flex-wrap items-center gap-2 p-3 text-sm">
|
||||
<Undo2 className="h-4 w-4 text-muted-foreground" />
|
||||
<span className="text-muted-foreground">Recent commits:</span>
|
||||
<span className="text-muted-foreground">{t('undo.recentCommits')}</span>
|
||||
{ops.slice(0, 3).map((o) => (
|
||||
<Button
|
||||
key={o.id}
|
||||
@@ -39,14 +41,14 @@ export function UndoTray() {
|
||||
size="sm"
|
||||
disabled={pending === o.id}
|
||||
onClick={() => runUndo(o.id)}
|
||||
title={`Created ${new Date(o.timestamp).toLocaleString()}`}
|
||||
title={t('undo.createdAt', { date: new Date(o.timestamp).toLocaleString() })}
|
||||
>
|
||||
<Undo2 className="h-3 w-3" />
|
||||
{pending === o.id ? 'Undoing...' : `Undo: ${o.label}`}
|
||||
{pending === o.id ? t('undo.undoing') : t('undo.action', { label: o.label })}
|
||||
</Button>
|
||||
))}
|
||||
{ops.length > 3 && (
|
||||
<span className="text-xs text-muted-foreground">+ {ops.length - 3} older</span>
|
||||
<span className="text-xs text-muted-foreground">{t('undo.older', { count: ops.length - 3 })}</span>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -2,13 +2,14 @@ import { useQuery } from '@tanstack/react-query'
|
||||
import { useAuth } from '@/stores/auth'
|
||||
import { createOctokit } from '@/lib/github/client'
|
||||
import { listWorkflowRuns, type WorkflowFile } from '@/lib/github/workflow'
|
||||
import type { MessageKey } from '@/lib/i18n'
|
||||
|
||||
export const WORKFLOWS: { file: WorkflowFile; label: string; description: string }[] = [
|
||||
{ file: 'update.yml', label: 'Update', description: 'Scrape new URLs from temp_link.json + INPUT_URL' },
|
||||
{ file: 'check_paid.yml', label: 'Check Paid', description: 'Re-verify free/paid status' },
|
||||
{ file: 'check_alive.yml', label: 'Check Alive', description: 'Verify URLs return 2xx/3xx' },
|
||||
{ file: 'generate_table.yml', label: 'Generate Tables', description: 'Regenerate lists/*.md' },
|
||||
{ file: 'log_deleted.yml', label: 'Log Deleted', description: 'Update deleted_games.txt' },
|
||||
export const WORKFLOWS: { file: WorkflowFile; labelKey: MessageKey; descriptionKey: MessageKey }[] = [
|
||||
{ file: 'update.yml', labelKey: 'workflows.update.label', descriptionKey: 'workflows.update.desc' },
|
||||
{ file: 'check_paid.yml', labelKey: 'workflows.checkPaid.label', descriptionKey: 'workflows.checkPaid.desc' },
|
||||
{ file: 'check_alive.yml', labelKey: 'workflows.checkAlive.label', descriptionKey: 'workflows.checkAlive.desc' },
|
||||
{ file: 'generate_table.yml', labelKey: 'workflows.generateTables.label', descriptionKey: 'workflows.generateTables.desc' },
|
||||
{ file: 'log_deleted.yml', labelKey: 'workflows.logDeleted.label', descriptionKey: 'workflows.logDeleted.desc' },
|
||||
]
|
||||
|
||||
export function useWorkflowRuns(workflow: WorkflowFile, enabled = true) {
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface ThirdParty {
|
||||
|
||||
export const APP = {
|
||||
name: 'Itch.io Free Games DB',
|
||||
version: '3.5.2',
|
||||
version: '3.6.0',
|
||||
repo: 'https://github.com/poli0981/free-games-itchio-list',
|
||||
license: 'MIT',
|
||||
buildDate: typeof __BUILD_DATE__ !== 'undefined' ? __BUILD_DATE__ : 'dev',
|
||||
@@ -153,6 +153,9 @@ export const THIRD_PARTY: ThirdParty[] = [
|
||||
{ name: 'TanStack Query', version: '5.100', license: 'MIT', url: 'https://tanstack.com/query', category: 'data' },
|
||||
{ name: 'TanStack Table', version: '8.21', license: 'MIT', url: 'https://tanstack.com/table', category: 'data' },
|
||||
{ name: 'TanStack Virtual', version: '3.13', license: 'MIT', url: 'https://tanstack.com/virtual', category: 'data' },
|
||||
{ name: 'TanStack Query Persist Client', version: '5.101', license: 'MIT', url: 'https://tanstack.com/query', category: 'data' },
|
||||
{ name: 'TanStack Query Async Storage Persister', version: '5.101', license: 'MIT', url: 'https://tanstack.com/query', category: 'data' },
|
||||
{ name: 'idb-keyval', version: '6.2', license: 'Apache-2.0', url: 'https://github.com/jakearchibald/idb-keyval', category: 'data' },
|
||||
{ name: '@octokit/rest', version: '22.0', license: 'MIT', url: 'https://github.com/octokit/octokit.js', category: 'data' },
|
||||
{ name: 'OpenPGP.js', version: '6.3', license: 'LGPL-3.0', url: 'https://openpgpjs.org', category: 'data' },
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { RAW_BASE } from '../config'
|
||||
import { HttpError } from '../http-error'
|
||||
|
||||
export async function fetchRaw<T>(path: string): Promise<T> {
|
||||
const url = `${RAW_BASE}/${path}`
|
||||
const res = await fetch(url, { cache: 'no-cache' })
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to fetch ${path}: ${res.status} ${res.statusText}`)
|
||||
throw new HttpError(res.status, `Failed to fetch ${path}: ${res.status} ${res.statusText}`, url)
|
||||
}
|
||||
return res.json() as Promise<T>
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Typed HTTP error so UI layers can map a real status code to an error page.
|
||||
* `fetchRaw` throws this; Octokit's RequestError already carries `.status`.
|
||||
*/
|
||||
export class HttpError extends Error {
|
||||
readonly status: number
|
||||
readonly url?: string
|
||||
|
||||
constructor(status: number, message: string, url?: string) {
|
||||
super(message)
|
||||
this.name = 'HttpError'
|
||||
this.status = status
|
||||
this.url = url
|
||||
}
|
||||
}
|
||||
|
||||
/** Extract an HTTP status code from any thrown value, if one exists. */
|
||||
export function errorStatus(err: unknown): number | undefined {
|
||||
if (err instanceof HttpError) return err.status
|
||||
if (
|
||||
typeof err === 'object' &&
|
||||
err !== null &&
|
||||
'status' in err &&
|
||||
typeof (err as { status: unknown }).status === 'number'
|
||||
) {
|
||||
// Octokit RequestError (and friends) shape
|
||||
return (err as { status: number }).status
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** fetch() rejects with a TypeError when the network itself is unreachable. */
|
||||
export function isNetworkError(err: unknown): boolean {
|
||||
return err instanceof TypeError
|
||||
}
|
||||
@@ -0,0 +1,483 @@
|
||||
/**
|
||||
* English dictionary — the source of truth for all UI strings.
|
||||
* `MessageKey` is derived from this object; `vi.ts` must mirror every key
|
||||
* (enforced at compile time via `Record<MessageKey, string>`).
|
||||
*
|
||||
* Conventions:
|
||||
* - Flat dot-namespaced keys: `<area>.<thing>` (greppable, no nesting).
|
||||
* - Interpolation via `{token}` placeholders, replaced by `t(key, { token })`.
|
||||
* - Brand names, legal/license text, and technical literals stay English
|
||||
* and never enter this dictionary.
|
||||
*/
|
||||
export const en = {
|
||||
// ---- common ----
|
||||
'common.loading': 'Loading…',
|
||||
'common.retry': 'Try again',
|
||||
'common.cancel': 'Cancel',
|
||||
'common.save': 'Save',
|
||||
'common.close': 'Close',
|
||||
'common.delete': 'Delete',
|
||||
'common.edit': 'Edit',
|
||||
'common.back': 'Back',
|
||||
'common.search': 'Search',
|
||||
'common.yes': 'Yes',
|
||||
'common.no': 'No',
|
||||
'common.unknown': 'Unknown',
|
||||
'common.none': 'None',
|
||||
'common.failedToLoad': 'Failed to load',
|
||||
'common.language': 'Language',
|
||||
|
||||
// ---- nav / sidebar ----
|
||||
'nav.dashboard': 'Dashboard',
|
||||
'nav.games': 'Games',
|
||||
'nav.addGame': 'Add Game',
|
||||
'nav.charts': 'Charts',
|
||||
'nav.workflows': 'Workflows',
|
||||
'nav.deleted': 'Deleted',
|
||||
'nav.settings': 'Settings',
|
||||
'nav.about': 'About',
|
||||
|
||||
// ---- document titles ----
|
||||
'titles.dashboard': 'Dashboard',
|
||||
'titles.games': 'Games',
|
||||
'titles.addGame': 'Add Game',
|
||||
'titles.charts': 'Charts',
|
||||
'titles.workflows': 'Workflows',
|
||||
'titles.deleted': 'Deleted Games',
|
||||
'titles.settings': 'Settings',
|
||||
'titles.about': 'About',
|
||||
'titles.notFound': '404 — Not found',
|
||||
|
||||
// ---- error pages ----
|
||||
'error.400.title': 'Bad request',
|
||||
'error.400.desc': 'The request was malformed and the server rejected it.',
|
||||
'error.401.title': 'Not authenticated',
|
||||
'error.401.desc':
|
||||
'Authentication is required — your PAT may be locked or expired. Unlock it in Settings.',
|
||||
'error.403.title': 'Access denied',
|
||||
'error.403.desc':
|
||||
"Your token may lack permissions, or you've hit GitHub's rate limit. Wait a moment and try again.",
|
||||
'error.404.title': 'Page not found',
|
||||
'error.404.desc': "The page or resource you're looking for doesn't exist or has been moved.",
|
||||
'error.408.title': 'Request timeout',
|
||||
'error.408.desc': 'The server took too long to respond. Check your connection and try again.',
|
||||
'error.419.title': 'Session expired',
|
||||
'error.419.desc':
|
||||
'Your session has expired. Refresh the page or unlock your PAT again in Settings.',
|
||||
'error.429.title': 'Too many requests',
|
||||
'error.429.desc': "You've hit GitHub's rate limit. Wait a few minutes before trying again.",
|
||||
'error.500.title': 'Server error',
|
||||
'error.500.desc': "Something went wrong on the server. It's not you — try again in a moment.",
|
||||
'error.502.title': 'Bad gateway',
|
||||
'error.502.desc': 'The server received an invalid response from upstream. Usually temporary.',
|
||||
'error.503.title': 'Service unavailable',
|
||||
'error.503.desc':
|
||||
'The service is temporarily unavailable — GitHub may be having a hiccup. Try again shortly.',
|
||||
'error.504.title': 'Gateway timeout',
|
||||
'error.504.desc': 'The upstream server took too long to respond. Try again in a moment.',
|
||||
'error.unknown.title': 'Something went wrong',
|
||||
'error.unknown.desc': 'An unexpected error occurred. Try again, or report it if it persists.',
|
||||
'error.offline.title': "You're offline",
|
||||
'error.offline.desc': "Couldn't reach the network. Check your connection and try again.",
|
||||
'error.chunk.title': 'New version available',
|
||||
'error.chunk.desc':
|
||||
'The app has been updated since this page was loaded. Reload to get the latest version.',
|
||||
'error.gameNotFound.title': 'Game not found',
|
||||
'error.gameNotFound.desc': 'No game matches the slug {slug}. It may have been renamed or removed.',
|
||||
'error.actions.home': 'Back to dashboard',
|
||||
'error.actions.report': 'Report a bug',
|
||||
'error.actions.reload': 'Reload',
|
||||
'error.actions.details': 'Technical details',
|
||||
'error.preview.hint': 'Preview of the {status} error page. Try /errors/403, /errors/500, …',
|
||||
|
||||
// ---- merged from i18n sweep ----
|
||||
"about.ai.desc": "No real co-maintainers (introvert max level). These two LLMs are the closest thing.",
|
||||
"about.ai.title": "AI co-authors",
|
||||
"about.app.access": "Reads are public (no auth needed). Writes use a fine-grained GitHub PAT held only in memory after passphrase unlock — see Settings.",
|
||||
"about.app.descPrefix": "A read/write companion app for the ",
|
||||
"about.app.descSuffix": " catalog. Browse 500+ free games from itch.io, edit annotations, dispatch the scraper workflow with one click, and visualize the dataset.",
|
||||
"about.app.meta": "v{version} · built {buildDate} · {license} licensed",
|
||||
"about.bug.desc": "If something's broken — desktop or web — file it here so I see it. Grok will probably patch it before I wake up :D",
|
||||
"about.bug.openTemplate": "Open bug report template",
|
||||
"about.bug.title": "Found a bug?",
|
||||
"about.developer.title": "Developer",
|
||||
"about.footer": "Made with the libraries above. No tracking, no analytics, no telemetry.",
|
||||
"about.legal.desc": "All policies are MD files in the repo — short, plain-language, slight humor, full on-the-record terms. Updated 2026-05-05.",
|
||||
"about.legal.title": "Legal & policies",
|
||||
"about.legal.viNote": "— Vietnamese translations of the policies above (community-readable, English remains the controlling version for legal interpretation).",
|
||||
"about.social.desc": "DMs open on most. Replies slow (introvert max level). Pick whichever channel fits.",
|
||||
"about.social.messagingNote": "Please DM your Telegram numeric ID privately. Never post it to Discord/X/public channels.",
|
||||
"about.social.paypalNote": "Receipt shows real legal name (DungDang212) — that’s me.",
|
||||
"about.social.supportNote": "Mirrors .github/FUNDING.yml — same handles GitHub uses for the Sponsor button.",
|
||||
"about.social.title": "Find me elsewhere",
|
||||
"about.thirdParty.core": "Core",
|
||||
"about.thirdParty.data": "Data layer",
|
||||
"about.thirdParty.desc": "Open-source libraries this app builds on. Click any name for the project's home page; license names link to the SPDX identifier.",
|
||||
"about.thirdParty.desktop": "Desktop (Tauri)",
|
||||
"about.thirdParty.dev": "Dev tooling",
|
||||
"about.thirdParty.title": "Third-party software",
|
||||
"about.thirdParty.ui": "UI / styling",
|
||||
"about.upstream.source": "Source:",
|
||||
"about.upstream.title": "Upstream data attribution",
|
||||
"add.addButton": "Add",
|
||||
"add.bulkDesc.prefix": "One URL per line (whitespace-separated also OK). Writes them to",
|
||||
"add.bulkDesc.suffix": "in a single commit, then dispatches the workflow.",
|
||||
"add.bulkTitle": "Bulk import",
|
||||
"add.dispatching": "Dispatching update workflow...",
|
||||
"add.errDuplicate": "Already in database",
|
||||
"add.errNotItchUrl": "Not an itch.io URL",
|
||||
"add.patNotice.prefix": "Unlock your PAT in",
|
||||
"add.patNotice.suffix": "first — adding games dispatches the GitHub Actions workflow which requires",
|
||||
"add.polling": "Workflow dispatched. Polling for completion...",
|
||||
"add.queueDispatch": "Queue & dispatch",
|
||||
"add.runNotFoundMsg": "Run not found; check Workflows tab",
|
||||
"add.singleDesc.prefix": "Dispatches",
|
||||
"add.singleDesc.suffix": "with this URL as input. The workflow scrapes, validates free status, and commits — usually 60–120 s.",
|
||||
"add.singleTitle": "Add one game by URL",
|
||||
"add.statusBadge": "Status",
|
||||
"add.statusLine": "Status: {status}",
|
||||
"add.tabBulk": "Bulk",
|
||||
"add.tabSingle": "Single URL",
|
||||
"add.toast.allInvalid": "All {count} URLs invalid. {reason}",
|
||||
"add.toast.bulkFailed": "Bulk failed: {message}",
|
||||
"add.toast.completed": "Workflow completed. Refreshing data.",
|
||||
"add.toast.dispatchFailed": "Dispatch failed: {message}",
|
||||
"add.toast.pasteAtLeastOne": "Paste at least one URL.",
|
||||
"add.toast.pollTimeout": "Polling timed out. Check the Workflows tab.",
|
||||
"add.toast.runNotFound": "Dispatched but could not locate the run. Check Workflows.",
|
||||
"add.toast.skippedValid": "{skipped} skipped, {valid} valid.",
|
||||
"add.toast.unlockPat": "Unlock your PAT in Settings.",
|
||||
"add.toast.workflowConcluded": "Workflow {conclusion}. See run logs.",
|
||||
"add.urlLabel": "itch.io URL",
|
||||
"add.viewRun": "View run",
|
||||
"add.working": "Working...",
|
||||
"add.writingTempLink": "Writing scripts/temp_link.json with {count} URLs...",
|
||||
"bulk.delete.confirmToast": "Type '{expected}' to confirm.",
|
||||
"bulk.delete.cta": "Delete {n}",
|
||||
"bulk.delete.deleting": "Deleting...",
|
||||
"bulk.delete.desc": "One atomic commit removes the records from data_game/ chunks (rebalanced) and appends entries to scripts/deleted_games.json. Use the undo button after committing to roll back. This is reversible only via undo or git revert.",
|
||||
"bulk.delete.more": "… and {n} more",
|
||||
"bulk.delete.reason": "Reason",
|
||||
"bulk.delete.title": "Delete {n} games",
|
||||
"bulk.delete.typePrefix": "Type",
|
||||
"bulk.delete.typeSuffix": "to confirm",
|
||||
"bulk.edit.apply": "Apply to selected",
|
||||
"bulk.edit.applying": "Applying...",
|
||||
"bulk.edit.desc": "Toggle a field on the left to apply the same value to every selected game. Untoggled fields stay as they are.",
|
||||
"bulk.edit.notesPlaceholder": "Same notes for every selected game",
|
||||
"bulk.edit.title": "Bulk Edit ({n} games)",
|
||||
"bulk.field.notesReplace": "Notes (replaces existing)",
|
||||
"bulk.field.safeVirus": "Safe / virus",
|
||||
"bulk.reason.duplicate": "Duplicate",
|
||||
"bulk.reason.manualCleanup": "Manual cleanup",
|
||||
"bulk.reason.other": "Other",
|
||||
"bulk.reason.qualityIssue": "Quality issue",
|
||||
"bulk.safe.caution": "Caution",
|
||||
"bulk.toast.cacheNotReady": "Game cache not ready.",
|
||||
"bulk.toast.deleteFailed": "Delete failed: {msg}",
|
||||
"bulk.toast.deleted": "{n} games deleted across {files} file(s) ({sha}).",
|
||||
"bulk.toast.editFailed": "Bulk-edit failed: {msg}",
|
||||
"bulk.toast.noField": "Toggle at least one field to update.",
|
||||
"bulk.toast.unlockPat": "Unlock your PAT in Settings.",
|
||||
"bulk.toast.updated": "{n} games updated in {files} file(s) ({sha}).",
|
||||
"bulk.undo.deleteLabel": "Bulk-delete of {n} games",
|
||||
"bulk.undo.editLabel": "Bulk-edit of {n} games",
|
||||
"charts.avgSession.title": "Average Session Length",
|
||||
"charts.deletionReasons.desc": "Why games left the catalog",
|
||||
"charts.deletionReasons.title": "Deletion Reasons",
|
||||
"charts.deletionsOverTime.desc": "Games removed per month",
|
||||
"charts.deletionsOverTime.title": "Deletions Over Time",
|
||||
"charts.gameCount.desc": "Total games in the catalog by day",
|
||||
"charts.gameCount.empty": "No history data yet.",
|
||||
"charts.gameCount.title": "Game Count Over Time",
|
||||
"charts.genre.desc": "Top 15 by game count",
|
||||
"charts.genre.title": "Genres",
|
||||
"charts.genreTreemap.desc": "Top 12 genres sized by game count",
|
||||
"charts.genreTreemap.title": "Genre Treemap",
|
||||
"charts.kpi.avgRating": "Avg rating",
|
||||
"charts.kpi.deletedTotal": "Deleted (total)",
|
||||
"charts.kpi.nsfw": "NSFW",
|
||||
"charts.kpi.online": "Online (HTML5)",
|
||||
"charts.kpi.totalGames": "Total games",
|
||||
"charts.languages.title": "Top 10 Languages",
|
||||
"charts.madeWith.desc": "Primary engine per game (made_with[0])",
|
||||
"charts.madeWith.title": "Game Engines",
|
||||
"charts.onlineOffline.desc": "HTML5 means playable in the browser",
|
||||
"charts.onlineOffline.offline": "Offline only",
|
||||
"charts.onlineOffline.online": "Online (HTML5)",
|
||||
"charts.onlineOffline.title": "Online vs Offline",
|
||||
"charts.platform.desc": "Counted per game (a game may target several)",
|
||||
"charts.platform.title": "Platforms",
|
||||
"charts.rating.desc": "Bins of 0.5 stars from 0 to 5",
|
||||
"charts.rating.title": "Rating Histogram",
|
||||
"charts.recentDeleted.desc": "Last {shown} of {total} total",
|
||||
"charts.recentDeleted.empty": "No deletions logged.",
|
||||
"charts.recentDeleted.title": "Recent Deletions",
|
||||
"charts.status.desc": "Released vs prototype/in-progress",
|
||||
"charts.status.title": "Status Mix",
|
||||
"charts.tabs.discovery": "Discovery",
|
||||
"charts.tabs.overview": "Overview",
|
||||
"charts.tabs.quality": "Quality",
|
||||
"charts.tabs.reach": "Reach",
|
||||
"charts.topRatedCount.desc": "Top 10 by number of ratings",
|
||||
"charts.topRatedCount.title": "Most Rated Games",
|
||||
"charts.topTags.desc": "Word-cloud-style ranking (sized by count)",
|
||||
"charts.topTags.tagTitle": "{count} games",
|
||||
"charts.topTags.title": "Top 30 Tags",
|
||||
"common.scrollToTop": "Scroll to top",
|
||||
"dashboard.databaseFiles": "Database Files",
|
||||
"dashboard.deletionLog": "Deletion Log",
|
||||
"dashboard.flagged": "{count} flagged",
|
||||
"dashboard.gamesCount": "{count} games",
|
||||
"dashboard.lastUpdated": "Last updated: {date}",
|
||||
"dashboard.nsfwRatio": "NSFW Ratio",
|
||||
"dashboard.onlineHtml5": "Online (HTML5)",
|
||||
"dashboard.playableInBrowser": "{count} playable in browser",
|
||||
"dashboard.released": "{count} released",
|
||||
"dashboard.removedTotal": "games removed total",
|
||||
"dashboard.topGenre": "Top Genre",
|
||||
"dashboard.totalGames": "Total Games",
|
||||
"deleted.count": "{count} entries",
|
||||
"deleted.empty": "No deletions logged.",
|
||||
"detail.annotationsDesc": "These three fields are user-editable in Phase 2 (safe_virus, notes, nsfw). Everything above comes from the scraper and is read-only.",
|
||||
"detail.avgSession": "Avg session",
|
||||
"detail.backToGames": "Back to games",
|
||||
"detail.byDev": "by {dev}",
|
||||
"detail.coverAlt": "{name} cover",
|
||||
"detail.editTooltip": "Edit annotations",
|
||||
"detail.editTooltipLocked": "Unlock your PAT in Settings to enable editing",
|
||||
"detail.genre": "Genre",
|
||||
"detail.inputs": "Inputs",
|
||||
"detail.languages": "Languages",
|
||||
"detail.madeWith": "Made with",
|
||||
"detail.manualAnnotations": "Manual Annotations",
|
||||
"detail.metadata": "Metadata",
|
||||
"detail.noNotes": "No notes yet",
|
||||
"detail.notes": "Notes",
|
||||
"detail.nsfwOverride": "NSFW (override)",
|
||||
"detail.openOnItch": "Open on itch.io",
|
||||
"detail.platforms": "Platforms",
|
||||
"detail.publisher": "Publisher",
|
||||
"detail.rating": "Rating",
|
||||
"detail.releaseDate": "Release date",
|
||||
"detail.reviewsCount": "({count} reviews)",
|
||||
"detail.safeVirus": "Safe / virus",
|
||||
"detail.tags": "Tags",
|
||||
"detail.techReach": "Tech & Reach",
|
||||
"editForm.desc": "Three user-editable fields. Everything else is auto-fetched and read-only.",
|
||||
"editForm.field.notes": "Notes",
|
||||
"editForm.field.nsfw": "NSFW (override auto-detection)",
|
||||
"editForm.field.safeVirus": "Safe / virus",
|
||||
"editForm.notesPlaceholder": "Free-form notes (markdown allowed)",
|
||||
"editForm.safe.caution": "Caution",
|
||||
"editForm.saving": "Saving...",
|
||||
"editForm.title": "Edit Annotations",
|
||||
"editForm.toast.cacheNotLoaded": "Game cache not loaded yet.",
|
||||
"editForm.toast.conflict": "Conflict: file changed on the remote. Refresh and re-edit.",
|
||||
"editForm.toast.notesTooLong": "Notes too long ({len}/{max}).",
|
||||
"editForm.toast.saveFailed": "Save failed: {msg}",
|
||||
"editForm.toast.saved": "Saved to {file} ({sha})",
|
||||
"editForm.toast.unlockPat": "Unlock your PAT in Settings first.",
|
||||
"editForm.unlockHint": "Unlock your PAT in Settings to enable Save.",
|
||||
"games.bulkDeleteTitle": "Bulk delete",
|
||||
"games.bulkEditTitle": "Bulk edit annotations",
|
||||
"games.clearSelection": "Clear selection",
|
||||
"games.count": "{shown} of {total}",
|
||||
"games.facet.genre": "Genre",
|
||||
"games.facet.nsfw": "NSFW",
|
||||
"games.facet.platforms": "Platforms",
|
||||
"games.facet.status": "Status",
|
||||
"games.selected": "{count} selected",
|
||||
"games.tip": "Tip: Shift-click column headers for multi-column sort. Select rows to enable bulk Edit / Delete.",
|
||||
"games.unlockPatFirst": "Unlock PAT first",
|
||||
"gpg.armoredKey": "Armored private key",
|
||||
"gpg.commitAuthor": "Commit author",
|
||||
"gpg.confirm.remove": "Remove the encrypted GPG key from this browser? You will need to re-import it.",
|
||||
"gpg.copyPublic": "Copy public key",
|
||||
"gpg.desc.1": "Sign every commit this app makes so they show as",
|
||||
"gpg.desc.2": "on GitHub. The private key is decrypted once at import and re-encrypted with your webapp passphrase (AES-GCM) before being stored in localStorage — same scheme as the PAT.",
|
||||
"gpg.footer.1": "The public half of this key must be uploaded to",
|
||||
"gpg.footer.2": "for the Verified badge to appear. Use",
|
||||
"gpg.footer.3": "above (when unlocked) — it puts the armored public block on your clipboard.",
|
||||
"gpg.importKey": "Import key",
|
||||
"gpg.keyPassphrase": "GPG key passphrase",
|
||||
"gpg.keyPassphrasePlaceholder": "Leave blank if the key has no passphrase",
|
||||
"gpg.lock": "Lock",
|
||||
"gpg.pasteFrom": "Or paste from",
|
||||
"gpg.patFirst": "Unlock your PAT first so we can use the same passphrase to encrypt the key.",
|
||||
"gpg.removeKey": "Remove key",
|
||||
"gpg.signCommits": "Sign commits",
|
||||
"gpg.signCommits.desc": "Turn off to keep the key imported but commit unsigned.",
|
||||
"gpg.status": "Status:",
|
||||
"gpg.status.noKey": "No key imported",
|
||||
"gpg.status.savedLocked": "Saved (locked)",
|
||||
"gpg.status.unlocked": "Unlocked",
|
||||
"gpg.testSign": "Test sign",
|
||||
"gpg.title": "Commit signing (GPG)",
|
||||
"gpg.toast.confirmPassphrase": "Confirm your webapp passphrase (min 8 chars) to encrypt the key locally.",
|
||||
"gpg.toast.copyFailed": "Copy failed: {message}",
|
||||
"gpg.toast.enterPassphrase": "Enter your webapp passphrase.",
|
||||
"gpg.toast.importFailed": "Import failed: {message}",
|
||||
"gpg.toast.imported": "Imported {fingerprint} — signing enabled.",
|
||||
"gpg.toast.locked": "Signing locked. Re-enter your passphrase to unlock.",
|
||||
"gpg.toast.noStoredKey": "No GPG key stored.",
|
||||
"gpg.toast.pasteKey": "Paste or upload an armored GPG private key.",
|
||||
"gpg.toast.publicCopied": "Public key copied. Paste it into github.com/settings/keys → New GPG key.",
|
||||
"gpg.toast.removed": "GPG key removed.",
|
||||
"gpg.toast.testError": "Test sign failed: {message}",
|
||||
"gpg.toast.testFail": "Signature failed verification — please re-import the key.",
|
||||
"gpg.toast.testOk": "Round-trip verified: signing is wired correctly.",
|
||||
"gpg.toast.unlockFailed": "Unlock failed: {message}",
|
||||
"gpg.toast.unlocked": "Signing unlocked ({fingerprint}).",
|
||||
"gpg.uids.matches": "matches a UID — commits will Verify.",
|
||||
"gpg.uids.mismatch.1": "is not in this key's UIDs. GitHub will show",
|
||||
"gpg.uids.mismatch.2": "even with a valid signature. Update",
|
||||
"gpg.uids.mismatch.3": "above to one of the badges, or clear it to auto-use the primary UID.",
|
||||
"gpg.uids.noOverride.1": "No override set in",
|
||||
"gpg.uids.noOverride.2": ". The first UID will be used automatically.",
|
||||
"gpg.uids.title": "Key UIDs (one of these must be your commit author email)",
|
||||
"gpg.unlock": "Unlock",
|
||||
"gpg.unlockPlaceholder": "The passphrase that encrypts your PAT",
|
||||
"gpg.upload": "Upload .asc / .key",
|
||||
"gpg.webappPassphrase": "Webapp passphrase",
|
||||
"gpg.webappPassphraseDesc": "Used to AES-GCM-encrypt the (already-decrypted) key in localStorage.",
|
||||
"gpg.webappPassphrasePlaceholder": "Same passphrase used for your PAT — min 8 chars",
|
||||
"settings.appearance.collapseSidebar": "Collapse sidebar",
|
||||
"settings.appearance.collapseSidebarDesc": "Mirror of the toggle in the sidebar footer.",
|
||||
"settings.appearance.density": "Density",
|
||||
"settings.appearance.desc": "Theme and layout density. Choices persist to localStorage.",
|
||||
"settings.appearance.theme": "Theme",
|
||||
"settings.appearance.title": "Appearance",
|
||||
"settings.auth.classicPrefix": "Classic tokens with the",
|
||||
"settings.auth.classicSuffix": "scope also work but grant access to every repo you can write to.",
|
||||
"settings.auth.desc": "Your PAT is encrypted with AES-GCM (PBKDF2-SHA256, 100k iterations) using your passphrase before being stored in localStorage. The decrypted token only lives in memory while the tab is open.",
|
||||
"settings.auth.forgetSaved": "Forget saved PAT",
|
||||
"settings.auth.lock": "Lock",
|
||||
"settings.auth.noToken": "No token saved",
|
||||
"settings.auth.passPlaceholder": "Min 8 chars; required to unlock later",
|
||||
"settings.auth.passphrase": "Passphrase",
|
||||
"settings.auth.passphrasePlaceholder": "Your passphrase",
|
||||
"settings.auth.patLabel": "Personal Access Token",
|
||||
"settings.auth.patScopePrefix": "Fine-grained token scoped to only",
|
||||
"settings.auth.patScopeSuffix": ", with these repository permissions:",
|
||||
"settings.auth.permActions": "required to dispatch the scraper workflow from Add / Workflows.",
|
||||
"settings.auth.permContents": "required for edits, deletes, and queueing URLs.",
|
||||
"settings.auth.removeSaved": "Remove saved PAT",
|
||||
"settings.auth.saveUnlock": "Save & unlock",
|
||||
"settings.auth.savedLocked": "Saved (locked)",
|
||||
"settings.auth.status": "Status:",
|
||||
"settings.auth.testRepo": "Test repo access",
|
||||
"settings.auth.title": "GitHub Authentication",
|
||||
"settings.auth.unlock": "Unlock",
|
||||
"settings.auth.unlocked": "Unlocked",
|
||||
"settings.author.descAnd": "and",
|
||||
"settings.author.descPrefix": "Optional override for the",
|
||||
"settings.author.descSuffix": "blocks of commits made from this app. Leave blank to use the GitHub user from your PAT.",
|
||||
"settings.author.email": "Email",
|
||||
"settings.author.name": "Name",
|
||||
"settings.author.namePlaceholder": "e.g. Your Name",
|
||||
"settings.author.title": "Commit author",
|
||||
"settings.author.verifiedPrefix": "For GPG-signed commits to show as",
|
||||
"settings.author.verifiedSuffix": ", this email must match one of the UIDs in your GPG key.",
|
||||
"settings.confirm.removePat": "Remove the encrypted PAT from this browser? You will need to paste it again.",
|
||||
"settings.density.compact": "Compact (smaller rows)",
|
||||
"settings.density.normal": "Normal",
|
||||
"settings.notif.desc": "Toast notifications shown at the top-right corner.",
|
||||
"settings.notif.duration": "Duration",
|
||||
"settings.notif.enable": "Enable toasts",
|
||||
"settings.notif.enableDesc": "Disables success / error / info popups globally.",
|
||||
"settings.notif.title": "Notifications",
|
||||
"settings.session.desc": "How long the decrypted PAT stays in memory after unlock.",
|
||||
"settings.session.hour": "1 hour",
|
||||
"settings.session.hours": "{h} hours",
|
||||
"settings.session.idleNote": "The PAT auto-locks on idle. Re-enter your passphrase to unlock again.",
|
||||
"settings.session.idleTimeout": "Idle timeout",
|
||||
"settings.session.minutes": "{m} minutes",
|
||||
"settings.session.title": "Session",
|
||||
"settings.theme.dark": "Dark",
|
||||
"settings.theme.light": "Light",
|
||||
"settings.theme.system": "System",
|
||||
"settings.toast.enterPassphrase": "Enter your passphrase.",
|
||||
"settings.toast.locked": "Locked. Enter your passphrase to unlock again.",
|
||||
"settings.toast.noSavedPat": "No saved PAT found.",
|
||||
"settings.toast.passMin": "Passphrase must be at least 8 characters.",
|
||||
"settings.toast.pastePat": "Paste a Personal Access Token first.",
|
||||
"settings.toast.patInvalid": "Could not validate PAT: {message}",
|
||||
"settings.toast.patRemoved": "Encrypted PAT removed from localStorage.",
|
||||
"settings.toast.repoFail": "No access to {repo}. Check token scopes.",
|
||||
"settings.toast.repoOk": "Can access {repo}",
|
||||
"settings.toast.savedUnlockedAs": "Saved & unlocked as {login}",
|
||||
"settings.toast.unlockFailed": "Unlock failed: {message}",
|
||||
"settings.toast.unlockedAs": "Unlocked as {login}",
|
||||
"sidebar.collapse": "Collapse sidebar",
|
||||
"sidebar.desktopMode": "Desktop mode (Tauri)",
|
||||
"sidebar.expand": "Expand sidebar",
|
||||
"sidebar.navDescription": "Browse routes, support links, and account status.",
|
||||
"sidebar.navigation": "Navigation",
|
||||
"sidebar.noPat": "No PAT saved",
|
||||
"sidebar.openNav": "Open navigation",
|
||||
"sidebar.patLocked": "PAT saved but locked",
|
||||
"sidebar.signedInAs": "Signed in as {login}",
|
||||
"sidebar.support": "Support the project",
|
||||
"sync.label": "Sync data",
|
||||
"sync.syncing": "Syncing...",
|
||||
"sync.title.authenticated": "Refresh data (authenticated)",
|
||||
"sync.title.cdn": "Refresh data (CDN)",
|
||||
"sync.toast.authenticated": "Synced (authenticated, bypasses CDN cache)",
|
||||
"sync.toast.cdn": "Synced from CDN (raw.githubusercontent.com)",
|
||||
"sync.toast.failed": "Sync failed: {message}",
|
||||
"table.clearFilters": "Clear filters",
|
||||
"table.dev": "Dev",
|
||||
"table.firstPage": "First page",
|
||||
"table.genre": "Genre",
|
||||
"table.lastPage": "Last page",
|
||||
"table.name": "Name",
|
||||
"table.nextPage": "Next page",
|
||||
"table.noOptions": "No options",
|
||||
"table.noResults": "No results.",
|
||||
"table.nsfw": "NSFW",
|
||||
"table.pageOf": "Page {page} of {total}",
|
||||
"table.platforms": "Platforms",
|
||||
"table.prevPage": "Previous page",
|
||||
"table.rating": "Rating",
|
||||
"table.reset": "Reset",
|
||||
"table.rowsPerPage": "Rows per page",
|
||||
"table.safe": "Safe",
|
||||
"table.searchPlaceholder": "Search name, dev, description...",
|
||||
"table.selectAll": "Select all",
|
||||
"table.selectGame": "Select {name}",
|
||||
"table.selectRow": "Select row",
|
||||
"table.showingRange": "Showing {start}–{end} of {total}",
|
||||
"table.status": "Status",
|
||||
"theme.dark": "Dark",
|
||||
"theme.light": "Light",
|
||||
"theme.system": "System",
|
||||
"theme.toggleTitle": "Theme: {label} (click to cycle)",
|
||||
"undo.action": "Undo: {label}",
|
||||
"undo.createdAt": "Created {date}",
|
||||
"undo.older": "+ {count} older",
|
||||
"undo.recentCommits": "Recent commits:",
|
||||
"undo.toast.done": "Undone: {label}",
|
||||
"undo.toast.failed": "Undo failed: {message}",
|
||||
"undo.undoing": "Undoing...",
|
||||
"workflows.checkAlive.desc": "Verify URLs return 2xx/3xx",
|
||||
"workflows.checkAlive.label": "Check Alive",
|
||||
"workflows.checkPaid.desc": "Re-verify free/paid status",
|
||||
"workflows.checkPaid.label": "Check Paid",
|
||||
"workflows.dispatch": "Dispatch",
|
||||
"workflows.generateTables.desc": "Regenerate lists/*.md",
|
||||
"workflows.generateTables.label": "Generate Tables",
|
||||
"workflows.logDeleted.desc": "Update deleted_games.txt",
|
||||
"workflows.logDeleted.label": "Log Deleted",
|
||||
"workflows.noRuns": "No runs yet.",
|
||||
"workflows.openRun": "Open",
|
||||
"workflows.refresh": "Refresh",
|
||||
"workflows.toast.dispatchFailed": "Dispatch failed: {message}",
|
||||
"workflows.toast.dispatched": "Dispatched {file}.",
|
||||
"workflows.toast.unlockPat": "Unlock your PAT in Settings.",
|
||||
"workflows.unlockPatToView": "Unlock your PAT to view runs.",
|
||||
"workflows.update.desc": "Scrape new URLs from temp_link.json + INPUT_URL",
|
||||
"workflows.update.label": "Update",
|
||||
} as const
|
||||
|
||||
export type MessageKey = keyof typeof en
|
||||
@@ -0,0 +1,75 @@
|
||||
import { useMemo } from 'react'
|
||||
import { create } from 'zustand'
|
||||
import { usePrefs } from '@/stores/prefs'
|
||||
import { en, type MessageKey } from './en'
|
||||
|
||||
export type Language = 'en' | 'vi'
|
||||
export type { MessageKey }
|
||||
|
||||
/**
|
||||
* Holds the lazily-loaded Vietnamese dictionary. A zustand store (rather than
|
||||
* a module variable) so every `useT` subscriber re-renders when it lands.
|
||||
*/
|
||||
const useViDict = create<{ dict: Record<MessageKey, string> | null }>(() => ({ dict: null }))
|
||||
|
||||
let viPromise: Promise<void> | null = null
|
||||
|
||||
/** Load the VI chunk once; literal specifier keeps it a separate Vite chunk. */
|
||||
function ensureVi(): Promise<void> {
|
||||
viPromise ??= import('./vi').then((m) => {
|
||||
useViDict.setState({ dict: m.vi })
|
||||
})
|
||||
return viPromise
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the UI language. Awaits the VI dictionary BEFORE flipping the pref
|
||||
* so `t()` never renders raw keys mid-switch.
|
||||
*/
|
||||
export async function switchLanguage(lang: Language): Promise<void> {
|
||||
if (lang === 'vi') await ensureVi()
|
||||
usePrefs.getState().setLanguage(lang)
|
||||
}
|
||||
|
||||
/** Call once at startup: preload VI if it was the persisted preference. */
|
||||
export function initI18n(): void {
|
||||
if (usePrefs.getState().language === 'vi') void ensureVi()
|
||||
}
|
||||
|
||||
function format(template: string, params?: Record<string, string | number>): string {
|
||||
if (!params) return template
|
||||
return template.replace(/\{(\w+)\}/g, (match, name: string) =>
|
||||
name in params ? String(params[name]) : match,
|
||||
)
|
||||
}
|
||||
|
||||
function lookup(
|
||||
lang: Language,
|
||||
dict: Record<MessageKey, string> | null,
|
||||
key: MessageKey,
|
||||
params?: Record<string, string | number>,
|
||||
): string {
|
||||
// Fall back to English while the VI chunk is still loading (cold start
|
||||
// with a persisted 'vi' pref) — never show raw keys.
|
||||
const template = (lang === 'vi' && dict ? dict[key] : undefined) ?? en[key]
|
||||
return format(template, params)
|
||||
}
|
||||
|
||||
/**
|
||||
* Imperative translate for non-component contexts (toasts, handlers, column
|
||||
* render functions executing inside an already-subscribed tree).
|
||||
*/
|
||||
export function t(key: MessageKey, params?: Record<string, string | number>): string {
|
||||
return lookup(usePrefs.getState().language, useViDict.getState().dict, key, params)
|
||||
}
|
||||
|
||||
/** Reactive translate hook — re-renders the component on language switch. */
|
||||
export function useT(): (key: MessageKey, params?: Record<string, string | number>) => string {
|
||||
const lang = usePrefs((s) => s.language)
|
||||
const dict = useViDict((s) => s.dict)
|
||||
return useMemo(
|
||||
() => (key: MessageKey, params?: Record<string, string | number>) =>
|
||||
lookup(lang, dict, key, params),
|
||||
[lang, dict],
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
import type { MessageKey } from './en'
|
||||
|
||||
/**
|
||||
* Vietnamese dictionary — lazy-loaded chunk.
|
||||
*
|
||||
* IMPORTANT: never static-import this file from app code; only
|
||||
* `lib/i18n/index.ts` may load it via `import('./vi')` so Vite keeps it in
|
||||
* its own chunk (downloaded only when the user switches to Vietnamese).
|
||||
* The type-only import above is erased at build time and does not couple
|
||||
* the chunks.
|
||||
*
|
||||
* `Record<MessageKey, string>` makes a missing key a compile error.
|
||||
*/
|
||||
export const vi: Record<MessageKey, string> = {
|
||||
// ---- common ----
|
||||
'common.loading': 'Đang tải…',
|
||||
'common.retry': 'Thử lại',
|
||||
'common.cancel': 'Huỷ',
|
||||
'common.save': 'Lưu',
|
||||
'common.close': 'Đóng',
|
||||
'common.delete': 'Xoá',
|
||||
'common.edit': 'Sửa',
|
||||
'common.back': 'Quay lại',
|
||||
'common.search': 'Tìm kiếm',
|
||||
'common.yes': 'Có',
|
||||
'common.no': 'Không',
|
||||
'common.unknown': 'Không rõ',
|
||||
'common.none': 'Không có',
|
||||
'common.failedToLoad': 'Tải dữ liệu thất bại',
|
||||
'common.language': 'Ngôn ngữ',
|
||||
|
||||
// ---- nav / sidebar ----
|
||||
'nav.dashboard': 'Trang chính',
|
||||
'nav.games': 'Danh sách game',
|
||||
'nav.addGame': 'Thêm game',
|
||||
'nav.charts': 'Biểu đồ',
|
||||
'nav.workflows': 'Quy trình',
|
||||
'nav.deleted': 'Đã xoá',
|
||||
'nav.settings': 'Cài đặt',
|
||||
'nav.about': 'Giới thiệu',
|
||||
|
||||
// ---- document titles ----
|
||||
'titles.dashboard': 'Trang chính',
|
||||
'titles.games': 'Danh sách game',
|
||||
'titles.addGame': 'Thêm game',
|
||||
'titles.charts': 'Biểu đồ',
|
||||
'titles.workflows': 'Quy trình',
|
||||
'titles.deleted': 'Game đã xoá',
|
||||
'titles.settings': 'Cài đặt',
|
||||
'titles.about': 'Giới thiệu',
|
||||
'titles.notFound': '404 — Không tìm thấy',
|
||||
|
||||
// ---- error pages ----
|
||||
'error.400.title': 'Yêu cầu không hợp lệ',
|
||||
'error.400.desc': 'Yêu cầu bị sai định dạng nên máy chủ đã từ chối.',
|
||||
'error.401.title': 'Chưa xác thực',
|
||||
'error.401.desc':
|
||||
'Cần xác thực — PAT của bạn có thể đang khoá hoặc đã hết hạn. Mở khoá trong Cài đặt.',
|
||||
'error.403.title': 'Bị từ chối truy cập',
|
||||
'error.403.desc':
|
||||
'Token có thể thiếu quyền, hoặc bạn đã chạm giới hạn tần suất của GitHub. Đợi một lát rồi thử lại.',
|
||||
'error.404.title': 'Không tìm thấy trang',
|
||||
'error.404.desc': 'Trang hoặc tài nguyên bạn tìm không tồn tại hoặc đã bị di chuyển.',
|
||||
'error.408.title': 'Hết thời gian chờ',
|
||||
'error.408.desc': 'Máy chủ phản hồi quá lâu. Kiểm tra kết nối rồi thử lại.',
|
||||
'error.419.title': 'Phiên đã hết hạn',
|
||||
'error.419.desc': 'Phiên làm việc đã hết hạn. Tải lại trang hoặc mở khoá PAT trong Cài đặt.',
|
||||
'error.429.title': 'Quá nhiều yêu cầu',
|
||||
'error.429.desc': 'Bạn đã chạm giới hạn tần suất của GitHub. Đợi vài phút rồi thử lại.',
|
||||
'error.500.title': 'Lỗi máy chủ',
|
||||
'error.500.desc': 'Máy chủ gặp sự cố. Không phải lỗi của bạn — thử lại sau giây lát.',
|
||||
'error.502.title': 'Cổng kết nối lỗi',
|
||||
'error.502.desc': 'Máy chủ nhận phản hồi không hợp lệ từ upstream. Thường chỉ là tạm thời.',
|
||||
'error.503.title': 'Dịch vụ không khả dụng',
|
||||
'error.503.desc':
|
||||
'Dịch vụ tạm thời gián đoạn — GitHub có thể đang trục trặc. Thử lại sau ít phút.',
|
||||
'error.504.title': 'Hết thời gian chờ cổng kết nối',
|
||||
'error.504.desc': 'Máy chủ upstream phản hồi quá lâu. Thử lại sau giây lát.',
|
||||
'error.unknown.title': 'Đã có lỗi xảy ra',
|
||||
'error.unknown.desc': 'Có lỗi không mong muốn. Thử lại, hoặc báo lỗi nếu vẫn tiếp diễn.',
|
||||
'error.offline.title': 'Bạn đang ngoại tuyến',
|
||||
'error.offline.desc': 'Không thể kết nối mạng. Kiểm tra kết nối rồi thử lại.',
|
||||
'error.chunk.title': 'Đã có phiên bản mới',
|
||||
'error.chunk.desc':
|
||||
'Ứng dụng đã được cập nhật sau khi trang này tải. Tải lại để dùng bản mới nhất.',
|
||||
'error.gameNotFound.title': 'Không tìm thấy game',
|
||||
'error.gameNotFound.desc': 'Không có game nào khớp với slug {slug}. Có thể đã bị đổi tên hoặc xoá.',
|
||||
'error.actions.home': 'Về trang chính',
|
||||
'error.actions.report': 'Báo lỗi',
|
||||
'error.actions.reload': 'Tải lại',
|
||||
'error.actions.details': 'Chi tiết kỹ thuật',
|
||||
'error.preview.hint': 'Xem trước trang lỗi {status}. Thử /errors/403, /errors/500, …',
|
||||
|
||||
// ---- merged from i18n sweep ----
|
||||
"about.ai.desc": "Không có đồng bảo trì viên thật nào (hướng nội cấp tối đa). Hai LLM này là thứ gần giống nhất.",
|
||||
"about.ai.title": "Đồng tác giả AI",
|
||||
"about.app.access": "Đọc dữ liệu là công khai (không cần xác thực). Ghi dữ liệu dùng GitHub PAT fine-grained, chỉ giữ trong bộ nhớ sau khi mở khoá bằng passphrase — xem mục Cài đặt.",
|
||||
"about.app.descPrefix": "Ứng dụng đồng hành đọc/ghi cho catalog ",
|
||||
"about.app.descSuffix": ". Duyệt hơn 500 game miễn phí từ itch.io, sửa ghi chú, chạy workflow scraper chỉ với một cú nhấp và trực quan hoá dữ liệu.",
|
||||
"about.app.meta": "v{version} · build ngày {buildDate} · giấy phép {license}",
|
||||
"about.bug.desc": "Nếu có gì hỏng — desktop hay web — hãy báo tại đây để mình thấy. Grok có lẽ sẽ vá xong trước khi mình thức dậy :D",
|
||||
"about.bug.openTemplate": "Mở mẫu báo cáo bug",
|
||||
"about.bug.title": "Phát hiện bug?",
|
||||
"about.developer.title": "Nhà phát triển",
|
||||
"about.footer": "Được tạo bằng các thư viện ở trên. Không theo dõi, không analytics, không telemetry.",
|
||||
"about.legal.desc": "Tất cả chính sách là file MD trong repo — ngắn gọn, dễ hiểu, hơi hài hước, điều khoản chính thức đầy đủ. Cập nhật 2026-05-05.",
|
||||
"about.legal.title": "Pháp lý & chính sách",
|
||||
"about.legal.viNote": "— bản dịch tiếng Việt của các chính sách trên (để cộng đồng dễ đọc; bản tiếng Anh vẫn là bản có hiệu lực khi diễn giải pháp lý).",
|
||||
"about.social.desc": "DM mở trên hầu hết các kênh. Trả lời chậm (hướng nội cấp tối đa). Chọn kênh nào tiện cho bạn.",
|
||||
"about.social.messagingNote": "Vui lòng DM riêng Telegram numeric ID của bạn. Đừng bao giờ đăng nó lên Discord/X/kênh công khai.",
|
||||
"about.social.paypalNote": "Biên lai hiển thị tên pháp lý thật (DungDang212) — chính là mình.",
|
||||
"about.social.supportNote": "Phản chiếu .github/FUNDING.yml — cùng các handle GitHub dùng cho nút Sponsor.",
|
||||
"about.social.title": "Tìm mình ở nơi khác",
|
||||
"about.thirdParty.core": "Cốt lõi",
|
||||
"about.thirdParty.data": "Tầng dữ liệu",
|
||||
"about.thirdParty.desc": "Các thư viện mã nguồn mở mà ứng dụng này dựa trên. Nhấp vào tên bất kỳ để mở trang chủ dự án; tên giấy phép liên kết tới mã định danh SPDX.",
|
||||
"about.thirdParty.desktop": "Desktop (Tauri)",
|
||||
"about.thirdParty.dev": "Công cụ dev",
|
||||
"about.thirdParty.title": "Phần mềm bên thứ ba",
|
||||
"about.thirdParty.ui": "UI / giao diện",
|
||||
"about.upstream.source": "Nguồn:",
|
||||
"about.upstream.title": "Ghi nguồn dữ liệu upstream",
|
||||
"add.addButton": "Thêm",
|
||||
"add.bulkDesc.prefix": "Mỗi dòng một URL (phân tách bằng khoảng trắng cũng được). Ghi vào",
|
||||
"add.bulkDesc.suffix": "trong một commit, rồi dispatch workflow.",
|
||||
"add.bulkTitle": "Nhập hàng loạt",
|
||||
"add.dispatching": "Đang dispatch workflow update...",
|
||||
"add.errDuplicate": "Đã có trong cơ sở dữ liệu",
|
||||
"add.errNotItchUrl": "Không phải URL itch.io",
|
||||
"add.patNotice.prefix": "Mở khoá PAT của bạn trong",
|
||||
"add.patNotice.suffix": "trước — thêm game sẽ dispatch workflow GitHub Actions, vốn yêu cầu",
|
||||
"add.polling": "Đã dispatch workflow. Đang chờ hoàn tất...",
|
||||
"add.queueDispatch": "Xếp hàng & dispatch",
|
||||
"add.runNotFoundMsg": "Không tìm thấy run; kiểm tra tab Quy trình",
|
||||
"add.singleDesc.prefix": "Dispatch",
|
||||
"add.singleDesc.suffix": "với URL này làm input. Workflow sẽ scrape, kiểm tra trạng thái miễn phí rồi commit — thường mất 60–120 giây.",
|
||||
"add.singleTitle": "Thêm một game theo URL",
|
||||
"add.statusBadge": "Trạng thái",
|
||||
"add.statusLine": "Trạng thái: {status}",
|
||||
"add.tabBulk": "Hàng loạt",
|
||||
"add.tabSingle": "Một URL",
|
||||
"add.toast.allInvalid": "Cả {count} URL đều không hợp lệ. {reason}",
|
||||
"add.toast.bulkFailed": "Nhập hàng loạt thất bại: {message}",
|
||||
"add.toast.completed": "Workflow hoàn tất. Đang làm mới dữ liệu.",
|
||||
"add.toast.dispatchFailed": "Dispatch thất bại: {message}",
|
||||
"add.toast.pasteAtLeastOne": "Dán ít nhất một URL.",
|
||||
"add.toast.pollTimeout": "Hết thời gian chờ. Kiểm tra tab Quy trình.",
|
||||
"add.toast.runNotFound": "Đã dispatch nhưng không tìm thấy run. Kiểm tra mục Quy trình.",
|
||||
"add.toast.skippedValid": "Bỏ qua {skipped}, hợp lệ {valid}.",
|
||||
"add.toast.unlockPat": "Mở khoá PAT của bạn trong Cài đặt.",
|
||||
"add.toast.workflowConcluded": "Workflow {conclusion}. Xem log của run.",
|
||||
"add.urlLabel": "URL itch.io",
|
||||
"add.viewRun": "Xem run",
|
||||
"add.working": "Đang xử lý...",
|
||||
"add.writingTempLink": "Đang ghi scripts/temp_link.json với {count} URL...",
|
||||
"bulk.delete.confirmToast": "Nhập '{expected}' để xác nhận.",
|
||||
"bulk.delete.cta": "Xoá {n}",
|
||||
"bulk.delete.deleting": "Đang xoá…",
|
||||
"bulk.delete.desc": "Một commit nguyên tử sẽ xoá các bản ghi khỏi các chunk data_game/ (đã cân bằng lại) và thêm mục vào scripts/deleted_games.json. Dùng nút hoàn tác sau khi commit để khôi phục. Chỉ có thể đảo ngược qua hoàn tác hoặc git revert.",
|
||||
"bulk.delete.more": "… và {n} game nữa",
|
||||
"bulk.delete.reason": "Lý do",
|
||||
"bulk.delete.title": "Xoá {n} game",
|
||||
"bulk.delete.typePrefix": "Nhập",
|
||||
"bulk.delete.typeSuffix": "để xác nhận",
|
||||
"bulk.edit.apply": "Áp dụng cho mục đã chọn",
|
||||
"bulk.edit.applying": "Đang áp dụng…",
|
||||
"bulk.edit.desc": "Bật một trường ở bên trái để áp dụng cùng giá trị cho mọi game đã chọn. Các trường không bật sẽ giữ nguyên.",
|
||||
"bulk.edit.notesPlaceholder": "Cùng một ghi chú cho mọi game đã chọn",
|
||||
"bulk.edit.title": "Sửa hàng loạt ({n} game)",
|
||||
"bulk.field.notesReplace": "Ghi chú (thay thế ghi chú cũ)",
|
||||
"bulk.field.safeVirus": "An toàn / virus",
|
||||
"bulk.reason.duplicate": "Trùng lặp",
|
||||
"bulk.reason.manualCleanup": "Dọn dẹp thủ công",
|
||||
"bulk.reason.other": "Khác",
|
||||
"bulk.reason.qualityIssue": "Vấn đề chất lượng",
|
||||
"bulk.safe.caution": "Cẩn trọng",
|
||||
"bulk.toast.cacheNotReady": "Cache game chưa sẵn sàng.",
|
||||
"bulk.toast.deleteFailed": "Xoá thất bại: {msg}",
|
||||
"bulk.toast.deleted": "Đã xoá {n} game trong {files} tệp ({sha}).",
|
||||
"bulk.toast.editFailed": "Sửa hàng loạt thất bại: {msg}",
|
||||
"bulk.toast.noField": "Bật ít nhất một trường để cập nhật.",
|
||||
"bulk.toast.unlockPat": "Mở khoá PAT trong Cài đặt.",
|
||||
"bulk.toast.updated": "Đã cập nhật {n} game trong {files} tệp ({sha}).",
|
||||
"bulk.undo.deleteLabel": "Xoá hàng loạt {n} game",
|
||||
"bulk.undo.editLabel": "Sửa hàng loạt {n} game",
|
||||
"charts.avgSession.title": "Thời lượng phiên chơi trung bình",
|
||||
"charts.deletionReasons.desc": "Vì sao game rời khỏi danh mục",
|
||||
"charts.deletionReasons.title": "Lý do xoá",
|
||||
"charts.deletionsOverTime.desc": "Số game bị xoá mỗi tháng",
|
||||
"charts.deletionsOverTime.title": "Lượt xoá theo thời gian",
|
||||
"charts.gameCount.desc": "Tổng số game trong danh mục theo ngày",
|
||||
"charts.gameCount.empty": "Chưa có dữ liệu lịch sử.",
|
||||
"charts.gameCount.title": "Số lượng game theo thời gian",
|
||||
"charts.genre.desc": "Top 15 theo số lượng game",
|
||||
"charts.genre.title": "Thể loại",
|
||||
"charts.genreTreemap.desc": "Top 12 thể loại, kích thước theo số lượng game",
|
||||
"charts.genreTreemap.title": "Treemap thể loại",
|
||||
"charts.kpi.avgRating": "Rating trung bình",
|
||||
"charts.kpi.deletedTotal": "Đã xoá (tổng)",
|
||||
"charts.kpi.nsfw": "NSFW",
|
||||
"charts.kpi.online": "Online (HTML5)",
|
||||
"charts.kpi.totalGames": "Tổng số game",
|
||||
"charts.languages.title": "Top 10 ngôn ngữ",
|
||||
"charts.madeWith.desc": "Engine chính của mỗi game (made_with[0])",
|
||||
"charts.madeWith.title": "Game engine",
|
||||
"charts.onlineOffline.desc": "HTML5 nghĩa là chơi được ngay trên trình duyệt",
|
||||
"charts.onlineOffline.offline": "Chỉ offline",
|
||||
"charts.onlineOffline.online": "Online (HTML5)",
|
||||
"charts.onlineOffline.title": "Online vs offline",
|
||||
"charts.platform.desc": "Đếm theo từng game (một game có thể hỗ trợ nhiều nền tảng)",
|
||||
"charts.platform.title": "Nền tảng",
|
||||
"charts.rating.desc": "Chia khoảng 0.5 sao từ 0 đến 5",
|
||||
"charts.rating.title": "Phân bố rating",
|
||||
"charts.recentDeleted.desc": "{shown} mục mới nhất trong tổng số {total}",
|
||||
"charts.recentDeleted.empty": "Chưa ghi nhận lượt xoá nào.",
|
||||
"charts.recentDeleted.title": "Xoá gần đây",
|
||||
"charts.status.desc": "Đã phát hành so với prototype/đang phát triển",
|
||||
"charts.status.title": "Tỷ lệ trạng thái",
|
||||
"charts.tabs.discovery": "Khám phá",
|
||||
"charts.tabs.overview": "Tổng quan",
|
||||
"charts.tabs.quality": "Chất lượng",
|
||||
"charts.tabs.reach": "Tiếp cận",
|
||||
"charts.topRatedCount.desc": "Top 10 theo số lượt rating",
|
||||
"charts.topRatedCount.title": "Game được đánh giá nhiều nhất",
|
||||
"charts.topTags.desc": "Xếp hạng kiểu word cloud (kích thước theo số lượng)",
|
||||
"charts.topTags.tagTitle": "{count} game",
|
||||
"charts.topTags.title": "Top 30 tag",
|
||||
"common.scrollToTop": "Cuộn lên đầu trang",
|
||||
"dashboard.databaseFiles": "Tệp cơ sở dữ liệu",
|
||||
"dashboard.deletionLog": "Nhật ký xoá",
|
||||
"dashboard.flagged": "{count} bị gắn cờ",
|
||||
"dashboard.gamesCount": "{count} game",
|
||||
"dashboard.lastUpdated": "Cập nhật lần cuối: {date}",
|
||||
"dashboard.nsfwRatio": "Tỉ lệ NSFW",
|
||||
"dashboard.onlineHtml5": "Chơi online (HTML5)",
|
||||
"dashboard.playableInBrowser": "{count} chơi được trên trình duyệt",
|
||||
"dashboard.released": "{count} đã phát hành",
|
||||
"dashboard.removedTotal": "game đã xoá tổng cộng",
|
||||
"dashboard.topGenre": "Thể loại hàng đầu",
|
||||
"dashboard.totalGames": "Tổng số game",
|
||||
"deleted.count": "{count} mục",
|
||||
"deleted.empty": "Chưa ghi nhận lượt xoá nào.",
|
||||
"detail.annotationsDesc": "Ba trường này do người dùng chỉnh sửa được trong Phase 2 (safe_virus, notes, nsfw). Mọi thứ phía trên là dữ liệu từ scraper và chỉ đọc.",
|
||||
"detail.avgSession": "Phiên chơi trung bình",
|
||||
"detail.backToGames": "Quay lại danh sách game",
|
||||
"detail.byDev": "bởi {dev}",
|
||||
"detail.coverAlt": "Ảnh bìa {name}",
|
||||
"detail.editTooltip": "Sửa chú thích",
|
||||
"detail.editTooltipLocked": "Mở khoá PAT trong Cài đặt để bật chỉnh sửa",
|
||||
"detail.genre": "Thể loại",
|
||||
"detail.inputs": "Điều khiển",
|
||||
"detail.languages": "Ngôn ngữ",
|
||||
"detail.madeWith": "Làm bằng",
|
||||
"detail.manualAnnotations": "Chú thích thủ công",
|
||||
"detail.metadata": "Metadata",
|
||||
"detail.noNotes": "Chưa có ghi chú",
|
||||
"detail.notes": "Ghi chú",
|
||||
"detail.nsfwOverride": "NSFW (ghi đè)",
|
||||
"detail.openOnItch": "Mở trên itch.io",
|
||||
"detail.platforms": "Nền tảng",
|
||||
"detail.publisher": "Nhà phát hành",
|
||||
"detail.rating": "Rating",
|
||||
"detail.releaseDate": "Ngày phát hành",
|
||||
"detail.reviewsCount": "({count} đánh giá)",
|
||||
"detail.safeVirus": "An toàn / virus",
|
||||
"detail.tags": "Tag",
|
||||
"detail.techReach": "Công nghệ & phạm vi",
|
||||
"editForm.desc": "Ba trường có thể chỉnh sửa. Mọi thứ khác được tự động lấy về và chỉ đọc.",
|
||||
"editForm.field.notes": "Ghi chú",
|
||||
"editForm.field.nsfw": "NSFW (ghi đè tự phát hiện)",
|
||||
"editForm.field.safeVirus": "An toàn / virus",
|
||||
"editForm.notesPlaceholder": "Ghi chú tự do (hỗ trợ markdown)",
|
||||
"editForm.safe.caution": "Cẩn trọng",
|
||||
"editForm.saving": "Đang lưu…",
|
||||
"editForm.title": "Sửa chú thích",
|
||||
"editForm.toast.cacheNotLoaded": "Cache game chưa được tải.",
|
||||
"editForm.toast.conflict": "Xung đột: tệp đã thay đổi trên remote. Hãy tải lại và sửa lại.",
|
||||
"editForm.toast.notesTooLong": "Ghi chú quá dài ({len}/{max}).",
|
||||
"editForm.toast.saveFailed": "Lưu thất bại: {msg}",
|
||||
"editForm.toast.saved": "Đã lưu vào {file} ({sha})",
|
||||
"editForm.toast.unlockPat": "Hãy mở khoá PAT trong Cài đặt trước.",
|
||||
"editForm.unlockHint": "Mở khoá PAT trong Cài đặt để bật nút Lưu.",
|
||||
"games.bulkDeleteTitle": "Xoá hàng loạt",
|
||||
"games.bulkEditTitle": "Sửa chú thích hàng loạt",
|
||||
"games.clearSelection": "Bỏ chọn",
|
||||
"games.count": "{shown} / {total}",
|
||||
"games.facet.genre": "Thể loại",
|
||||
"games.facet.nsfw": "NSFW",
|
||||
"games.facet.platforms": "Nền tảng",
|
||||
"games.facet.status": "Trạng thái",
|
||||
"games.selected": "Đã chọn {count}",
|
||||
"games.tip": "Mẹo: Shift-click tiêu đề cột để sắp xếp theo nhiều cột. Chọn hàng để bật Sửa / Xoá hàng loạt.",
|
||||
"games.unlockPatFirst": "Mở khoá PAT trước",
|
||||
"gpg.armoredKey": "Khoá riêng tư dạng armored",
|
||||
"gpg.commitAuthor": "Tác giả commit",
|
||||
"gpg.confirm.remove": "Xoá khoá GPG đã mã hoá khỏi trình duyệt này? Bạn sẽ cần nhập lại khoá.",
|
||||
"gpg.copyPublic": "Sao chép khoá công khai",
|
||||
"gpg.desc.1": "Ký mọi commit ứng dụng này tạo ra để chúng hiển thị là",
|
||||
"gpg.desc.2": "trên GitHub. Khoá riêng tư được giải mã một lần khi nhập và mã hoá lại bằng passphrase webapp của bạn (AES-GCM) trước khi lưu vào localStorage — cùng cơ chế với PAT.",
|
||||
"gpg.footer.1": "Nửa công khai của khoá này phải được tải lên",
|
||||
"gpg.footer.2": "để huy hiệu Verified xuất hiện. Dùng",
|
||||
"gpg.footer.3": "ở trên (khi đã mở khoá) — khối khoá công khai dạng armored sẽ được đưa vào clipboard.",
|
||||
"gpg.importKey": "Nhập khoá",
|
||||
"gpg.keyPassphrase": "Passphrase của khoá GPG",
|
||||
"gpg.keyPassphrasePlaceholder": "Để trống nếu khoá không có passphrase",
|
||||
"gpg.lock": "Khoá",
|
||||
"gpg.pasteFrom": "Hoặc dán từ",
|
||||
"gpg.patFirst": "Mở khoá PAT trước để dùng cùng passphrase mã hoá khoá này.",
|
||||
"gpg.removeKey": "Xoá khoá",
|
||||
"gpg.signCommits": "Ký commit",
|
||||
"gpg.signCommits.desc": "Tắt để giữ khoá đã nhập nhưng commit không được ký.",
|
||||
"gpg.status": "Trạng thái:",
|
||||
"gpg.status.noKey": "Chưa nhập khoá",
|
||||
"gpg.status.savedLocked": "Đã lưu (đang khoá)",
|
||||
"gpg.status.unlocked": "Đã mở khoá",
|
||||
"gpg.testSign": "Ký thử",
|
||||
"gpg.title": "Ký commit (GPG)",
|
||||
"gpg.toast.confirmPassphrase": "Xác nhận passphrase webapp (tối thiểu 8 ký tự) để mã hoá khoá cục bộ.",
|
||||
"gpg.toast.copyFailed": "Sao chép thất bại: {message}",
|
||||
"gpg.toast.enterPassphrase": "Nhập passphrase webapp của bạn.",
|
||||
"gpg.toast.importFailed": "Nhập thất bại: {message}",
|
||||
"gpg.toast.imported": "Đã nhập {fingerprint} — đã bật ký.",
|
||||
"gpg.toast.locked": "Đã khoá ký. Nhập lại passphrase để mở khoá.",
|
||||
"gpg.toast.noStoredKey": "Chưa lưu khoá GPG nào.",
|
||||
"gpg.toast.pasteKey": "Dán hoặc tải lên khoá GPG riêng tư dạng armored.",
|
||||
"gpg.toast.publicCopied": "Đã sao chép khoá công khai. Dán vào github.com/settings/keys → New GPG key.",
|
||||
"gpg.toast.removed": "Đã xoá khoá GPG.",
|
||||
"gpg.toast.testError": "Ký thử thất bại: {message}",
|
||||
"gpg.toast.testFail": "Chữ ký không vượt qua xác minh — vui lòng nhập lại khoá.",
|
||||
"gpg.toast.testOk": "Xác minh hai chiều thành công: ký đã hoạt động đúng.",
|
||||
"gpg.toast.unlockFailed": "Mở khoá thất bại: {message}",
|
||||
"gpg.toast.unlocked": "Đã mở khoá ký ({fingerprint}).",
|
||||
"gpg.uids.matches": "khớp với một UID — commit sẽ được Verify.",
|
||||
"gpg.uids.mismatch.1": "không nằm trong các UID của khoá này. GitHub sẽ hiển thị",
|
||||
"gpg.uids.mismatch.2": "ngay cả khi chữ ký hợp lệ. Cập nhật",
|
||||
"gpg.uids.mismatch.3": "ở trên thành một trong các badge, hoặc xoá trống để tự động dùng UID chính.",
|
||||
"gpg.uids.noOverride.1": "Chưa đặt ghi đè trong",
|
||||
"gpg.uids.noOverride.2": ". UID đầu tiên sẽ được dùng tự động.",
|
||||
"gpg.uids.title": "UID của khoá (một trong số này phải là email tác giả commit)",
|
||||
"gpg.unlock": "Mở khoá",
|
||||
"gpg.unlockPlaceholder": "Passphrase dùng để mã hoá PAT của bạn",
|
||||
"gpg.upload": "Tải lên .asc / .key",
|
||||
"gpg.webappPassphrase": "Passphrase webapp",
|
||||
"gpg.webappPassphraseDesc": "Dùng để mã hoá AES-GCM khoá (đã giải mã sẵn) trong localStorage.",
|
||||
"gpg.webappPassphrasePlaceholder": "Cùng passphrase với PAT của bạn — tối thiểu 8 ký tự",
|
||||
"settings.appearance.collapseSidebar": "Thu gọn thanh bên",
|
||||
"settings.appearance.collapseSidebarDesc": "Tương ứng với nút bật/tắt ở cuối thanh bên.",
|
||||
"settings.appearance.density": "Mật độ",
|
||||
"settings.appearance.desc": "Chủ đề và mật độ hiển thị. Lựa chọn được lưu vào localStorage.",
|
||||
"settings.appearance.theme": "Chủ đề",
|
||||
"settings.appearance.title": "Giao diện",
|
||||
"settings.auth.classicPrefix": "Token classic với scope",
|
||||
"settings.auth.classicSuffix": "cũng dùng được nhưng cấp quyền cho mọi repo bạn có quyền ghi.",
|
||||
"settings.auth.desc": "PAT của bạn được mã hoá bằng AES-GCM (PBKDF2-SHA256, 100k vòng lặp) với passphrase trước khi lưu vào localStorage. Token đã giải mã chỉ nằm trong bộ nhớ khi tab còn mở.",
|
||||
"settings.auth.forgetSaved": "Quên PAT đã lưu",
|
||||
"settings.auth.lock": "Khoá",
|
||||
"settings.auth.noToken": "Chưa lưu token",
|
||||
"settings.auth.passPlaceholder": "Tối thiểu 8 ký tự; cần để mở khoá sau này",
|
||||
"settings.auth.passphrase": "Passphrase",
|
||||
"settings.auth.passphrasePlaceholder": "Passphrase của bạn",
|
||||
"settings.auth.patLabel": "Personal Access Token",
|
||||
"settings.auth.patScopePrefix": "Token fine-grained chỉ cấp quyền cho",
|
||||
"settings.auth.patScopeSuffix": ", với các quyền repository sau:",
|
||||
"settings.auth.permActions": "cần để chạy workflow scraper từ trang Add / Workflows.",
|
||||
"settings.auth.permContents": "cần để sửa, xoá và đưa URL vào hàng đợi.",
|
||||
"settings.auth.removeSaved": "Xoá PAT đã lưu",
|
||||
"settings.auth.saveUnlock": "Lưu & mở khoá",
|
||||
"settings.auth.savedLocked": "Đã lưu (đang khoá)",
|
||||
"settings.auth.status": "Trạng thái:",
|
||||
"settings.auth.testRepo": "Kiểm tra truy cập repo",
|
||||
"settings.auth.title": "Xác thực GitHub",
|
||||
"settings.auth.unlock": "Mở khoá",
|
||||
"settings.auth.unlocked": "Đã mở khoá",
|
||||
"settings.author.descAnd": "và",
|
||||
"settings.author.descPrefix": "Tuỳ chọn ghi đè khối",
|
||||
"settings.author.descSuffix": "trong các commit tạo từ ứng dụng này. Để trống để dùng tài khoản GitHub từ PAT của bạn.",
|
||||
"settings.author.email": "Email",
|
||||
"settings.author.name": "Tên",
|
||||
"settings.author.namePlaceholder": "VD: Tên của bạn",
|
||||
"settings.author.title": "Tác giả commit",
|
||||
"settings.author.verifiedPrefix": "Để commit ký GPG hiển thị là",
|
||||
"settings.author.verifiedSuffix": ", email này phải khớp với một UID trong khoá GPG của bạn.",
|
||||
"settings.confirm.removePat": "Xoá PAT đã mã hoá khỏi trình duyệt này? Bạn sẽ cần dán lại token.",
|
||||
"settings.density.compact": "Gọn (hàng nhỏ hơn)",
|
||||
"settings.density.normal": "Bình thường",
|
||||
"settings.notif.desc": "Thông báo toast hiển thị ở góc trên bên phải.",
|
||||
"settings.notif.duration": "Thời lượng",
|
||||
"settings.notif.enable": "Bật toast",
|
||||
"settings.notif.enableDesc": "Tắt để ẩn toàn bộ popup thành công / lỗi / thông tin.",
|
||||
"settings.notif.title": "Thông báo",
|
||||
"settings.session.desc": "Thời gian PAT đã giải mã được giữ trong bộ nhớ sau khi mở khoá.",
|
||||
"settings.session.hour": "1 giờ",
|
||||
"settings.session.hours": "{h} giờ",
|
||||
"settings.session.idleNote": "PAT tự khoá khi không hoạt động. Nhập lại passphrase để mở khoá.",
|
||||
"settings.session.idleTimeout": "Tự khoá khi không hoạt động",
|
||||
"settings.session.minutes": "{m} phút",
|
||||
"settings.session.title": "Phiên làm việc",
|
||||
"settings.theme.dark": "Tối",
|
||||
"settings.theme.light": "Sáng",
|
||||
"settings.theme.system": "Theo hệ thống",
|
||||
"settings.toast.enterPassphrase": "Hãy nhập passphrase.",
|
||||
"settings.toast.locked": "Đã khoá. Nhập passphrase để mở khoá lại.",
|
||||
"settings.toast.noSavedPat": "Không tìm thấy PAT đã lưu.",
|
||||
"settings.toast.passMin": "Passphrase phải có ít nhất 8 ký tự.",
|
||||
"settings.toast.pastePat": "Hãy dán Personal Access Token trước.",
|
||||
"settings.toast.patInvalid": "Không thể xác thực PAT: {message}",
|
||||
"settings.toast.patRemoved": "Đã xoá PAT mã hoá khỏi localStorage.",
|
||||
"settings.toast.repoFail": "Không truy cập được {repo}. Kiểm tra scope của token.",
|
||||
"settings.toast.repoOk": "Truy cập được {repo}",
|
||||
"settings.toast.savedUnlockedAs": "Đã lưu & mở khoá với tài khoản {login}",
|
||||
"settings.toast.unlockFailed": "Mở khoá thất bại: {message}",
|
||||
"settings.toast.unlockedAs": "Đã mở khoá với tài khoản {login}",
|
||||
"sidebar.collapse": "Thu gọn thanh bên",
|
||||
"sidebar.desktopMode": "Chế độ desktop (Tauri)",
|
||||
"sidebar.expand": "Mở rộng thanh bên",
|
||||
"sidebar.navDescription": "Duyệt các trang, liên kết ủng hộ và trạng thái tài khoản.",
|
||||
"sidebar.navigation": "Điều hướng",
|
||||
"sidebar.noPat": "Chưa lưu PAT",
|
||||
"sidebar.openNav": "Mở điều hướng",
|
||||
"sidebar.patLocked": "PAT đã lưu nhưng đang khoá",
|
||||
"sidebar.signedInAs": "Đăng nhập với tư cách {login}",
|
||||
"sidebar.support": "Ủng hộ dự án",
|
||||
"sync.label": "Đồng bộ dữ liệu",
|
||||
"sync.syncing": "Đang đồng bộ...",
|
||||
"sync.title.authenticated": "Làm mới dữ liệu (đã xác thực)",
|
||||
"sync.title.cdn": "Làm mới dữ liệu (CDN)",
|
||||
"sync.toast.authenticated": "Đã đồng bộ (đã xác thực, bỏ qua cache CDN)",
|
||||
"sync.toast.cdn": "Đã đồng bộ từ CDN (raw.githubusercontent.com)",
|
||||
"sync.toast.failed": "Đồng bộ thất bại: {message}",
|
||||
"table.clearFilters": "Xoá bộ lọc",
|
||||
"table.dev": "Dev",
|
||||
"table.firstPage": "Trang đầu",
|
||||
"table.genre": "Thể loại",
|
||||
"table.lastPage": "Trang cuối",
|
||||
"table.name": "Tên",
|
||||
"table.nextPage": "Trang sau",
|
||||
"table.noOptions": "Không có tuỳ chọn",
|
||||
"table.noResults": "Không có kết quả.",
|
||||
"table.nsfw": "NSFW",
|
||||
"table.pageOf": "Trang {page} / {total}",
|
||||
"table.platforms": "Nền tảng",
|
||||
"table.prevPage": "Trang trước",
|
||||
"table.rating": "Rating",
|
||||
"table.reset": "Đặt lại",
|
||||
"table.rowsPerPage": "Số dòng mỗi trang",
|
||||
"table.safe": "An toàn",
|
||||
"table.searchPlaceholder": "Tìm theo tên, dev, mô tả...",
|
||||
"table.selectAll": "Chọn tất cả",
|
||||
"table.selectGame": "Chọn {name}",
|
||||
"table.selectRow": "Chọn dòng",
|
||||
"table.showingRange": "Hiển thị {start}–{end} trong {total}",
|
||||
"table.status": "Trạng thái",
|
||||
"theme.dark": "Tối",
|
||||
"theme.light": "Sáng",
|
||||
"theme.system": "Hệ thống",
|
||||
"theme.toggleTitle": "Giao diện: {label} (bấm để chuyển)",
|
||||
"undo.action": "Hoàn tác: {label}",
|
||||
"undo.createdAt": "Tạo lúc {date}",
|
||||
"undo.older": "+ {count} cũ hơn",
|
||||
"undo.recentCommits": "Commit gần đây:",
|
||||
"undo.toast.done": "Đã hoàn tác: {label}",
|
||||
"undo.toast.failed": "Hoàn tác thất bại: {message}",
|
||||
"undo.undoing": "Đang hoàn tác...",
|
||||
"workflows.checkAlive.desc": "Xác minh URL trả về 2xx/3xx",
|
||||
"workflows.checkAlive.label": "Kiểm tra còn hoạt động",
|
||||
"workflows.checkPaid.desc": "Kiểm tra lại trạng thái miễn phí/trả phí",
|
||||
"workflows.checkPaid.label": "Kiểm tra trả phí",
|
||||
"workflows.dispatch": "Dispatch",
|
||||
"workflows.generateTables.desc": "Tạo lại lists/*.md",
|
||||
"workflows.generateTables.label": "Tạo bảng",
|
||||
"workflows.logDeleted.desc": "Cập nhật deleted_games.txt",
|
||||
"workflows.logDeleted.label": "Ghi log game đã xoá",
|
||||
"workflows.noRuns": "Chưa có run nào.",
|
||||
"workflows.openRun": "Mở",
|
||||
"workflows.refresh": "Làm mới",
|
||||
"workflows.toast.dispatchFailed": "Dispatch thất bại: {message}",
|
||||
"workflows.toast.dispatched": "Đã dispatch {file}.",
|
||||
"workflows.toast.unlockPat": "Mở khoá PAT của bạn trong Cài đặt.",
|
||||
"workflows.unlockPatToView": "Mở khoá PAT để xem các run.",
|
||||
"workflows.update.desc": "Scrape URL mới từ temp_link.json + INPUT_URL",
|
||||
"workflows.update.label": "Cập nhật",
|
||||
}
|
||||
+41
-4
@@ -1,33 +1,70 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { QueryClient } from '@tanstack/react-query'
|
||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
||||
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
|
||||
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
|
||||
import { get, set, del } from 'idb-keyval'
|
||||
import { HashRouter } from 'react-router-dom'
|
||||
import App from './App'
|
||||
import { AppToaster } from './components/app-toaster'
|
||||
import { APP } from './lib/about'
|
||||
import { initI18n } from './lib/i18n'
|
||||
import './index.css'
|
||||
|
||||
// Catalog data persisted to IndexedDB survives restarts for up to a week —
|
||||
// instant paint from cache, then background revalidation. gcTime must be
|
||||
// >= maxAge or restored queries are garbage-collected right after hydration.
|
||||
const CACHE_MAX_AGE = 7 * 24 * 60 * 60 * 1000
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: 5 * 60 * 1000,
|
||||
gcTime: CACHE_MAX_AGE,
|
||||
refetchOnWindowFocus: true,
|
||||
retry: 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const persister = createAsyncStoragePersister({
|
||||
key: 'webapp.query-cache',
|
||||
storage: {
|
||||
getItem: async (key) => (await get<string>(key)) ?? null,
|
||||
setItem: (key, value) => set(key, value),
|
||||
removeItem: (key) => del(key),
|
||||
},
|
||||
throttleTime: 1_000,
|
||||
})
|
||||
|
||||
// Only the public catalog queries are persisted — never PAT-gated data.
|
||||
const PERSISTED_KEYS = new Set(['db', 'deleted', 'count-history'])
|
||||
|
||||
initI18n()
|
||||
|
||||
const rootEl = document.getElementById('root')
|
||||
if (!rootEl) throw new Error('Root element not found')
|
||||
|
||||
createRoot(rootEl).render(
|
||||
<StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<PersistQueryClientProvider
|
||||
client={queryClient}
|
||||
persistOptions={{
|
||||
persister,
|
||||
maxAge: CACHE_MAX_AGE,
|
||||
buster: APP.version,
|
||||
dehydrateOptions: {
|
||||
shouldDehydrateQuery: (q) =>
|
||||
q.state.status === 'success' && PERSISTED_KEYS.has(String(q.queryKey[0])),
|
||||
},
|
||||
}}
|
||||
>
|
||||
<HashRouter>
|
||||
<App />
|
||||
</HashRouter>
|
||||
<AppToaster />
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
</QueryClientProvider>
|
||||
{import.meta.env.DEV && <ReactQueryDevtools initialIsOpen={false} />}
|
||||
</PersistQueryClientProvider>
|
||||
</StrictMode>,
|
||||
)
|
||||
+58
-69
@@ -24,6 +24,7 @@ import { Button } from '@/components/ui/button'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { ExtLink } from '@/components/ext-link'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useT, type MessageKey } from '@/lib/i18n'
|
||||
import {
|
||||
AI_TOOLS,
|
||||
APP,
|
||||
@@ -42,12 +43,12 @@ import {
|
||||
type ThirdParty,
|
||||
} from '@/lib/about'
|
||||
|
||||
const CATEGORY_LABELS: Record<ThirdParty['category'], string> = {
|
||||
core: 'Core',
|
||||
ui: 'UI / styling',
|
||||
data: 'Data layer',
|
||||
desktop: 'Desktop (Tauri)',
|
||||
dev: 'Dev tooling',
|
||||
const CATEGORY_LABELS: Record<ThirdParty['category'], MessageKey> = {
|
||||
core: 'about.thirdParty.core',
|
||||
ui: 'about.thirdParty.ui',
|
||||
data: 'about.thirdParty.data',
|
||||
desktop: 'about.thirdParty.desktop',
|
||||
dev: 'about.thirdParty.dev',
|
||||
}
|
||||
|
||||
const SOCIAL_ICON: Record<string, LucideIcon> = {
|
||||
@@ -71,29 +72,32 @@ const SOCIAL_GROUP_ORDER: SocialGroup[] = ['social', 'community', 'messaging', '
|
||||
const LEGAL_GROUP_ORDER: LegalGroup[] = ['policy', 'meta']
|
||||
|
||||
function ThirdPartySection({ category }: { category: ThirdParty['category'] }) {
|
||||
const items = THIRD_PARTY.filter((t) => t.category === category)
|
||||
const t = useT()
|
||||
const items = THIRD_PARTY.filter((lib) => lib.category === category)
|
||||
if (items.length === 0) return null
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<h3 className="text-sm font-semibold text-muted-foreground">{CATEGORY_LABELS[category]}</h3>
|
||||
<h3 className="text-sm font-semibold text-muted-foreground">
|
||||
{t(CATEGORY_LABELS[category])}
|
||||
</h3>
|
||||
<ul className="grid grid-cols-1 gap-1.5 md:grid-cols-2">
|
||||
{items.map((t) => (
|
||||
{items.map((lib) => (
|
||||
<li
|
||||
key={t.name}
|
||||
key={lib.name}
|
||||
className="flex items-center justify-between gap-2 rounded-md border p-2 text-sm"
|
||||
>
|
||||
<ExtLink
|
||||
href={t.url}
|
||||
href={lib.url}
|
||||
className="inline-flex items-center gap-1 truncate font-medium hover:underline"
|
||||
title={`${t.name} ${t.version}`}
|
||||
title={`${lib.name} ${lib.version}`}
|
||||
>
|
||||
{t.name}
|
||||
{lib.name}
|
||||
<ExternalLinkIcon className="h-3 w-3 opacity-50" />
|
||||
</ExtLink>
|
||||
<div className="flex flex-shrink-0 items-center gap-2 text-xs">
|
||||
<span className="text-muted-foreground">{t.version}</span>
|
||||
<span className="text-muted-foreground">{lib.version}</span>
|
||||
<Badge variant="outline" className="font-mono text-xs">
|
||||
{t.license}
|
||||
{lib.license}
|
||||
</Badge>
|
||||
</div>
|
||||
</li>
|
||||
@@ -103,21 +107,20 @@ function ThirdPartySection({ category }: { category: ThirdParty['category'] }) {
|
||||
)
|
||||
}
|
||||
|
||||
const GROUP_NOTE: Partial<Record<SocialGroup, string>> = {
|
||||
messaging:
|
||||
'Please DM your Telegram numeric ID privately. Never post it to Discord/X/public channels.',
|
||||
support:
|
||||
'Mirrors .github/FUNDING.yml — same handles GitHub uses for the Sponsor button.',
|
||||
const GROUP_NOTE: Partial<Record<SocialGroup, MessageKey>> = {
|
||||
messaging: 'about.social.messagingNote',
|
||||
support: 'about.social.supportNote',
|
||||
}
|
||||
|
||||
const PLATFORM_NOTE: Record<string, string> = {
|
||||
paypal: 'Receipt shows real legal name (DungDang212) — that’s me.',
|
||||
const PLATFORM_NOTE: Record<string, MessageKey> = {
|
||||
paypal: 'about.social.paypalNote',
|
||||
}
|
||||
|
||||
function SocialGroupSection({ group }: { group: SocialGroup }) {
|
||||
const t = useT()
|
||||
const items = SOCIAL_LINKS.filter((s) => s.group === group)
|
||||
if (items.length === 0) return null
|
||||
const note = GROUP_NOTE[group]
|
||||
const noteKey = GROUP_NOTE[group]
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<h3
|
||||
@@ -126,7 +129,7 @@ function SocialGroupSection({ group }: { group: SocialGroup }) {
|
||||
>
|
||||
{SOCIAL_GROUP_LABELS[group]}
|
||||
</h3>
|
||||
{note && <p className="text-xs text-muted-foreground">{note}</p>}
|
||||
{noteKey && <p className="text-xs text-muted-foreground">{t(noteKey)}</p>}
|
||||
<ul className="grid grid-cols-1 gap-2 md:grid-cols-2">
|
||||
{items.map((s) => (
|
||||
<SocialItem key={s.platform} link={s} />
|
||||
@@ -137,8 +140,9 @@ function SocialGroupSection({ group }: { group: SocialGroup }) {
|
||||
}
|
||||
|
||||
function SocialItem({ link }: { link: SocialLink }) {
|
||||
const t = useT()
|
||||
const Icon = SOCIAL_ICON[link.platform] ?? Globe
|
||||
const note = PLATFORM_NOTE[link.platform]
|
||||
const noteKey = PLATFORM_NOTE[link.platform]
|
||||
return (
|
||||
<li className="rounded-md border">
|
||||
<ExtLink
|
||||
@@ -152,43 +156,44 @@ function SocialItem({ link }: { link: SocialLink }) {
|
||||
</span>
|
||||
<ExternalLinkIcon className="h-3 w-3 flex-shrink-0 opacity-50" />
|
||||
</ExtLink>
|
||||
{note && <p className="px-2 pb-1 text-[10px] text-muted-foreground">{note}</p>}
|
||||
{noteKey && <p className="px-2 pb-1 text-[10px] text-muted-foreground">{t(noteKey)}</p>}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
export default function About() {
|
||||
useDocumentTitle('About')
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.about'))
|
||||
return (
|
||||
<div className="container mx-auto max-w-4xl p-6">
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">About</h1>
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">{t('titles.about')}</h1>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{APP.name}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
v{APP.version} · built {APP.buildDate} · {APP.license} licensed
|
||||
{t('about.app.meta', {
|
||||
version: APP.version,
|
||||
buildDate: APP.buildDate,
|
||||
license: APP.license,
|
||||
})}
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2 text-sm">
|
||||
<p>
|
||||
A read/write companion app for the{' '}
|
||||
{t('about.app.descPrefix')}
|
||||
<ExtLink href={APP.repo} className="font-medium hover:underline">
|
||||
free-games-itchio-list
|
||||
</ExtLink>{' '}
|
||||
catalog. Browse 500+ free games from itch.io, edit annotations, dispatch the scraper
|
||||
workflow with one click, and visualize the dataset.
|
||||
</p>
|
||||
<p className="text-muted-foreground">
|
||||
Reads are public (no auth needed). Writes use a fine-grained GitHub PAT held only in
|
||||
memory after passphrase unlock — see Settings.
|
||||
</ExtLink>
|
||||
{t('about.app.descSuffix')}
|
||||
</p>
|
||||
<p className="text-muted-foreground">{t('about.app.access')}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Developer</CardTitle>
|
||||
<CardTitle className="text-base">{t('about.developer.title')}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2 text-sm">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
@@ -211,10 +216,8 @@ export default function About() {
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">AI co-authors</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
No real co-maintainers (introvert max level). These two LLMs are the closest thing.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('about.ai.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('about.ai.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 text-sm">
|
||||
{AI_TOOLS.map((tool) => (
|
||||
@@ -237,17 +240,14 @@ export default function About() {
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Found a bug?</CardTitle>
|
||||
<CardTitle className="text-base">{t('about.bug.title')}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 text-sm">
|
||||
<p className="text-muted-foreground">
|
||||
If something's broken — desktop or web — file it here so I see it. Grok will probably
|
||||
patch it before I wake up :D
|
||||
</p>
|
||||
<p className="text-muted-foreground">{t('about.bug.desc')}</p>
|
||||
<Button asChild variant="default" size="sm">
|
||||
<ExtLink href={ERROR_TEMPLATE_URL}>
|
||||
<Bug className="h-4 w-4" />
|
||||
Open bug report template
|
||||
{t('about.bug.openTemplate')}
|
||||
<ExternalLinkIcon className="h-3.5 w-3.5 opacity-80" />
|
||||
</ExtLink>
|
||||
</Button>
|
||||
@@ -256,10 +256,8 @@ export default function About() {
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Find me elsewhere</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
DMs open on most. Replies slow (introvert max level). Pick whichever channel fits.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('about.social.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('about.social.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-5">
|
||||
{SOCIAL_GROUP_ORDER.map((group, i) => (
|
||||
@@ -275,12 +273,9 @@ export default function About() {
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 text-base">
|
||||
<ScrollText className="h-4 w-4" />
|
||||
Legal & policies
|
||||
{t('about.legal.title')}
|
||||
</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
All policies are MD files in the repo — short, plain-language, slight humor, full
|
||||
on-the-record terms. Updated 2026-05-05.
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">{t('about.legal.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-5 text-sm">
|
||||
{LEGAL_GROUP_ORDER.map((group, i) => {
|
||||
@@ -314,19 +309,18 @@ export default function About() {
|
||||
<ExtLink href={LEGAL_VI_INDEX_URL} className="font-medium hover:underline">
|
||||
docs/i18n/vi/
|
||||
</ExtLink>{' '}
|
||||
— Vietnamese translations of the policies above (community-readable, English remains
|
||||
the controlling version for legal interpretation).
|
||||
{t('about.legal.viNote')}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Upstream data attribution</CardTitle>
|
||||
<CardTitle className="text-base">{t('about.upstream.title')}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2 text-sm">
|
||||
<p>
|
||||
Source:{' '}
|
||||
{t('about.upstream.source')}{' '}
|
||||
<ExtLink href={UPSTREAM_DATA.url} className="font-medium hover:underline">
|
||||
{UPSTREAM_DATA.source}
|
||||
</ExtLink>
|
||||
@@ -337,11 +331,8 @@ export default function About() {
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Third-party software</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Open-source libraries this app builds on. Click any name for the project's home page;
|
||||
license names link to the SPDX identifier.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('about.thirdParty.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('about.thirdParty.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-5">
|
||||
<ThirdPartySection category="core" />
|
||||
@@ -354,9 +345,7 @@ export default function About() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<p className="mt-6 text-center text-xs text-muted-foreground">
|
||||
Made with the libraries above. No tracking, no analytics, no telemetry.
|
||||
</p>
|
||||
<p className="mt-6 text-center text-xs text-muted-foreground">{t('about.footer')}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+38
-38
@@ -11,6 +11,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { useAllGames } from '@/hooks/useGames'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import { useAuth } from '@/stores/auth'
|
||||
import { createOctokit } from '@/lib/github/client'
|
||||
import { commitSingleFile } from '@/lib/github/contents'
|
||||
@@ -28,7 +29,8 @@ function normalizeUrl(u: string): string {
|
||||
}
|
||||
|
||||
export default function Add() {
|
||||
useDocumentTitle('Add Game')
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.addGame'))
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const all = useAllGames()
|
||||
const qc = useQueryClient()
|
||||
@@ -45,13 +47,13 @@ export default function Add() {
|
||||
|
||||
function validateOne(u: string): string | null {
|
||||
const norm = normalizeUrl(u)
|
||||
if (!URL_REGEX.test(norm)) return 'Not an itch.io URL'
|
||||
if (existingUrls.has(norm)) return 'Already in database'
|
||||
if (!URL_REGEX.test(norm)) return t('add.errNotItchUrl')
|
||||
if (existingUrls.has(norm)) return t('add.errDuplicate')
|
||||
return null
|
||||
}
|
||||
|
||||
async function pollRun(runId: number) {
|
||||
setProgressMsg('Workflow dispatched. Polling for completion...')
|
||||
setProgressMsg(t('add.polling'))
|
||||
const octokit = createOctokit()
|
||||
const start = Date.now()
|
||||
const TIMEOUT_MS = 5 * 60 * 1000
|
||||
@@ -59,27 +61,27 @@ export default function Add() {
|
||||
await new Promise((r) => setTimeout(r, 5_000))
|
||||
const run = await getWorkflowRun(octokit, runId)
|
||||
setRunUrl(run.html_url)
|
||||
setProgressMsg(`Status: ${run.status}${run.conclusion ? ` (${run.conclusion})` : ''}`)
|
||||
setProgressMsg(t('add.statusLine', { status: `${run.status}${run.conclusion ? ` (${run.conclusion})` : ''}` }))
|
||||
if (run.status === 'completed') {
|
||||
if (run.conclusion === 'success') {
|
||||
toast.success('Workflow completed. Refreshing data.')
|
||||
toast.success(t('add.toast.completed'))
|
||||
await qc.invalidateQueries({ queryKey: ['db'] })
|
||||
} else {
|
||||
toast.error(`Workflow ${run.conclusion}. See run logs.`)
|
||||
toast.error(t('add.toast.workflowConcluded', { conclusion: run.conclusion ?? '' }))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
toast.warning('Polling timed out. Check the Workflows tab.')
|
||||
toast.warning(t('add.toast.pollTimeout'))
|
||||
}
|
||||
|
||||
async function handleSingle() {
|
||||
if (!pat) return toast.error('Unlock your PAT in Settings.')
|
||||
if (!pat) return toast.error(t('add.toast.unlockPat'))
|
||||
const err = validateOne(single)
|
||||
if (err) return toast.error(err)
|
||||
setBusy(true)
|
||||
setRunUrl(null)
|
||||
setProgressMsg('Dispatching update workflow...')
|
||||
setProgressMsg(t('add.dispatching'))
|
||||
try {
|
||||
const octokit = createOctokit()
|
||||
const dispatchTime = Date.now() - 2_000
|
||||
@@ -91,14 +93,14 @@ export default function Add() {
|
||||
run = await findRecentDispatchedRun(octokit, 'update.yml', dispatchTime)
|
||||
}
|
||||
if (!run) {
|
||||
toast.warning('Dispatched but could not locate the run. Check Workflows.')
|
||||
setProgressMsg('Run not found; check Workflows tab')
|
||||
toast.warning(t('add.toast.runNotFound'))
|
||||
setProgressMsg(t('add.runNotFoundMsg'))
|
||||
return
|
||||
}
|
||||
setSingle('')
|
||||
await pollRun(run.id)
|
||||
} catch (e) {
|
||||
toast.error(`Dispatch failed: ${(e as Error).message}`)
|
||||
toast.error(t('add.toast.dispatchFailed', { message: (e as Error).message }))
|
||||
setProgressMsg('')
|
||||
} finally {
|
||||
setBusy(false)
|
||||
@@ -106,12 +108,12 @@ export default function Add() {
|
||||
}
|
||||
|
||||
async function handleBulk() {
|
||||
if (!pat) return toast.error('Unlock your PAT in Settings.')
|
||||
if (!pat) return toast.error(t('add.toast.unlockPat'))
|
||||
const lines = bulk
|
||||
.split(/\s+/)
|
||||
.map((l) => normalizeUrl(l))
|
||||
.filter(Boolean)
|
||||
if (lines.length === 0) return toast.error('Paste at least one URL.')
|
||||
if (lines.length === 0) return toast.error(t('add.toast.pasteAtLeastOne'))
|
||||
|
||||
const valid: string[] = []
|
||||
const errors: { url: string; reason: string }[] = []
|
||||
@@ -121,14 +123,14 @@ export default function Add() {
|
||||
else if (!valid.includes(u)) valid.push(u)
|
||||
}
|
||||
if (valid.length === 0) {
|
||||
toast.error(`All ${lines.length} URLs invalid. ${errors[0]?.reason ?? ''}`)
|
||||
toast.error(t('add.toast.allInvalid', { count: lines.length, reason: errors[0]?.reason ?? '' }))
|
||||
return
|
||||
}
|
||||
if (errors.length > 0) toast.warning(`${errors.length} skipped, ${valid.length} valid.`)
|
||||
if (errors.length > 0) toast.warning(t('add.toast.skippedValid', { skipped: errors.length, valid: valid.length }))
|
||||
|
||||
setBusy(true)
|
||||
setRunUrl(null)
|
||||
setProgressMsg(`Writing scripts/temp_link.json with ${valid.length} URLs...`)
|
||||
setProgressMsg(t('add.writingTempLink', { count: valid.length }))
|
||||
try {
|
||||
const octokit = createOctokit()
|
||||
const newJson = JSON.stringify(valid, null, 4) + '\n'
|
||||
@@ -138,7 +140,7 @@ export default function Add() {
|
||||
newJson,
|
||||
`chore(webapp): queue ${valid.length} new URLs`,
|
||||
)
|
||||
setProgressMsg('Dispatching update workflow...')
|
||||
setProgressMsg(t('add.dispatching'))
|
||||
const dispatchTime = Date.now() - 2_000
|
||||
await dispatchWorkflow(octokit, 'update.yml')
|
||||
let run = null
|
||||
@@ -150,10 +152,10 @@ export default function Add() {
|
||||
setBulk('')
|
||||
await pollRun(run.id)
|
||||
} else {
|
||||
toast.warning('Dispatched but could not locate the run. Check Workflows.')
|
||||
toast.warning(t('add.toast.runNotFound'))
|
||||
}
|
||||
} catch (e) {
|
||||
toast.error(`Bulk failed: ${(e as Error).message}`)
|
||||
toast.error(t('add.toast.bulkFailed', { message: (e as Error).message }))
|
||||
setProgressMsg('')
|
||||
} finally {
|
||||
setBusy(false)
|
||||
@@ -162,35 +164,34 @@ export default function Add() {
|
||||
|
||||
return (
|
||||
<div className="container mx-auto max-w-2xl p-6">
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">Add Game</h1>
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">{t('titles.addGame')}</h1>
|
||||
|
||||
{!pat && (
|
||||
<Card className="mb-4">
|
||||
<CardContent className="p-4 text-sm text-muted-foreground">
|
||||
Unlock your PAT in <b>Settings</b> first — adding games dispatches the GitHub
|
||||
Actions workflow which requires <code>workflow:write</code>.
|
||||
{t('add.patNotice.prefix')} <b>{t('nav.settings')}</b>{' '}
|
||||
{t('add.patNotice.suffix')} <code>workflow:write</code>.
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<Tabs defaultValue="single">
|
||||
<TabsList>
|
||||
<TabsTrigger value="single">Single URL</TabsTrigger>
|
||||
<TabsTrigger value="bulk">Bulk</TabsTrigger>
|
||||
<TabsTrigger value="single">{t('add.tabSingle')}</TabsTrigger>
|
||||
<TabsTrigger value="bulk">{t('add.tabBulk')}</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="single">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Add one game by URL</CardTitle>
|
||||
<CardTitle className="text-base">{t('add.singleTitle')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Dispatches <code>update.yml</code> with this URL as input. The workflow scrapes,
|
||||
validates free status, and commits — usually 60–120 s.
|
||||
{t('add.singleDesc.prefix')} <code>update.yml</code> {t('add.singleDesc.suffix')}
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="single">itch.io URL</Label>
|
||||
<Label htmlFor="single">{t('add.urlLabel')}</Label>
|
||||
<Input
|
||||
id="single"
|
||||
placeholder="https://username.itch.io/game-slug"
|
||||
@@ -201,7 +202,7 @@ export default function Add() {
|
||||
</div>
|
||||
<Button onClick={handleSingle} disabled={busy || !pat}>
|
||||
<Plus className="h-4 w-4" />
|
||||
{busy ? 'Working...' : 'Add'}
|
||||
{busy ? t('add.working') : t('add.addButton')}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -210,11 +211,10 @@ export default function Add() {
|
||||
<TabsContent value="bulk">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Bulk import</CardTitle>
|
||||
<CardTitle className="text-base">{t('add.bulkTitle')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
One URL per line (whitespace-separated also OK). Writes them to
|
||||
<code> scripts/temp_link.json</code> in a single commit, then dispatches the
|
||||
workflow.
|
||||
{t('add.bulkDesc.prefix')} <code>scripts/temp_link.json</code>{' '}
|
||||
{t('add.bulkDesc.suffix')}
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
@@ -226,7 +226,7 @@ export default function Add() {
|
||||
/>
|
||||
<Button onClick={handleBulk} disabled={busy || !pat}>
|
||||
<Upload className="h-4 w-4" />
|
||||
{busy ? 'Working...' : 'Queue & dispatch'}
|
||||
{busy ? t('add.working') : t('add.queueDispatch')}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -238,7 +238,7 @@ export default function Add() {
|
||||
<CardContent className="p-4">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<Badge variant="secondary">Status</Badge>
|
||||
<Badge variant="secondary">{t('add.statusBadge')}</Badge>
|
||||
<span>{progressMsg}</span>
|
||||
</div>
|
||||
{runUrl && (
|
||||
@@ -248,7 +248,7 @@ export default function Add() {
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-1 text-sm text-primary hover:underline"
|
||||
>
|
||||
View run
|
||||
{t('add.viewRun')}
|
||||
<ExternalLink className="h-3 w-3" />
|
||||
</a>
|
||||
)}
|
||||
|
||||
@@ -18,11 +18,14 @@ import {
|
||||
TopRatedCountChart,
|
||||
TopTagsChart,
|
||||
} from '@/components/charts'
|
||||
import { RouteError } from '@/components/route-error'
|
||||
import { useAllGames, useCountHistory, useDeletedGames } from '@/hooks/useGames'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
export default function Charts() {
|
||||
useDocumentTitle('Charts')
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.charts'))
|
||||
const games = useAllGames()
|
||||
const deleted = useDeletedGames()
|
||||
const history = useCountHistory()
|
||||
@@ -30,7 +33,7 @@ export default function Charts() {
|
||||
if (games.isLoading) {
|
||||
return (
|
||||
<div className="container mx-auto p-6 space-y-4">
|
||||
<h1 className="text-3xl font-bold tracking-tight">Charts</h1>
|
||||
<h1 className="text-3xl font-bold tracking-tight">{t('titles.charts')}</h1>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-72" />
|
||||
@@ -41,12 +44,7 @@ export default function Charts() {
|
||||
}
|
||||
|
||||
if (games.isError) {
|
||||
return (
|
||||
<div className="container mx-auto p-6">
|
||||
<h1 className="mb-4 text-3xl font-bold tracking-tight">Charts</h1>
|
||||
<p className="text-destructive">Failed to load: {games.error.message}</p>
|
||||
</div>
|
||||
)
|
||||
return <RouteError error={games.error} onRetry={() => void games.refetch()} />
|
||||
}
|
||||
|
||||
const data = games.data?.games ?? []
|
||||
@@ -55,14 +53,14 @@ export default function Charts() {
|
||||
|
||||
return (
|
||||
<div className="container mx-auto p-6">
|
||||
<h1 className="mb-4 text-3xl font-bold tracking-tight">Charts</h1>
|
||||
<h1 className="mb-4 text-3xl font-bold tracking-tight">{t('titles.charts')}</h1>
|
||||
|
||||
<Tabs defaultValue="overview">
|
||||
<TabsList className="flex-wrap">
|
||||
<TabsTrigger value="overview">Overview</TabsTrigger>
|
||||
<TabsTrigger value="reach">Reach</TabsTrigger>
|
||||
<TabsTrigger value="quality">Quality</TabsTrigger>
|
||||
<TabsTrigger value="discovery">Discovery</TabsTrigger>
|
||||
<TabsTrigger value="overview">{t('charts.tabs.overview')}</TabsTrigger>
|
||||
<TabsTrigger value="reach">{t('charts.tabs.reach')}</TabsTrigger>
|
||||
<TabsTrigger value="quality">{t('charts.tabs.quality')}</TabsTrigger>
|
||||
<TabsTrigger value="discovery">{t('charts.tabs.discovery')}</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="overview" className="space-y-4">
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { RouteError } from '@/components/route-error'
|
||||
import { useAllGames, useDeletedGames } from '@/hooks/useGames'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import { computeOverview } from '@/lib/analytics'
|
||||
import { formatNumber } from '@/lib/utils'
|
||||
|
||||
export default function Dashboard() {
|
||||
useDocumentTitle('Dashboard')
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.dashboard'))
|
||||
const games = useAllGames()
|
||||
const deleted = useDeletedGames()
|
||||
|
||||
if (games.isLoading) {
|
||||
return (
|
||||
<div className="container mx-auto p-8">
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">Dashboard</h1>
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">{t('nav.dashboard')}</h1>
|
||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-32" />
|
||||
@@ -24,12 +27,7 @@ export default function Dashboard() {
|
||||
}
|
||||
|
||||
if (games.isError) {
|
||||
return (
|
||||
<div className="container mx-auto p-8">
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">Dashboard</h1>
|
||||
<p className="text-destructive">Failed to load games: {games.error.message}</p>
|
||||
</div>
|
||||
)
|
||||
return <RouteError error={games.error} onRetry={() => void games.refetch()} />
|
||||
}
|
||||
|
||||
const stats = games.data ? computeOverview(games.data.games) : null
|
||||
@@ -40,21 +38,21 @@ export default function Dashboard() {
|
||||
return (
|
||||
<div className="container mx-auto p-8">
|
||||
<div className="mb-6 flex items-baseline justify-between">
|
||||
<h1 className="text-3xl font-bold tracking-tight">Dashboard</h1>
|
||||
<p className="text-sm text-muted-foreground">Last updated: {lastUpdated}</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight">{t('nav.dashboard')}</h1>
|
||||
<p className="text-sm text-muted-foreground">{t('dashboard.lastUpdated', { date: lastUpdated })}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">
|
||||
Total Games
|
||||
{t('dashboard.totalGames')}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-3xl font-bold">{stats ? formatNumber(stats.total) : '—'}</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{stats?.releasedCount ?? 0} released
|
||||
{t('dashboard.released', { count: stats?.releasedCount ?? 0 })}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -62,41 +60,41 @@ export default function Dashboard() {
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">
|
||||
NSFW Ratio
|
||||
{t('dashboard.nsfwRatio')}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-3xl font-bold">
|
||||
{stats ? `${stats.nsfwPercent.toFixed(1)}%` : '—'}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{stats?.nsfwCount ?? 0} flagged</p>
|
||||
<p className="text-xs text-muted-foreground">{t('dashboard.flagged', { count: stats?.nsfwCount ?? 0 })}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">
|
||||
Online (HTML5)
|
||||
{t('dashboard.onlineHtml5')}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-3xl font-bold">
|
||||
{stats ? `${stats.onlinePercent.toFixed(1)}%` : '—'}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{stats?.htmlCount ?? 0} playable in browser</p>
|
||||
<p className="text-xs text-muted-foreground">{t('dashboard.playableInBrowser', { count: stats?.htmlCount ?? 0 })}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">
|
||||
Top Genre
|
||||
{t('dashboard.topGenre')}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-3xl font-bold">{stats?.topGenre ?? '—'}</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{stats ? `${formatNumber(stats.topGenreCount)} games` : ''}
|
||||
{stats ? t('dashboard.gamesCount', { count: formatNumber(stats.topGenreCount) }) : ''}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -105,14 +103,14 @@ export default function Dashboard() {
|
||||
<div className="mt-6 grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Database Files</CardTitle>
|
||||
<CardTitle className="text-base">{t('dashboard.databaseFiles')}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ul className="space-y-1 text-sm">
|
||||
{games.data?.index.files.map((f) => (
|
||||
<li key={f.name} className="flex justify-between border-b py-1 last:border-0">
|
||||
<span className="font-mono text-muted-foreground">{f.name}</span>
|
||||
<span>{formatNumber(f.count)} games</span>
|
||||
<span>{t('dashboard.gamesCount', { count: formatNumber(f.count) })}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -121,7 +119,7 @@ export default function Dashboard() {
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Deletion Log</CardTitle>
|
||||
<CardTitle className="text-base">{t('dashboard.deletionLog')}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{deleted.isLoading ? (
|
||||
@@ -129,7 +127,7 @@ export default function Dashboard() {
|
||||
) : (
|
||||
<p className="text-sm">
|
||||
<span className="text-3xl font-bold">{formatNumber(deleted.data?.length ?? 0)}</span>{' '}
|
||||
games removed total
|
||||
{t('dashboard.removedTotal')}
|
||||
</p>
|
||||
)}
|
||||
</CardContent>
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { RouteError } from '@/components/route-error'
|
||||
import { useDeletedGames } from '@/hooks/useGames'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { formatNumber } from '@/lib/utils'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
export default function Deleted() {
|
||||
useDocumentTitle('Deleted Games')
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.deleted'))
|
||||
const deleted = useDeletedGames()
|
||||
|
||||
if (deleted.isLoading) {
|
||||
return (
|
||||
<div className="container mx-auto p-8 space-y-3">
|
||||
<h1 className="text-3xl font-bold tracking-tight">Deleted Games</h1>
|
||||
<h1 className="text-3xl font-bold tracking-tight">{t('titles.deleted')}</h1>
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-16" />
|
||||
))}
|
||||
@@ -21,12 +24,7 @@ export default function Deleted() {
|
||||
}
|
||||
|
||||
if (deleted.isError) {
|
||||
return (
|
||||
<div className="container mx-auto p-8">
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">Deleted Games</h1>
|
||||
<p className="text-destructive">Failed to load: {deleted.error.message}</p>
|
||||
</div>
|
||||
)
|
||||
return <RouteError error={deleted.error} onRetry={() => void deleted.refetch()} />
|
||||
}
|
||||
|
||||
const entries = deleted.data ?? []
|
||||
@@ -37,14 +35,14 @@ export default function Deleted() {
|
||||
return (
|
||||
<div className="container mx-auto p-8">
|
||||
<div className="mb-6 flex items-baseline justify-between">
|
||||
<h1 className="text-3xl font-bold tracking-tight">Deleted Games</h1>
|
||||
<h1 className="text-3xl font-bold tracking-tight">{t('titles.deleted')}</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{formatNumber(sorted.length)} entries
|
||||
{t('deleted.count', { count: formatNumber(sorted.length) })}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{sorted.length === 0 ? (
|
||||
<p className="text-muted-foreground">No deletions logged.</p>
|
||||
<p className="text-muted-foreground">{t('deleted.empty')}</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{sorted.map((d) => (
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { ErrorPage } from '@/components/error-page'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
/**
|
||||
* Hidden route (`/errors/:code`) for previewing the error pages — not linked
|
||||
* from the nav. Try `#/errors/403`, `#/errors/500`, `#/errors/999`.
|
||||
*/
|
||||
export default function ErrorPreview() {
|
||||
const { code } = useParams()
|
||||
const t = useT()
|
||||
const status = Number(code)
|
||||
useDocumentTitle(`Error ${code ?? ''}`)
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
<p className="px-6 pt-4 text-center text-xs text-muted-foreground">
|
||||
{t('error.preview.hint', { status: code ?? '?' })}
|
||||
</p>
|
||||
<ErrorPage status={Number.isFinite(status) ? status : undefined} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -8,9 +8,13 @@ import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { ExtLink } from '@/components/ext-link'
|
||||
import { EditGameForm } from '@/components/edit-game-form'
|
||||
import { ErrorPage } from '@/components/error-page'
|
||||
import { RouteError } from '@/components/route-error'
|
||||
import { GameThumb } from '@/components/game-thumb'
|
||||
import { useGameBySlug } from '@/hooks/useGameBySlug'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useAuth } from '@/stores/auth'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import type { Game } from '@/types/game'
|
||||
|
||||
function FieldRow({ label, children }: { label: string; children: React.ReactNode }) {
|
||||
@@ -36,6 +40,7 @@ function ArrayBadges({ items, variant = 'outline' }: { items: string[]; variant?
|
||||
}
|
||||
|
||||
function GameDetailView({ game }: { game: Game }) {
|
||||
const t = useT()
|
||||
useDocumentTitle(game.name)
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const [editing, setEditing] = useState(false)
|
||||
@@ -46,7 +51,7 @@ function GameDetailView({ game }: { game: Game }) {
|
||||
<Button variant="ghost" size="sm" asChild>
|
||||
<Link to="/games">
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
Back to games
|
||||
{t('detail.backToGames')}
|
||||
</Link>
|
||||
</Button>
|
||||
{!editing && (
|
||||
@@ -54,10 +59,10 @@ function GameDetailView({ game }: { game: Game }) {
|
||||
size="sm"
|
||||
onClick={() => setEditing(true)}
|
||||
disabled={!pat}
|
||||
title={pat ? 'Edit annotations' : 'Unlock your PAT in Settings to enable editing'}
|
||||
title={pat ? t('detail.editTooltip') : t('detail.editTooltipLocked')}
|
||||
>
|
||||
<Pencil className="h-4 w-4" />
|
||||
Edit
|
||||
{t('common.edit')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@@ -74,37 +79,29 @@ function GameDetailView({ game }: { game: Game }) {
|
||||
|
||||
<Card>
|
||||
<CardContent className="flex flex-col gap-6 p-6 md:flex-row">
|
||||
{game.thumbnail ? (
|
||||
<img
|
||||
src={game.thumbnail}
|
||||
alt={`${game.name} cover`}
|
||||
width={630}
|
||||
height={500}
|
||||
decoding="async"
|
||||
fetchPriority="high"
|
||||
className="h-48 w-full flex-shrink-0 rounded-lg object-cover md:w-80"
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className="h-48 w-full flex-shrink-0 rounded-lg bg-muted md:w-80"
|
||||
/>
|
||||
)}
|
||||
<GameThumb
|
||||
src={game.thumbnail}
|
||||
alt={t('detail.coverAlt', { name: game.name })}
|
||||
width={630}
|
||||
height={500}
|
||||
decoding="async"
|
||||
fetchPriority="high"
|
||||
className="h-48 w-full flex-shrink-0 rounded-lg object-cover md:w-80"
|
||||
/>
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<div className="flex flex-wrap items-baseline gap-2">
|
||||
<h1 className="text-3xl font-bold tracking-tight">{game.name}</h1>
|
||||
{game.nsfw === 'Yes' && <Badge variant="destructive">NSFW</Badge>}
|
||||
<Badge variant={game.status === 'Released' ? 'default' : 'secondary'}>
|
||||
{game.status || 'Unknown'}
|
||||
{game.status || t('common.unknown')}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="mt-1 text-sm text-muted-foreground">by {game.dev}</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">{t('detail.byDev', { dev: game.dev })}</p>
|
||||
<p className="mt-3 text-sm">{game.description}</p>
|
||||
<div className="mt-auto pt-4">
|
||||
<Button variant="outline" size="sm" asChild>
|
||||
<ExtLink href={game.url}>
|
||||
Open on itch.io
|
||||
{t('detail.openOnItch')}
|
||||
<ExternalLink className="h-4 w-4" />
|
||||
</ExtLink>
|
||||
</Button>
|
||||
@@ -116,28 +113,28 @@ function GameDetailView({ game }: { game: Game }) {
|
||||
<div className="mt-6 grid gap-6 md:grid-cols-2">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Metadata</CardTitle>
|
||||
<CardTitle className="text-base">{t('detail.metadata')}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<dl className="divide-y">
|
||||
<FieldRow label="Genre">
|
||||
<Badge variant="secondary">{game.genre || 'Unknown'}</Badge>
|
||||
<FieldRow label={t('detail.genre')}>
|
||||
<Badge variant="secondary">{game.genre || t('common.unknown')}</Badge>
|
||||
</FieldRow>
|
||||
<FieldRow label="Publisher">{game.publisher || '—'}</FieldRow>
|
||||
<FieldRow label="Release date">{game.release_date || '—'}</FieldRow>
|
||||
<FieldRow label="Rating">
|
||||
<FieldRow label={t('detail.publisher')}>{game.publisher || '—'}</FieldRow>
|
||||
<FieldRow label={t('detail.releaseDate')}>{game.release_date || '—'}</FieldRow>
|
||||
<FieldRow label={t('detail.rating')}>
|
||||
{game.rating ? (
|
||||
<span>
|
||||
{game.rating}{' '}
|
||||
<span className="text-muted-foreground">
|
||||
{game.rating_count ? `(${game.rating_count} reviews)` : ''}
|
||||
{game.rating_count ? t('detail.reviewsCount', { count: game.rating_count }) : ''}
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
'—'
|
||||
)}
|
||||
</FieldRow>
|
||||
<FieldRow label="Avg session">{game.average_session || '—'}</FieldRow>
|
||||
<FieldRow label={t('detail.avgSession')}>{game.average_session || '—'}</FieldRow>
|
||||
<FieldRow label="NSFW">{game.nsfw || '—'}</FieldRow>
|
||||
</dl>
|
||||
</CardContent>
|
||||
@@ -145,23 +142,23 @@ function GameDetailView({ game }: { game: Game }) {
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Tech & Reach</CardTitle>
|
||||
<CardTitle className="text-base">{t('detail.techReach')}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<dl className="divide-y">
|
||||
<FieldRow label="Platforms">
|
||||
<FieldRow label={t('detail.platforms')}>
|
||||
<ArrayBadges items={game.platforms} />
|
||||
</FieldRow>
|
||||
<FieldRow label="Languages">
|
||||
<FieldRow label={t('detail.languages')}>
|
||||
<ArrayBadges items={game.languages} />
|
||||
</FieldRow>
|
||||
<FieldRow label="Inputs">
|
||||
<FieldRow label={t('detail.inputs')}>
|
||||
<ArrayBadges items={game.inputs} />
|
||||
</FieldRow>
|
||||
<FieldRow label="Made with">
|
||||
<FieldRow label={t('detail.madeWith')}>
|
||||
<ArrayBadges items={game.made_with} />
|
||||
</FieldRow>
|
||||
<FieldRow label="Tags">
|
||||
<FieldRow label={t('detail.tags')}>
|
||||
<ArrayBadges items={game.tags} variant="secondary" />
|
||||
</FieldRow>
|
||||
</dl>
|
||||
@@ -171,23 +168,20 @@ function GameDetailView({ game }: { game: Game }) {
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Manual Annotations</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
These three fields are user-editable in Phase 2 (safe_virus, notes, nsfw). Everything
|
||||
above comes from the scraper and is read-only.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('detail.manualAnnotations')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('detail.annotationsDesc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<dl className="divide-y">
|
||||
<FieldRow label="Safe / virus">
|
||||
<FieldRow label={t('detail.safeVirus')}>
|
||||
<Badge variant="outline">{game.safe_virus || '?'}</Badge>
|
||||
</FieldRow>
|
||||
<FieldRow label="NSFW (override)">{game.nsfw || '—'}</FieldRow>
|
||||
<FieldRow label="Notes">
|
||||
<FieldRow label={t('detail.nsfwOverride')}>{game.nsfw || '—'}</FieldRow>
|
||||
<FieldRow label={t('detail.notes')}>
|
||||
{game.notes ? (
|
||||
<span className="whitespace-pre-wrap">{game.notes}</span>
|
||||
) : (
|
||||
<span className="text-muted-foreground">No notes yet</span>
|
||||
<span className="text-muted-foreground">{t('detail.noNotes')}</span>
|
||||
)}
|
||||
</FieldRow>
|
||||
</dl>
|
||||
@@ -203,9 +197,10 @@ function GameDetailView({ game }: { game: Game }) {
|
||||
}
|
||||
|
||||
export default function GameDetail() {
|
||||
const t = useT()
|
||||
const { slug } = useParams()
|
||||
const decoded = slug ? decodeURIComponent(slug) : undefined
|
||||
const { game, isLoading, isError, error } = useGameBySlug(decoded)
|
||||
const { game, isLoading, isError, error, refetch } = useGameBySlug(decoded)
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
@@ -221,24 +216,24 @@ export default function GameDetail() {
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
return (
|
||||
<div className="container mx-auto p-6">
|
||||
<p className="text-destructive">Failed to load: {error?.message}</p>
|
||||
</div>
|
||||
)
|
||||
return <RouteError error={error} onRetry={() => void refetch()} />
|
||||
}
|
||||
|
||||
if (!game) {
|
||||
return (
|
||||
<div className="container mx-auto p-6">
|
||||
<Button variant="ghost" size="sm" asChild className="mb-4">
|
||||
<Link to="/games">
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
Back to games
|
||||
</Link>
|
||||
</Button>
|
||||
<p className="text-muted-foreground">Game not found for slug: <code>{decoded}</code></p>
|
||||
</div>
|
||||
<ErrorPage
|
||||
status={404}
|
||||
title={t('error.gameNotFound.title')}
|
||||
description={t('error.gameNotFound.desc', { slug: decoded ?? '' })}
|
||||
actions={
|
||||
<Button asChild>
|
||||
<Link to="/games">
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
{t('detail.backToGames')}
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+21
-24
@@ -20,10 +20,12 @@ import { gameColumns } from '@/components/data-table/columns'
|
||||
import type { FacetOption } from '@/components/data-table/faceted-filter'
|
||||
import { BulkEditDialog } from '@/components/bulk-edit-dialog'
|
||||
import { BulkDeleteDialog } from '@/components/bulk-delete-dialog'
|
||||
import { RouteError } from '@/components/route-error'
|
||||
import { UndoTray } from '@/components/undo-tray'
|
||||
import { useAllGames } from '@/hooks/useGames'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useAuth } from '@/stores/auth'
|
||||
import { useT } from '@/lib/i18n'
|
||||
import { countBy, countByArray } from '@/lib/analytics'
|
||||
import { formatNumber } from '@/lib/utils'
|
||||
import type { Game } from '@/types/game'
|
||||
@@ -40,7 +42,8 @@ function gameSearch(g: Game, q: string): boolean {
|
||||
}
|
||||
|
||||
export default function Games() {
|
||||
useDocumentTitle('Games')
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.games'))
|
||||
const games = useAllGames()
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const [globalFilter, setGlobalFilter] = useState('')
|
||||
@@ -59,23 +62,23 @@ export default function Games() {
|
||||
const toOpts = (entries: { key: string; count: number }[]): FacetOption[] =>
|
||||
entries.map((e) => ({ value: e.key, label: e.key, count: e.count }))
|
||||
return [
|
||||
{ columnId: 'genre', title: 'Genre', options: toOpts(countBy(data, 'genre')) },
|
||||
{ columnId: 'status', title: 'Status', options: toOpts(countBy(data, 'status')) },
|
||||
{ columnId: 'genre', title: t('games.facet.genre'), options: toOpts(countBy(data, 'genre')) },
|
||||
{ columnId: 'status', title: t('games.facet.status'), options: toOpts(countBy(data, 'status')) },
|
||||
{
|
||||
columnId: 'platforms',
|
||||
title: 'Platforms',
|
||||
title: t('games.facet.platforms'),
|
||||
options: toOpts(countByArray(data, 'platforms')),
|
||||
},
|
||||
{
|
||||
columnId: 'nsfw',
|
||||
title: 'NSFW',
|
||||
title: t('games.facet.nsfw'),
|
||||
options: [
|
||||
{ value: 'Yes', label: 'Yes', count: data.filter((g) => g.nsfw === 'Yes').length },
|
||||
{ value: 'No', label: 'No', count: data.filter((g) => g.nsfw === 'No').length },
|
||||
],
|
||||
},
|
||||
]
|
||||
}, [data])
|
||||
}, [data, t])
|
||||
|
||||
const tableForToolbar = useReactTable({
|
||||
data,
|
||||
@@ -106,7 +109,7 @@ export default function Games() {
|
||||
if (games.isLoading) {
|
||||
return (
|
||||
<div className="container mx-auto p-8 space-y-4">
|
||||
<h1 className="text-3xl font-bold tracking-tight">Games</h1>
|
||||
<h1 className="text-3xl font-bold tracking-tight">{t('nav.games')}</h1>
|
||||
<Skeleton className="h-9" />
|
||||
<Skeleton className="h-[60vh]" />
|
||||
</div>
|
||||
@@ -114,21 +117,16 @@ export default function Games() {
|
||||
}
|
||||
|
||||
if (games.isError) {
|
||||
return (
|
||||
<div className="container mx-auto p-8">
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">Games</h1>
|
||||
<p className="text-destructive">Failed to load: {games.error.message}</p>
|
||||
</div>
|
||||
)
|
||||
return <RouteError error={games.error} onRetry={() => void games.refetch()} />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container mx-auto p-6">
|
||||
<div className="mb-4 flex items-baseline justify-between">
|
||||
<h1 className="text-3xl font-bold tracking-tight">Games</h1>
|
||||
<h1 className="text-3xl font-bold tracking-tight">{t('nav.games')}</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{formatNumber(filteredCount)} of {formatNumber(data.length)}
|
||||
{selectedUrls.length > 0 && ` — ${selectedUrls.length} selected`}
|
||||
{t('games.count', { shown: formatNumber(filteredCount), total: formatNumber(data.length) })}
|
||||
{selectedUrls.length > 0 && ` — ${t('games.selected', { count: selectedUrls.length })}`}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -142,29 +140,29 @@ export default function Games() {
|
||||
|
||||
{selectedUrls.length > 0 && (
|
||||
<div className="flex flex-wrap items-center gap-2 rounded-md border bg-accent/40 p-2">
|
||||
<span className="px-1 text-sm font-medium">{selectedUrls.length} selected</span>
|
||||
<span className="px-1 text-sm font-medium">{t('games.selected', { count: selectedUrls.length })}</span>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => setEditOpen(true)}
|
||||
disabled={!pat}
|
||||
title={pat ? 'Bulk edit annotations' : 'Unlock PAT first'}
|
||||
title={pat ? t('games.bulkEditTitle') : t('games.unlockPatFirst')}
|
||||
>
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
Edit
|
||||
{t('common.edit')}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="destructive"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
disabled={!pat}
|
||||
title={pat ? 'Bulk delete' : 'Unlock PAT first'}
|
||||
title={pat ? t('games.bulkDeleteTitle') : t('games.unlockPatFirst')}
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
Delete
|
||||
{t('common.delete')}
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" onClick={() => setRowSelection({})}>
|
||||
Clear selection
|
||||
{t('games.clearSelection')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
@@ -192,8 +190,7 @@ export default function Games() {
|
||||
/>
|
||||
|
||||
<p className="mt-3 text-xs text-muted-foreground">
|
||||
Tip: Shift-click column headers for multi-column sort. Select rows to enable bulk Edit /
|
||||
Delete.
|
||||
{t('games.tip')}
|
||||
</p>
|
||||
|
||||
<BulkEditDialog
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { ErrorPage } from '@/components/error-page'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useT } from '@/lib/i18n'
|
||||
|
||||
export default function NotFound() {
|
||||
useDocumentTitle('404 — Not found')
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center gap-4">
|
||||
<h1 className="text-6xl font-bold">404</h1>
|
||||
<p className="text-muted-foreground">Page not found</p>
|
||||
<Button asChild>
|
||||
<Link to="/">Back to dashboard</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.notFound'))
|
||||
return <ErrorPage status={404} />
|
||||
}
|
||||
+108
-89
@@ -32,16 +32,18 @@ import { checkRepoAccess, fetchAuthenticatedUser } from '@/lib/github/client'
|
||||
import { REPO } from '@/lib/config'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { GpgCard } from '@/components/settings/gpg-card'
|
||||
import { switchLanguage, useT, type MessageKey } from '@/lib/i18n'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const THEME_CHOICES: { value: Theme; label: string; icon: typeof Sun }[] = [
|
||||
{ value: 'light', label: 'Light', icon: Sun },
|
||||
{ value: 'dark', label: 'Dark', icon: Moon },
|
||||
{ value: 'system', label: 'System', icon: Monitor },
|
||||
const THEME_CHOICES: { value: Theme; labelKey: MessageKey; icon: typeof Sun }[] = [
|
||||
{ value: 'light', labelKey: 'settings.theme.light', icon: Sun },
|
||||
{ value: 'dark', labelKey: 'settings.theme.dark', icon: Moon },
|
||||
{ value: 'system', labelKey: 'settings.theme.system', icon: Monitor },
|
||||
]
|
||||
|
||||
export default function Settings() {
|
||||
useDocumentTitle('Settings')
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.settings'))
|
||||
const { pat, user, hasStoredPat, setPat, setUser, lock, refreshStoredFlag } = useAuth()
|
||||
const theme = useThemeStore((s) => s.theme)
|
||||
const setTheme = useThemeStore((s) => s.setTheme)
|
||||
@@ -54,11 +56,11 @@ export default function Settings() {
|
||||
|
||||
async function handleSavePat() {
|
||||
if (!patInput.trim()) {
|
||||
toast.error('Paste a Personal Access Token first.')
|
||||
toast.error(t('settings.toast.pastePat'))
|
||||
return
|
||||
}
|
||||
if (passphrase.length < 8) {
|
||||
toast.error('Passphrase must be at least 8 characters.')
|
||||
toast.error(t('settings.toast.passMin'))
|
||||
return
|
||||
}
|
||||
setBusy(true)
|
||||
@@ -71,9 +73,9 @@ export default function Settings() {
|
||||
refreshStoredFlag()
|
||||
setPatInput('')
|
||||
setPassphrase('')
|
||||
toast.success(`Saved & unlocked as ${userInfo.login}`)
|
||||
toast.success(t('settings.toast.savedUnlockedAs', { login: userInfo.login }))
|
||||
} catch (err) {
|
||||
toast.error(`Could not validate PAT: ${(err as Error).message}`)
|
||||
toast.error(t('settings.toast.patInvalid', { message: (err as Error).message }))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
@@ -82,11 +84,11 @@ export default function Settings() {
|
||||
async function handleUnlock() {
|
||||
const packed = readEncryptedPat()
|
||||
if (!packed) {
|
||||
toast.error('No saved PAT found.')
|
||||
toast.error(t('settings.toast.noSavedPat'))
|
||||
return
|
||||
}
|
||||
if (!unlockPassphrase) {
|
||||
toast.error('Enter your passphrase.')
|
||||
toast.error(t('settings.toast.enterPassphrase'))
|
||||
return
|
||||
}
|
||||
setBusy(true)
|
||||
@@ -96,9 +98,9 @@ export default function Settings() {
|
||||
setPat(decrypted)
|
||||
setUser(userInfo)
|
||||
setUnlockPassphrase('')
|
||||
toast.success(`Unlocked as ${userInfo.login}`)
|
||||
toast.success(t('settings.toast.unlockedAs', { login: userInfo.login }))
|
||||
} catch (err) {
|
||||
toast.error(`Unlock failed: ${(err as Error).message}`)
|
||||
toast.error(t('settings.toast.unlockFailed', { message: (err as Error).message }))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
@@ -107,17 +109,16 @@ export default function Settings() {
|
||||
function handleLock() {
|
||||
lock()
|
||||
setRepoOk(null)
|
||||
toast.info('Locked. Enter your passphrase to unlock again.')
|
||||
toast.info(t('settings.toast.locked'))
|
||||
}
|
||||
|
||||
function handleRemove() {
|
||||
if (!confirm('Remove the encrypted PAT from this browser? You will need to paste it again.'))
|
||||
return
|
||||
if (!confirm(t('settings.confirm.removePat'))) return
|
||||
clearEncryptedPat()
|
||||
lock()
|
||||
refreshStoredFlag()
|
||||
setRepoOk(null)
|
||||
toast.success('Encrypted PAT removed from localStorage.')
|
||||
toast.success(t('settings.toast.patRemoved'))
|
||||
}
|
||||
|
||||
async function handleTestRepo() {
|
||||
@@ -129,8 +130,8 @@ export default function Settings() {
|
||||
setRepoOk(ok)
|
||||
toast[ok ? 'success' : 'error'](
|
||||
ok
|
||||
? `Can access ${REPO.owner}/${REPO.name}`
|
||||
: `No access to ${REPO.owner}/${REPO.name}. Check token scopes.`,
|
||||
? t('settings.toast.repoOk', { repo: `${REPO.owner}/${REPO.name}` })
|
||||
: t('settings.toast.repoFail', { repo: `${REPO.owner}/${REPO.name}` }),
|
||||
)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
@@ -139,36 +140,43 @@ export default function Settings() {
|
||||
|
||||
return (
|
||||
<div className="container mx-auto max-w-2xl p-6">
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">Settings</h1>
|
||||
<h1 className="mb-6 text-3xl font-bold tracking-tight">{t('titles.settings')}</h1>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">GitHub Authentication</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Your PAT is encrypted with AES-GCM (PBKDF2-SHA256, 100k iterations) using your
|
||||
passphrase before being stored in localStorage. The decrypted token only lives in
|
||||
memory while the tab is open.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('settings.auth.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('settings.auth.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-5">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<div className="text-sm">
|
||||
Status:{' '}
|
||||
{t('settings.auth.status')}{' '}
|
||||
{pat ? (
|
||||
<Badge variant="default">
|
||||
<Unlock className="mr-1 h-3 w-3" /> Unlocked
|
||||
<Unlock className="mr-1 h-3 w-3" /> {t('settings.auth.unlocked')}
|
||||
</Badge>
|
||||
) : hasStoredPat ? (
|
||||
<Badge variant="secondary">
|
||||
<Lock className="mr-1 h-3 w-3" /> Saved (locked)
|
||||
<Lock className="mr-1 h-3 w-3" /> {t('settings.auth.savedLocked')}
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="outline">No token saved</Badge>
|
||||
<Badge variant="outline">{t('settings.auth.noToken')}</Badge>
|
||||
)}
|
||||
</div>
|
||||
{user && (
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<img src={user.avatar_url} alt="" className="h-6 w-6 rounded-full" />
|
||||
<img
|
||||
src={user.avatar_url}
|
||||
alt=""
|
||||
width={24}
|
||||
height={24}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
className="h-6 w-6 rounded-full"
|
||||
onError={(e) => {
|
||||
e.currentTarget.style.display = 'none'
|
||||
}}
|
||||
/>
|
||||
<span>{user.login}</span>
|
||||
</div>
|
||||
)}
|
||||
@@ -180,47 +188,47 @@ export default function Settings() {
|
||||
<div className="space-y-3">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button onClick={handleTestRepo} disabled={busy} variant="outline" size="sm">
|
||||
Test repo access
|
||||
{t('settings.auth.testRepo')}
|
||||
{repoOk === true && <Check className="h-4 w-4 text-green-600" />}
|
||||
{repoOk === false && <X className="h-4 w-4 text-destructive" />}
|
||||
</Button>
|
||||
<Button onClick={handleLock} variant="outline" size="sm">
|
||||
<Lock className="h-4 w-4" />
|
||||
Lock
|
||||
{t('settings.auth.lock')}
|
||||
</Button>
|
||||
<Button onClick={handleRemove} variant="destructive" size="sm">
|
||||
<Trash2 className="h-4 w-4" />
|
||||
Remove saved PAT
|
||||
{t('settings.auth.removeSaved')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : hasStoredPat ? (
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="unlock-pass">Passphrase</Label>
|
||||
<Label htmlFor="unlock-pass">{t('settings.auth.passphrase')}</Label>
|
||||
<Input
|
||||
id="unlock-pass"
|
||||
type="password"
|
||||
value={unlockPassphrase}
|
||||
onChange={(e) => setUnlockPassphrase(e.target.value)}
|
||||
placeholder="Your passphrase"
|
||||
placeholder={t('settings.auth.passphrasePlaceholder')}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleUnlock()}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button onClick={handleUnlock} disabled={busy}>
|
||||
<Unlock className="h-4 w-4" />
|
||||
Unlock
|
||||
{t('settings.auth.unlock')}
|
||||
</Button>
|
||||
<Button onClick={handleRemove} variant="ghost" size="sm">
|
||||
Forget saved PAT
|
||||
{t('settings.auth.forgetSaved')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="pat">Personal Access Token</Label>
|
||||
<Label htmlFor="pat">{t('settings.auth.patLabel')}</Label>
|
||||
<Input
|
||||
id="pat"
|
||||
type="password"
|
||||
@@ -230,40 +238,41 @@ export default function Settings() {
|
||||
/>
|
||||
<div className="space-y-1 text-xs text-muted-foreground">
|
||||
<p>
|
||||
Fine-grained token scoped to only{' '}
|
||||
{t('settings.auth.patScopePrefix')}{' '}
|
||||
<span className="font-mono">
|
||||
{REPO.owner}/{REPO.name}
|
||||
</span>
|
||||
, with these repository permissions:
|
||||
{t('settings.auth.patScopeSuffix')}
|
||||
</p>
|
||||
<ul className="ml-4 list-disc space-y-0.5">
|
||||
<li>
|
||||
<span className="font-mono">Contents</span>: Read and write — required for
|
||||
edits, deletes, and queueing URLs.
|
||||
<span className="font-mono">Contents</span>: Read and write —{' '}
|
||||
{t('settings.auth.permContents')}
|
||||
</li>
|
||||
<li>
|
||||
<span className="font-mono">Actions</span>: Read and write — required to
|
||||
dispatch the scraper workflow from Add / Workflows.
|
||||
<span className="font-mono">Actions</span>: Read and write —{' '}
|
||||
{t('settings.auth.permActions')}
|
||||
</li>
|
||||
</ul>
|
||||
<p className="pt-1">
|
||||
Classic tokens with the <span className="font-mono">workflow</span> scope also
|
||||
work but grant access to every repo you can write to.
|
||||
{t('settings.auth.classicPrefix')}{' '}
|
||||
<span className="font-mono">workflow</span>{' '}
|
||||
{t('settings.auth.classicSuffix')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="pass">Passphrase</Label>
|
||||
<Label htmlFor="pass">{t('settings.auth.passphrase')}</Label>
|
||||
<Input
|
||||
id="pass"
|
||||
type="password"
|
||||
value={passphrase}
|
||||
onChange={(e) => setPassphrase(e.target.value)}
|
||||
placeholder="Min 8 chars; required to unlock later"
|
||||
placeholder={t('settings.auth.passPlaceholder')}
|
||||
/>
|
||||
</div>
|
||||
<Button onClick={handleSavePat} disabled={busy}>
|
||||
Save & unlock
|
||||
{t('settings.auth.saveUnlock')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
@@ -272,16 +281,30 @@ export default function Settings() {
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Appearance</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Theme and layout density. Choices persist to localStorage.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('settings.appearance.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('settings.appearance.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-5">
|
||||
<div className="space-y-2">
|
||||
<Label>Theme</Label>
|
||||
<Label htmlFor="language">{t('common.language')}</Label>
|
||||
<Select
|
||||
value={prefs.language}
|
||||
onValueChange={(v) => void switchLanguage(v as 'en' | 'vi')}
|
||||
>
|
||||
<SelectTrigger id="language" className="w-[200px]">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="en">English</SelectItem>
|
||||
<SelectItem value="vi">Tiếng Việt</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label>{t('settings.appearance.theme')}</Label>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{THEME_CHOICES.map(({ value, label, icon: Icon }) => (
|
||||
{THEME_CHOICES.map(({ value, labelKey, icon: Icon }) => (
|
||||
<Button
|
||||
key={value}
|
||||
variant={theme === value ? 'default' : 'outline'}
|
||||
@@ -290,14 +313,14 @@ export default function Settings() {
|
||||
className={cn('min-w-[88px]')}
|
||||
>
|
||||
<Icon className="h-4 w-4" />
|
||||
{label}
|
||||
{t(labelKey)}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="density">Density</Label>
|
||||
<Label htmlFor="density">{t('settings.appearance.density')}</Label>
|
||||
<Select
|
||||
value={prefs.density}
|
||||
onValueChange={(v) => prefs.setDensity(v as 'normal' | 'compact')}
|
||||
@@ -306,17 +329,17 @@ export default function Settings() {
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="normal">Normal</SelectItem>
|
||||
<SelectItem value="compact">Compact (smaller rows)</SelectItem>
|
||||
<SelectItem value="normal">{t('settings.density.normal')}</SelectItem>
|
||||
<SelectItem value="compact">{t('settings.density.compact')}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="sidebar-collapsed">Collapse sidebar</Label>
|
||||
<Label htmlFor="sidebar-collapsed">{t('settings.appearance.collapseSidebar')}</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Mirror of the toggle in the sidebar footer.
|
||||
{t('settings.appearance.collapseSidebarDesc')}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
@@ -330,14 +353,12 @@ export default function Settings() {
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Session</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
How long the decrypted PAT stays in memory after unlock.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('settings.session.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('settings.session.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="idle">Idle timeout</Label>
|
||||
<Label htmlFor="idle">{t('settings.session.idleTimeout')}</Label>
|
||||
<Select
|
||||
value={String(prefs.idleTimeoutMs / 60_000)}
|
||||
onValueChange={(v) => prefs.setIdleTimeoutMs(Number(v) * 60_000)}
|
||||
@@ -348,39 +369,41 @@ export default function Settings() {
|
||||
<SelectContent>
|
||||
{IDLE_TIMEOUT_OPTIONS.map((m) => (
|
||||
<SelectItem key={m} value={String(m)}>
|
||||
{m < 60 ? `${m} minutes` : `${m / 60} hour${m === 60 ? '' : 's'}`}
|
||||
{m < 60
|
||||
? t('settings.session.minutes', { m })
|
||||
: m === 60
|
||||
? t('settings.session.hour')
|
||||
: t('settings.session.hours', { h: m / 60 })}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
The PAT auto-locks on idle. Re-enter your passphrase to unlock again.
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">{t('settings.session.idleNote')}</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Commit author</CardTitle>
|
||||
<CardTitle className="text-base">{t('settings.author.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Optional override for the <span className="font-mono">author</span> and{' '}
|
||||
<span className="font-mono">committer</span> blocks of commits made from this app.
|
||||
Leave blank to use the GitHub user from your PAT.
|
||||
{t('settings.author.descPrefix')} <span className="font-mono">author</span>{' '}
|
||||
{t('settings.author.descAnd')} <span className="font-mono">committer</span>{' '}
|
||||
{t('settings.author.descSuffix')}
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="author-name">Name</Label>
|
||||
<Label htmlFor="author-name">{t('settings.author.name')}</Label>
|
||||
<Input
|
||||
id="author-name"
|
||||
value={prefs.authorName}
|
||||
onChange={(e) => prefs.setAuthorName(e.target.value)}
|
||||
placeholder={user?.name ?? user?.login ?? 'e.g. Your Name'}
|
||||
placeholder={user?.name ?? user?.login ?? t('settings.author.namePlaceholder')}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="author-email">Email</Label>
|
||||
<Label htmlFor="author-email">{t('settings.author.email')}</Label>
|
||||
<Input
|
||||
id="author-email"
|
||||
type="email"
|
||||
@@ -389,8 +412,8 @@ export default function Settings() {
|
||||
placeholder={user ? `${user.login}@users.noreply.github.com` : 'you@example.com'}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
For GPG-signed commits to show as <b>Verified</b>, this email must match one of the
|
||||
UIDs in your GPG key.
|
||||
{t('settings.author.verifiedPrefix')} <b>Verified</b>
|
||||
{t('settings.author.verifiedSuffix')}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
@@ -400,18 +423,14 @@ export default function Settings() {
|
||||
|
||||
<Card className="mt-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Notifications</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Toast notifications shown at the top-right corner.
|
||||
</p>
|
||||
<CardTitle className="text-base">{t('settings.notif.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('settings.notif.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="notif-enabled">Enable toasts</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Disables success / error / info popups globally.
|
||||
</p>
|
||||
<Label htmlFor="notif-enabled">{t('settings.notif.enable')}</Label>
|
||||
<p className="text-xs text-muted-foreground">{t('settings.notif.enableDesc')}</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="notif-enabled"
|
||||
@@ -420,7 +439,7 @@ export default function Settings() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="notif-duration">Duration</Label>
|
||||
<Label htmlFor="notif-duration">{t('settings.notif.duration')}</Label>
|
||||
<Select
|
||||
value={String(prefs.notificationDurationMs)}
|
||||
onValueChange={(v) => prefs.setNotificationDurationMs(Number(v))}
|
||||
|
||||
@@ -18,6 +18,7 @@ import { createOctokit } from '@/lib/github/client'
|
||||
import { dispatchWorkflow, type WorkflowFile, type WorkflowRunSummary } from '@/lib/github/workflow'
|
||||
import { useWorkflowRuns, WORKFLOWS } from '@/hooks/useWorkflows'
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||
import { useT, type MessageKey } from '@/lib/i18n'
|
||||
|
||||
function StatusBadge({ run }: { run: WorkflowRunSummary }) {
|
||||
if (run.status !== 'completed') {
|
||||
@@ -28,20 +29,21 @@ function StatusBadge({ run }: { run: WorkflowRunSummary }) {
|
||||
return <Badge variant="outline">{run.conclusion ?? '—'}</Badge>
|
||||
}
|
||||
|
||||
function WorkflowPanel({ file, label, description }: { file: WorkflowFile; label: string; description: string }) {
|
||||
function WorkflowPanel({ file, labelKey, descriptionKey }: { file: WorkflowFile; labelKey: MessageKey; descriptionKey: MessageKey }) {
|
||||
const t = useT()
|
||||
const pat = useAuth((s) => s.pat)
|
||||
const runs = useWorkflowRuns(file)
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
async function handleDispatch() {
|
||||
if (!pat) return toast.error('Unlock your PAT in Settings.')
|
||||
if (!pat) return toast.error(t('workflows.toast.unlockPat'))
|
||||
setBusy(true)
|
||||
try {
|
||||
await dispatchWorkflow(createOctokit(), file)
|
||||
toast.success(`Dispatched ${file}.`)
|
||||
toast.success(t('workflows.toast.dispatched', { file }))
|
||||
setTimeout(() => runs.refetch(), 3_000)
|
||||
} catch (e) {
|
||||
toast.error(`Dispatch failed: ${(e as Error).message}`)
|
||||
toast.error(t('workflows.toast.dispatchFailed', { message: (e as Error).message }))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
@@ -52,8 +54,8 @@ function WorkflowPanel({ file, label, description }: { file: WorkflowFile; label
|
||||
<CardHeader>
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<div>
|
||||
<CardTitle className="text-base">{label}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{description}</p>
|
||||
<CardTitle className="text-base">{t(labelKey)}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t(descriptionKey)}</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
@@ -63,24 +65,24 @@ function WorkflowPanel({ file, label, description }: { file: WorkflowFile; label
|
||||
disabled={runs.isFetching}
|
||||
>
|
||||
<RefreshCw className={`h-4 w-4 ${runs.isFetching ? 'animate-spin' : ''}`} />
|
||||
Refresh
|
||||
{t('workflows.refresh')}
|
||||
</Button>
|
||||
<Button size="sm" onClick={handleDispatch} disabled={busy || !pat}>
|
||||
<Play className="h-4 w-4" />
|
||||
Dispatch
|
||||
{t('workflows.dispatch')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{!pat ? (
|
||||
<p className="text-sm text-muted-foreground">Unlock your PAT to view runs.</p>
|
||||
<p className="text-sm text-muted-foreground">{t('workflows.unlockPatToView')}</p>
|
||||
) : runs.isLoading ? (
|
||||
<Skeleton className="h-32" />
|
||||
) : runs.isError ? (
|
||||
<p className="text-sm text-destructive">{runs.error.message}</p>
|
||||
) : (runs.data?.length ?? 0) === 0 ? (
|
||||
<p className="text-sm text-muted-foreground">No runs yet.</p>
|
||||
<p className="text-sm text-muted-foreground">{t('workflows.noRuns')}</p>
|
||||
) : (
|
||||
<ul className="space-y-1.5 text-sm">
|
||||
{runs.data!.slice(0, 10).map((r) => (
|
||||
@@ -104,7 +106,7 @@ function WorkflowPanel({ file, label, description }: { file: WorkflowFile; label
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-1 text-primary hover:underline"
|
||||
>
|
||||
Open
|
||||
{t('workflows.openRun')}
|
||||
<ExternalLink className="h-3 w-3" />
|
||||
</a>
|
||||
</div>
|
||||
@@ -118,11 +120,12 @@ function WorkflowPanel({ file, label, description }: { file: WorkflowFile; label
|
||||
}
|
||||
|
||||
export default function Workflows() {
|
||||
useDocumentTitle('Workflows')
|
||||
const t = useT()
|
||||
useDocumentTitle(t('titles.workflows'))
|
||||
const [current, setCurrent] = useState<string>(WORKFLOWS[0].file)
|
||||
return (
|
||||
<div className="container mx-auto p-6">
|
||||
<h1 className="mb-4 text-3xl font-bold tracking-tight">Workflows</h1>
|
||||
<h1 className="mb-4 text-3xl font-bold tracking-tight">{t('titles.workflows')}</h1>
|
||||
<div className="mb-3 md:hidden">
|
||||
<Select value={current} onValueChange={setCurrent}>
|
||||
<SelectTrigger className="h-10 w-full">
|
||||
@@ -131,7 +134,7 @@ export default function Workflows() {
|
||||
<SelectContent>
|
||||
{WORKFLOWS.map((w) => (
|
||||
<SelectItem key={w.file} value={w.file}>
|
||||
{w.label}
|
||||
{t(w.labelKey)}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
@@ -141,13 +144,13 @@ export default function Workflows() {
|
||||
<TabsList className="hidden flex-wrap md:inline-flex">
|
||||
{WORKFLOWS.map((w) => (
|
||||
<TabsTrigger key={w.file} value={w.file}>
|
||||
{w.label}
|
||||
{t(w.labelKey)}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
{WORKFLOWS.map((w) => (
|
||||
<TabsContent key={w.file} value={w.file}>
|
||||
<WorkflowPanel file={w.file} label={w.label} description={w.description} />
|
||||
<WorkflowPanel file={w.file} labelKey={w.labelKey} descriptionKey={w.descriptionKey} />
|
||||
</TabsContent>
|
||||
))}
|
||||
</Tabs>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { create } from 'zustand'
|
||||
import { persist } from 'zustand/middleware'
|
||||
|
||||
type Density = 'compact' | 'normal'
|
||||
type Language = 'en' | 'vi'
|
||||
|
||||
export const IDLE_TIMEOUT_OPTIONS = [5, 15, 30, 60, 120] as const
|
||||
|
||||
@@ -10,6 +11,7 @@ export const NOTIFICATION_DURATION_OPTIONS = [2_000, 4_000, 6_000, 10_000] as co
|
||||
interface PrefsStore {
|
||||
sidebarCollapsed: boolean
|
||||
density: Density
|
||||
language: Language
|
||||
notificationsEnabled: boolean
|
||||
notificationDurationMs: number
|
||||
idleTimeoutMs: number
|
||||
@@ -18,6 +20,7 @@ interface PrefsStore {
|
||||
toggleSidebar: () => void
|
||||
setSidebarCollapsed: (v: boolean) => void
|
||||
setDensity: (d: Density) => void
|
||||
setLanguage: (l: Language) => void
|
||||
setNotificationsEnabled: (v: boolean) => void
|
||||
setNotificationDurationMs: (v: number) => void
|
||||
setIdleTimeoutMs: (v: number) => void
|
||||
@@ -32,6 +35,7 @@ export const usePrefs = create<PrefsStore>()(
|
||||
(set) => ({
|
||||
sidebarCollapsed: false,
|
||||
density: 'normal',
|
||||
language: 'en',
|
||||
notificationsEnabled: true,
|
||||
notificationDurationMs: 4_000,
|
||||
idleTimeoutMs: DEFAULT_IDLE_MS,
|
||||
@@ -40,6 +44,7 @@ export const usePrefs = create<PrefsStore>()(
|
||||
toggleSidebar: () => set((s) => ({ sidebarCollapsed: !s.sidebarCollapsed })),
|
||||
setSidebarCollapsed: (v) => set({ sidebarCollapsed: v }),
|
||||
setDensity: (d) => set({ density: d }),
|
||||
setLanguage: (l) => set({ language: l }),
|
||||
setNotificationsEnabled: (v) => set({ notificationsEnabled: v }),
|
||||
setNotificationDurationMs: (v) => set({ notificationDurationMs: v }),
|
||||
setIdleTimeoutMs: (v) => set({ idleTimeoutMs: v }),
|
||||
|
||||
Reference in new issue
Block a user