From b1d3b955bdaf18a64773eb29e55e5d35f51e9ee5 Mon Sep 17 00:00:00 2001 From: Matartos Date: Sun, 29 Nov 2026 16:27:29 +0100 Subject: [PATCH] Add per-project changes and version comparison tab --- src/features/library/changes-tab.tsx | 41 +++++++++++++++++++++++++++ src/features/library/project-tabs.tsx | 8 ++++-- src/i18n/messages/en/library.ts | 12 ++++++++ src/i18n/messages/es/library.ts | 12 ++++++++ src/i18n/messages/fr/library.ts | 12 ++++++++ src/i18n/messages/ru/library.ts | 12 ++++++++ src/i18n/messages/zh-CN/library.ts | 12 ++++++++ src/i18n/messages/zh-TW/library.ts | 12 ++++++++ src/lib/store.ts | 2 +- src/lib/version-links.test.ts | 21 ++++++++++++++ src/lib/version-links.ts | 25 ++++++++++++++++ 11 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 src/features/library/changes-tab.tsx create mode 100644 src/lib/version-links.test.ts create mode 100644 src/lib/version-links.ts diff --git a/src/features/library/changes-tab.tsx b/src/features/library/changes-tab.tsx new file mode 100644 index 0000000..c8c8483 --- /dev/null +++ b/src/features/library/changes-tab.tsx @@ -0,0 +1,41 @@ +import { useState } from "react" +import { toast } from "sonner" +import { Button } from "@/components/ui/button" +import { Dialog } from "@/components/ui/dialog" +import { useT } from "@/i18n" +import { openUrl } from "@/lib/api" +import { run, useStore } from "@/lib/store" +import type { Project } from "@/lib/types" +import { githubVersionLinks } from "@/lib/version-links" + +export function ChangesTab({ project: p }: { project: Project }) { + const t = useT() + const busy = useStore((s) => !!s.snap?.job.running || (s.snap?.active_builds ?? 0) > 0) + const [confirm, setConfirm] = useState(false) + const links = p.kind === "git" && !p.listing.nuked ? githubVersionLinks(p.web_url, p.built, p.update) : null + const value = (sha: string | null) => sha || t("library.details.versionUnknown") + const browse = (url: string) => void openUrl(url).catch((error) => toast.error(String(error))) + return ( +
+

{t("library.tabs.changes")}

+
+
{t("library.changes.installed")}
{value(p.built)}
+
{t("library.changes.available")}
{p.update ? value(p.update) : t("library.changes.noUpdate")}
+
{t("library.changes.previous")}
{p.previous_build === null ? "—" : value(p.previous_build)}
+
+
+ {p.kind === "git" && !p.listing.nuked && } + {links?.compare && } + {links && } + {p.kind === "git" && p.previous_build !== null && } +
+

{t("library.changes.hint")}

+ + + + + } /> +
+ ) +} diff --git a/src/features/library/project-tabs.tsx b/src/features/library/project-tabs.tsx index c2be792..726d724 100644 --- a/src/features/library/project-tabs.tsx +++ b/src/features/library/project-tabs.tsx @@ -6,6 +6,7 @@ import type { Project } from "@/lib/types" import { cn } from "@/lib/utils" import { ActivityTab } from "./activity-tab" import { GraphicsTab } from "./graphics-tab" +import { ChangesTab } from "./changes-tab" import { LaunchTab } from "./launch-tab" import { NotesTab } from "./notes-tab" import { OverviewTab } from "./overview-tab" @@ -15,6 +16,7 @@ const TABS = [ { id: "overview", labelKey: "library.tabs.overview" }, { id: "graphics", labelKey: "library.tabs.graphics" }, { id: "launch", labelKey: "library.tabs.launch" }, + { id: "changes", labelKey: "library.tabs.changes" }, { id: "notes", labelKey: "library.tabs.notes" }, { id: "activity", labelKey: "library.tabs.activity" }, ] as const satisfies readonly { id: ProjectTab; labelKey: Key }[] @@ -29,7 +31,7 @@ export function ProjectTabs({ project }: { project: Project }) { const running = useStore((s) => s.snap?.job.running || (s.snap?.active_builds ?? 0) > 0) const screenshot = useStore((s) => s.screenshot) const listRef = useRef(null) - const hidden = screenshot && (tab === "launch" || tab === "notes" || tab === "activity") + const hidden = screenshot && (tab === "launch" || tab === "notes" || tab === "activity" || tab === "changes") // Arrow keys move between tabs and open them (the WAI-ARIA tabs pattern, automatic activation). const onKey = (e: React.KeyboardEvent) => { const i = TABS.findIndex((x) => x.id === tab) @@ -42,7 +44,7 @@ export function ProjectTabs({ project }: { project: Project }) { } return (
-
+
{TABS.map((x) => (