mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 15:33:12 +09:00
Add viewable changelog
This commit is contained in:
6 files changed
+81
-6
No files matched your search
@@ -0,0 +1,63 @@
|
||||
import React, { useState, ReactNode } from "react";
|
||||
import { Modal, Tooltip } from "antd";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
|
||||
import webUiPackage from "../../package.json";
|
||||
import changelog from "../../../../CHANGELOG.md";
|
||||
|
||||
const cleanedChangelog = changelog
|
||||
.replace(/<!--[\s\S]*?-->/g, "") // remove comments
|
||||
.replace(/^#\s+Changelog\s*\n?/i, ""); // remove top-level title
|
||||
|
||||
type Props = {
|
||||
/** Optional tooltip text */
|
||||
tooltip?: string;
|
||||
/** Optional class for the clickable wrapper */
|
||||
className?: string;
|
||||
/** Custom clickable content */
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
/**
|
||||
* Displays a clickable element which opens a modal containing the changelog.
|
||||
* Defaults to showing the current version if no children are provided.
|
||||
*/
|
||||
export default function ChangeLogModal({
|
||||
tooltip = "View changelog",
|
||||
className = "site-version",
|
||||
children = webUiPackage.version,
|
||||
}: Props) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip
|
||||
title={tooltip}
|
||||
placement="bottom"
|
||||
align={{ offset: [0, -10] }}
|
||||
>
|
||||
<span
|
||||
className={className}
|
||||
style={{ cursor: "pointer" }}
|
||||
onClick={() => setOpen(true)}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
</Tooltip>
|
||||
|
||||
<Modal
|
||||
title="Changelog"
|
||||
open={open}
|
||||
onCancel={() => setOpen(false)}
|
||||
footer={null}
|
||||
width={800}
|
||||
>
|
||||
<div style={{ maxHeight: "70vh", overflow: "auto" }}>
|
||||
<ReactMarkdown>
|
||||
{cleanedChangelog}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
import React, { Fragment, useContext, useEffect, useState } from "react";
|
||||
import { Route, Routes, useNavigate } from "react-router-dom";
|
||||
import { Button, Dropdown, Layout, Menu, MenuProps, Tooltip } from "antd";
|
||||
import UserOutlined from "@ant-design/icons/UserOutlined";
|
||||
import webUiPackage from "../../package.json";
|
||||
import { UserOutlined, DownloadOutlined } from "@ant-design/icons";
|
||||
|
||||
import { useAccount } from "../model/account";
|
||||
import ErrorBoundary from "./ErrorBoundary";
|
||||
import ErrorPage from "./ErrorPage";
|
||||
import ControlContext from "./ControlContext";
|
||||
import ChangeLogModal from "./ChangeLogModal";
|
||||
|
||||
import { pages } from "../pages";
|
||||
import { DraggingContext } from "../model/is_dragging";
|
||||
import { saveJson } from "../util/save_file";
|
||||
import { useAccount } from "../model/account";
|
||||
import { DraggingContext } from "../model/is_dragging";
|
||||
|
||||
import { ControlConfig } from "@clusterio/lib";
|
||||
import { DownloadOutlined } from "@ant-design/icons";
|
||||
|
||||
type MenuItem = Required<MenuProps>["items"][number];
|
||||
|
||||
@@ -145,7 +146,7 @@ export default function SiteLayout() {
|
||||
<Header className="header">
|
||||
<div className="site-logo" />
|
||||
<span className="site-name">Clusterio</span>
|
||||
<span className="site-version">{webUiPackage.version}</span>
|
||||
<ChangeLogModal />
|
||||
<Menu
|
||||
theme="dark"
|
||||
mode="horizontal"
|
||||
|
||||
Reference in new issue
Block a user