Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: add upgrad and maintenance page

shuaia741bd5cfc40
diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json
index 0bf94f19..ecbb7b7c 100644
--- a/ui/src/i18n/locales/en.json
+++ b/ui/src/i18n/locales/en.json
@@ -28,7 +28,10 @@
"confirm_email": "Confirm Email",
"account_suspended": "Account Suspended",
"admin": "Admin",
- "change_email": "Modify Email"
+ "change_email": "Modify Email",
+ "install": "Answer Installation",
+ "upgrade": "Answer Upgrade",
+ "maintenance": "Webite Maintenance"
},
"notifications": {
"title": "Notifications",
@@ -790,7 +793,20 @@
},
"ready_title": "Your Answer is Ready!",
"ready_description": "If you ever feel like changing more settings, visit <1>admin section</1>; find it in the site menu.",
- "good_luck": "Have fun, and good luck!"
+ "good_luck": "Have fun, and good luck!",
+ "warning": "Warning",
+ "warning_description": "The file <1>config.yaml</1> already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <2>installing now</2>.",
+ "installed": "Already installed",
+ "installed_description": "You appear to have already installed. To reinstall please clear your old database tables first."
+ },
+ "upgrade": {
+ "title": "Answer",
+ "update_btn": "Update data",
+ "update_title": "Data update required",
+ "update_description": "<1>Answer has been updated! Before you continue, we have to update your data to the newest version.</1><1>The update process may take a little while, so please be patient.</1>",
+ "done_title": "No update required",
+ "done_btn": "Done",
+ "done_desscription": "Your Answer data is already up-to-date."
},
"page_404": {
"description": "Unfortunately, this page doesn't exist.",
@@ -800,6 +816,9 @@
"description": "The server encountered an error and could not complete your request.",
"back_home": "Back to homepage"
},
+ "page_maintenance": {
+ "description": "We are under maintenance, we’ll be back soon."
+ },
"admin": {
"admin_header": {
"title": "Admin"
diff --git a/ui/src/index.scss b/ui/src/index.scss
index e81a900c..dd25289f 100644
--- a/ui/src/index.scss
+++ b/ui/src/index.scss
@@ -77,6 +77,9 @@ a {
.page-wrap {
min-height: calc(100vh - 148px);
}
+.page-wrap2 {
+ min-height: 100vh;
+}
.btn-no-border,
.btn-no-border:hover,
diff --git a/ui/src/pages/Install/index.tsx b/ui/src/pages/Install/index.tsx
index e1425893..8de7cb11 100644
--- a/ui/src/pages/Install/index.tsx
+++ b/ui/src/pages/Install/index.tsx
@@ -1,6 +1,6 @@
import { FC, useState } from 'react';
import { Container, Row, Col, Card, Alert } from 'react-bootstrap';
-import { useTranslation } from 'react-i18next';
+import { useTranslation, Trans } from 'react-i18next';
import {
FirstStep,
@@ -10,12 +10,15 @@ import {
Fifth,
} from './components';
+import { PageTitle } from '@/components';
+
const Index: FC = () => {
const { t } = useTranslation('translation', { keyPrefix: 'install' });
- const [step] = useState(5);
+ const [step] = useState(7);
return (
<div style={{ background: '#f5f5f5', minHeight: '100vh' }}>
+ <PageTitle title={t('install', { keyPrefix: 'page_title' })} />
<Container style={{ paddingTop: '74px' }}>
<Row className="justify-content-center">
<Col lg={6}>
@@ -32,6 +35,26 @@ const Index: FC = () => {
<FourthStep visible={step === 4} />
<Fifth visible={step === 5} />
+ {step === 6 && (
+ <div>
+ <h5>{t('warning')}</h5>
+ <p>
+ <Trans i18nKey="install.warning_description">
+ The file <code>config.yaml</code> already exists. If you
+ need to reset any of the configuration items in this
+ file, please delete it first. You may try{' '}
+ <a href="/">installing now</a>.
+ </Trans>
+ </p>
+ </div>
+ )}
+
+ {step === 7 && (
+ <div>
+ <h5>{t('installed')}</h5>
+ <p>{t('installed_description')}</p>
+ </div>
+ )}
</Card.Body>
</Card>
</Col>
diff --git a/ui/src/pages/Maintenance/index.tsx b/ui/src/pages/Maintenance/index.tsx
new file mode 100644
index 00000000..3a2c2d86
--- /dev/null
+++ b/ui/src/pages/Maintenance/index.tsx
@@ -0,0 +1,23 @@
+import { Container } from 'react-bootstrap';
+import { useTranslation } from 'react-i18next';
+
+import { PageTitle } from '@/components';
+
+const Index = () => {
+ const { t } = useTranslation('translation', {
+ keyPrefix: 'page_maintenance',
+ });
+ return (
+ <Container className="d-flex flex-column justify-content-center align-items-center page-wrap2">
+ <PageTitle title={t('maintenance', { keyPrefix: 'page_title' })} />
+ <div
+ className="mb-4 text-secondary"
+ style={{ fontSize: '120px', lineHeight: 1.2 }}>
+ (=‘_‘=)
+ </div>
+ <div className="text-center mb-4">{t('description')}</div>
+ </Container>
+ );
+};
+
+export default Index;
diff --git a/ui/src/pages/Upgrade/index.tsx b/ui/src/pages/Upgrade/index.tsx
new file mode 100644
index 00000000..aee2a37a
--- /dev/null
+++ b/ui/src/pages/Upgrade/index.tsx
@@ -0,0 +1,52 @@
+import { useState } from 'react';
+import { Container, Row, Col, Card, Button } from 'react-bootstrap';
+import { useTranslation, Trans } from 'react-i18next';
+
+import { PageTitle } from '@/components';
+
+const Index = () => {
+ const { t } = useTranslation('translation', {
+ keyPrefix: 'upgrade',
+ });
+ const [step, setStep] = useState(1);
+
+ const handleUpdate = () => {
+ setStep(2);
+ };
+ return (
+ <Container className="page-wrap2" style={{ paddingTop: '74px' }}>
+ <PageTitle title={t('upgrade', { keyPrefix: 'page_title' })} />
+ <Row className="justify-content-center">
+ <Col lg={6}>
+ <h2 className="text-center mb-4">{t('title')}</h2>
+ <Card>
+ <Card.Body>
+ {step === 1 && (
+ <>
+ <h5>{t('update_title')}</h5>
+ <Trans
+ i18nKey="upgrade.update_description"
+ components={{ 1: <p /> }}
+ />
+ <Button className="float-end" onClick={handleUpdate}>
+ {t('update_btn')}
+ </Button>
+ </>
+ )}
+
+ {step === 2 && (
+ <>
+ <h5>{t('done_title')}</h5>
+ <p>{t('done_desscription')}</p>
+ <Button className="float-end">{t('done_btn')}</Button>
+ </>
+ )}
+ </Card.Body>
+ </Card>
+ </Col>
+ </Row>
+ </Container>
+ );
+};
+
+export default Index;
diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.ts
index 69498f5d..9436298a 100644
--- a/ui/src/router/routes.ts
+++ b/ui/src/router/routes.ts
@@ -215,5 +215,13 @@ const routes: RouteNode[] = [
path: 'install',
page: 'pages/Install',
},
+ {
+ path: '/maintenance',
+ page: 'pages/Maintenance',
+ },
+ {
+ path: '/upgrade',
+ page: 'pages/Upgrade',
+ },
];
export default routes;