diff --git a/.vscode/settings.json b/.vscode/settings.json index 2b9b96b..bea3982 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -63,7 +63,8 @@ "uncategorised", "unmount", "unregistering", - "unsyncable" + "unsyncable", + "whatsnew" ], "i18next.defaultTranslatedLocale": "en", "i18next.i18nPaths": "public/locales", diff --git a/public/locales/en.json b/public/locales/en.json index 50a7708..9092d82 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -807,5 +807,18 @@ "message": "You do not own this address.", "messageLocked": "This address was locked.", "alert": "Message from the sync node:" + }, + + "whatsNew": { + "title": "What's new", + "siteTitle": "What's new", + + "titleKrist": "Krist", + "titleKristWeb": "KristWeb", + + "tooltipGitHub": "View on GitHub", + + "cardWhatsNewTitle": "What's New", + "cardCommitsTitle": "Commits" } } diff --git a/src/global/AppRouter.tsx b/src/global/AppRouter.tsx index bce97db..8491340 100644 --- a/src/global/AppRouter.tsx +++ b/src/global/AppRouter.tsx @@ -19,6 +19,7 @@ import { SettingsPage } from "@pages/settings/SettingsPage"; import { SettingsTranslations } from "@pages/settings/translations/SettingsTranslations"; +import { WhatsNewPage } from "@pages/whatsnew/WhatsNewPage"; import { CreditsPage } from "@pages/credits/CreditsPage"; import { DevPage } from "@pages/dev/DevPage"; @@ -79,6 +80,7 @@ { path: "/settings/debug", name: "settingsDebug" }, { path: "/settings/debug/translations", name: "settings", component: }, + { path: "/whatsnew", name: "whatsNew", component: }, { path: "/credits", name: "credits", component: }, // TODO: remove this diff --git a/src/pages/whatsnew/WhatsNewPage.tsx b/src/pages/whatsnew/WhatsNewPage.tsx new file mode 100644 index 0000000..60ab7d2 --- /dev/null +++ b/src/pages/whatsnew/WhatsNewPage.tsx @@ -0,0 +1,52 @@ +// Copyright (c) 2020-2021 Drew Lemmy +// This file is part of KristWeb 2 under GPL-3.0. +// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt +import { useState, useEffect } from "react"; +import { Row, Col, Card, Typography } from "antd"; + +import { useTranslation } from "react-i18next"; + +import * as api from "@api"; +import { WhatsNewResponse } from "./types"; + +import { PageLayout } from "@layout/PageLayout"; + +const { Title } = Typography; + +export function WhatsNewPage(): JSX.Element { + const { t } = useTranslation(); + + const syncNode = api.useSyncNode(); + + const [kristData, setKristData] = useState(); + const [loading, setLoading] = useState(true); + + useEffect(() => { + // Fetch the 'whats new' and commits from the Krist sync node + api.get("/whatsnew") + .then(setKristData) + .catch(console.error) // TODO: show errors to the user + .finally(() => setLoading(false)); + }, [syncNode]); + + return + {/* KristWeb row */} + {t("whatsNew.titleKristWeb")} + + + + + + {/* Krist row */} + {t("whatsNew.titleKrist")} + + + + + ; +} diff --git a/src/pages/whatsnew/types.ts b/src/pages/whatsnew/types.ts new file mode 100644 index 0000000..223c03b --- /dev/null +++ b/src/pages/whatsnew/types.ts @@ -0,0 +1,28 @@ +// Copyright (c) 2020-2021 Drew Lemmy +// This file is part of KristWeb 2 under GPL-3.0. +// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt +export interface WhatsNewItem { + commitHash?: string; + date: string; + authorUsername?: string; + authorName?: string; + body: string; + new?: boolean; +} + +export interface Commit { + type?: "feat" | "fix" | string; + subject?: string; + body: string; + hash: string; + authorName?: string; + authorEmail?: string; + authorDate: string; + authorDateRel: string; + avatar?: string; +} + +export interface WhatsNewResponse { + whatsNew: WhatsNewItem[]; + commits: Commit[]; +}