From 845038babe678ed36e31d4a72233fe316bf19935 Mon Sep 17 00:00:00 2001 From: Timur Demin Date: Sun, 5 Jan 2020 16:37:39 +0500 Subject: [PATCH] Add an about page (fixes #5) --- src/main.tsx | 18 ++++++---- src/typings/bulma.ts | 6 ++++ src/views/aboutView.tsx | 60 +++++++++++++++++++++++++++++++++ src/views/assets/locales.ts | 9 ++++- src/views/components/footer.tsx | 30 ++++++----------- 5 files changed, 95 insertions(+), 28 deletions(-) create mode 100644 src/views/aboutView.tsx diff --git a/src/main.tsx b/src/main.tsx index 59267eb..b66b123 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -12,6 +12,7 @@ import LoginForm from "./views/loginForm"; import SignupForm from "./views/signupForm"; import MainView from "./views/mainView"; import EditorView from "./views/editorView"; +import AboutView from "./views/aboutView"; import { setToken, resetToken, localLogout } from "./actions/auth"; @@ -56,27 +57,30 @@ class App extends React.Component { } }; componentDidMount = () => { - req.head("/session").then((res) => { - if (res.status !== HTTPSuccessCode) { - this.props.logout(); - } - }); + if (this.props.token) { + req.head("/session").then((res) => { + if (res.status !== HTTPSuccessCode) { + this.props.logout(); + } + }); + } }; render = () => { - const token = this.state.token as string; - const loggedIn = token.length !== 0; + const loggedIn = (this.state.token as string).length !== 0; return ( {!loggedIn && ( + )} {loggedIn && ( + )} diff --git a/src/typings/bulma.ts b/src/typings/bulma.ts index 3d2dd47..2924059 100644 --- a/src/typings/bulma.ts +++ b/src/typings/bulma.ts @@ -31,3 +31,9 @@ export interface BulmaFieldProps { /** `
` */ control?: React.ReactNode; } + +/** List of properties used by the `
` component in Bulma. */ +export interface BulmaSectionProps { + isMedium?: boolean; + isLarge?: boolean; +} diff --git a/src/views/aboutView.tsx b/src/views/aboutView.tsx new file mode 100644 index 0000000..59460cc --- /dev/null +++ b/src/views/aboutView.tsx @@ -0,0 +1,60 @@ +import React from "react"; +import { RouteComponentProps } from "react-router-dom"; + +import Container from "./components/bulma/container"; +import Level from "./components/bulma/level"; +import Button from "./components/bulma/button"; + +import { getServerVersion } from "../actions/misc"; +import strings from "./assets/locales"; +import { appHomePage, amberHomePage } from "../const"; + +interface State { + serverVersion: string; +} + +class AboutView extends React.Component { + state = { + serverVersion: "unknown", + }; + componentDidMount = async () => { + let versionData = await getServerVersion(); + this.setState({ serverVersion: versionData.version }); + }; + render = () => ( + + + +