From 955704d1e8c3f47b8672cbbd77f4bfb6068fd7b2 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 3 Jan 2021 19:01:32 +0800 Subject: ... --- FrontEnd/src/app/locales/en/translation.json | 3 + FrontEnd/src/app/locales/zh/translation.json | 3 + FrontEnd/src/app/views/home/BoardWithUser.tsx | 89 ++++++++++++++++++--------- FrontEnd/src/app/views/home/TimelineBoard.tsx | 46 +++++++------- FrontEnd/src/app/views/home/home.sass | 1 + 5 files changed, 89 insertions(+), 53 deletions(-) (limited to 'FrontEnd/src') diff --git a/FrontEnd/src/app/locales/en/translation.json b/FrontEnd/src/app/locales/en/translation.json index be80d21e..28e7c978 100644 --- a/FrontEnd/src/app/locales/en/translation.json +++ b/FrontEnd/src/app/locales/en/translation.json @@ -1,6 +1,8 @@ { "welcome": "Welcome!", "search": "Search", + "edit": "Edit", + "done": "Done", "loadFailReload": "Load failed, click <1>here to reload.", "serviceWorker": { "availableOffline": "Timeline is now cached in your computer and you can use it offline. 🎉🎉🎉", @@ -23,6 +25,7 @@ "highlightTimeline": "Highlight Timelines", "relatedTimeline": "Timelines Related To You", "publicTimeline": "Public Timelines", + "bookmarkTimeline": "Bookmark Timelines", "offlinePrompt": "Oh oh, it seems you are offline. Here list some timelines cached locally. You can view them or click <1>here to refresh.", "createButton": "Create Timeline", "createDialog": { diff --git a/FrontEnd/src/app/locales/zh/translation.json b/FrontEnd/src/app/locales/zh/translation.json index 8c925eb9..708d0b3b 100644 --- a/FrontEnd/src/app/locales/zh/translation.json +++ b/FrontEnd/src/app/locales/zh/translation.json @@ -1,6 +1,8 @@ { "welcome": "欢迎!", "search": "搜索", + "edit": "编辑", + "done": "完成", "loadFailReload": "加载失败,<1>点击重试。", "serviceWorker": { "availableOffline": "Timeline 已经缓存在本地,你可以离线使用它。🎉🎉🎉", @@ -23,6 +25,7 @@ "highlightTimeline": "高光时间线", "relatedTimeline": "关于你的时间线", "publicTimeline": "公开时间线", + "bookmarkTimeline": "书签时间线", "offlinePrompt": "你好像处于离线状态。以下是一些缓存在本地的时间线。你可以查看它们或者<1>点击重新获取在线信息。", "createButton": "创建时间线", "createDialog": { diff --git a/FrontEnd/src/app/views/home/BoardWithUser.tsx b/FrontEnd/src/app/views/home/BoardWithUser.tsx index 7c736695..1c6f713a 100644 --- a/FrontEnd/src/app/views/home/BoardWithUser.tsx +++ b/FrontEnd/src/app/views/home/BoardWithUser.tsx @@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next"; import { AuthUser } from "@/services/user"; import { getHttpHighlightClient } from "@/http/highlight"; import { getHttpTimelineClient } from "@/http/timeline"; +import { getHttpBookmarkClient } from "@/http/bookmark"; import TimelineBoard from "./TimelineBoard"; @@ -12,36 +13,64 @@ const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => { const { t } = useTranslation(); return ( - - - getHttpHighlightClient().list()} - editHandler={ - user.hasHighlightTimelineAdministrationPermission - ? { - onDelete: () => { - // TODO: Implement this. - return Promise.resolve(); - }, - onMove: () => { - // TODO: Implement this. - return Promise.resolve(); - }, - } - : undefined - } - /> - - - - getHttpTimelineClient().listTimeline({ relate: user.username }) - } - /> - - + <> + + + getHttpBookmarkClient().list(user.token)} + editHandler={{ + onDelete: () => { + // TODO: Implement this. + return Promise.resolve(); + }, + onMove: () => { + // TODO: Implement this. + return Promise.resolve(); + }, + }} + /> + + + + getHttpTimelineClient().listTimeline({ relate: user.username }) + } + /> + + + + + getHttpHighlightClient().list()} + editHandler={ + user.hasHighlightTimelineAdministrationPermission + ? { + onDelete: () => { + // TODO: Implement this. + return Promise.resolve(); + }, + onMove: () => { + // TODO: Implement this. + return Promise.resolve(); + }, + } + : undefined + } + /> + + + + getHttpTimelineClient().listTimeline({ visibility: "Public" }) + } + /> + + + ); }; diff --git a/FrontEnd/src/app/views/home/TimelineBoard.tsx b/FrontEnd/src/app/views/home/TimelineBoard.tsx index bb3f5947..083f4034 100644 --- a/FrontEnd/src/app/views/home/TimelineBoard.tsx +++ b/FrontEnd/src/app/views/home/TimelineBoard.tsx @@ -1,7 +1,7 @@ import React from "react"; import clsx from "clsx"; import { Link } from "react-router-dom"; -import { Trans } from "react-i18next"; +import { Trans, useTranslation } from "react-i18next"; import { Spinner } from "react-bootstrap"; import { TimelineInfo } from "@/services/timeline"; @@ -218,6 +218,8 @@ interface TimelineBoardUIProps { const TimelineBoardUI: React.FC = (props) => { const { title, timelines, className, editHandler } = props; + const { t } = useTranslation(); + const editable = editHandler != null; const [editing, setEditing] = React.useState(false); @@ -226,28 +228,26 @@ const TimelineBoardUI: React.FC = (props) => {
{title != null &&

{title}

} - { - editable && - (editing ? ( -
{ - setEditing(false); - }} - > - Done -
- ) : ( -
{ - setEditing(true); - }} - > - Edit -
- )) // TODO: i18n - } + {editable && + (editing ? ( +
{ + setEditing(false); + }} + > + {t("done")} +
+ ) : ( +
{ + setEditing(true); + }} + > + {t("edit")} +
+ ))}
{(() => { if (timelines === "loading") { diff --git a/FrontEnd/src/app/views/home/home.sass b/FrontEnd/src/app/views/home/home.sass index 6af1b6d8..4b86f241 100644 --- a/FrontEnd/src/app/views/home/home.sass +++ b/FrontEnd/src/app/views/home/home.sass @@ -4,6 +4,7 @@ @extend .flex-column @extend .py-3 min-height: 200px + height: 100% position: relative .timeline-board-header -- cgit v1.2.3