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) => (