2020-11-03 03:40:12 +01:00
|
|
|
import React, { useState, useEffect } from "react";
|
|
|
|
import ReactMarkdown from "react-markdown";
|
2020-11-06 03:30:14 +01:00
|
|
|
import { Table, Typography } from "antd";
|
2020-11-04 03:15:38 +01:00
|
|
|
import { getGithubRelease } from "../utils/apis";
|
2020-11-03 03:40:12 +01:00
|
|
|
|
2020-11-06 03:30:14 +01:00
|
|
|
const { Title } = Typography;
|
|
|
|
|
2020-11-03 03:40:12 +01:00
|
|
|
export default function Logs() {
|
|
|
|
const [release, setRelease] = useState({
|
|
|
|
html_url: "",
|
|
|
|
name: "",
|
|
|
|
created_at: null,
|
|
|
|
body: "",
|
|
|
|
assets: [],
|
2020-11-03 06:38:56 +01:00
|
|
|
|
2020-11-03 03:40:12 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const getRelease = async () => {
|
|
|
|
try {
|
2020-11-04 03:15:38 +01:00
|
|
|
const result = await getGithubRelease();
|
2020-11-03 03:40:12 +01:00
|
|
|
setRelease(result);
|
|
|
|
} catch (error) {
|
|
|
|
console.log("==== error", error);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
getRelease();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
if (!release) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2020-11-06 03:30:14 +01:00
|
|
|
<Title level={2}>
|
2020-11-03 03:40:12 +01:00
|
|
|
<a href={release.html_url}>{release.name}</a>
|
2020-11-06 03:30:14 +01:00
|
|
|
</Title>
|
|
|
|
<Title level={5}>{new Date(release.created_at).toDateString()}</Title>
|
|
|
|
<ReactMarkdown>{release.body}</ReactMarkdown>;<h3>Downloads</h3>
|
2020-11-03 03:40:12 +01:00
|
|
|
<AssetTable {...release.assets} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function AssetTable(assets) {
|
|
|
|
const data = [];
|
|
|
|
|
|
|
|
for (const key in assets) {
|
|
|
|
data.push(assets[key]);
|
|
|
|
}
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
title: "Name",
|
|
|
|
dataIndex: "name",
|
|
|
|
key: "name",
|
|
|
|
render: (text, entry) =>
|
2020-11-03 06:38:56 +01:00
|
|
|
<a href={entry.browser_download_url}>{text}</a>,
|
2020-11-03 03:40:12 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Size",
|
|
|
|
dataIndex: "size",
|
|
|
|
key: "size",
|
|
|
|
render: (text, entry) =>
|
|
|
|
`${(text/1024/1024).toFixed(2)} MB`
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2020-11-03 06:38:56 +01:00
|
|
|
return <Table dataSource={data} columns={columns} rowKey="id" size="large" />;
|
2020-11-03 03:40:12 +01:00
|
|
|
}
|
|
|
|
|