From 77a3513a6b989273e10378ead33c1b4c5259ad4a Mon Sep 17 00:00:00 2001 From: Steven Date: Sat, 24 Sep 2022 09:31:20 +0800 Subject: [PATCH] chore: update memo detail page --- web/src/components/Memo.tsx | 74 ++++++++++++++---------- web/src/components/MemoCardDialog.tsx | 9 ++- web/src/less/memo-detail.less | 83 +++++++++++++++++++++++++++ web/src/locales/en.json | 2 +- web/src/locales/vi.json | 2 +- web/src/locales/zh.json | 2 +- web/src/pages/MemoDetail.tsx | 48 +++++++++++++++- 7 files changed, 183 insertions(+), 37 deletions(-) create mode 100644 web/src/less/memo-detail.less diff --git a/web/src/components/Memo.tsx b/web/src/components/Memo.tsx index ec990dee..64fecbda 100644 --- a/web/src/components/Memo.tsx +++ b/web/src/components/Memo.tsx @@ -3,6 +3,7 @@ import relativeTime from "dayjs/plugin/relativeTime"; import { indexOf } from "lodash-es"; import { memo, useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; +import { useNavigate } from "react-router-dom"; import "dayjs/locale/zh"; import { UNKNOWN_ID } from "../helpers/consts"; import { DONE_BLOCK_REG, TODO_BLOCK_REG } from "../helpers/marked"; @@ -32,6 +33,7 @@ export const getFormatedMemoCreatedAtStr = (createdTs: number, locale = "en"): s const Memo: React.FC = (props: Props) => { const memo = props.memo; const { t, i18n } = useTranslation(); + const navigate = useNavigate(); const [createdAtStr, setCreatedAtStr] = useState(getFormatedMemoCreatedAtStr(memo.createdTs, i18n.language)); const memoContainerRef = useRef(null); const isVisitorMode = userService.isVisitorMode(); @@ -50,9 +52,17 @@ const Memo: React.FC = (props: Props) => { }, [i18n.language]); const handleShowMemoStoryDialog = () => { + if (isVisitorMode) { + return; + } + showMemoCardDialog(memo); }; + const handleViewMemoDetailPage = () => { + navigate(`/m/${memo.id}`); + }; + const handleTogglePinMemoBtnClick = async () => { try { if (memo.pinned) { @@ -165,44 +175,48 @@ const Memo: React.FC = (props: Props) => { return (
-
- {createdAtStr} +
+ + {createdAtStr} + {memo.visibility !== "PRIVATE" && !isVisitorMode && ( {memo.visibility} )}
-
- - - -
-
-
-
- - {memo.pinned ? t("common.unpin") : t("common.pin")} -
-
- - {t("common.edit")} -
-
- - {t("common.share")} + {!isVisitorMode && ( +
+ + + +
+
+
+
+ + {memo.pinned ? t("common.unpin") : t("common.pin")} +
+
+ + {t("common.edit")} +
+
+ + {t("common.share")} +
+ + {t("common.mark")} + + + {t("memo.view-detail")} + + + {t("common.archive")} +
- - {t("common.mark")} - - - {t("memo.view-story")} - - - {t("common.archive")} -
-
+ )}
= (props: Props) => { }); const [linkMemos, setLinkMemos] = useState([]); const [linkedMemos, setLinkedMemos] = useState([]); + const isVisitorMode = userService.isVisitorMode(); const visibilitySelectorItems = VISIBILITY_SELECTOR_ITEMS.map((item) => { return { value: item.value, @@ -83,6 +84,10 @@ const MemoCardDialog: React.FC = (props: Props) => { }, [memos, memo.id]); const handleMemoCreatedAtClick = () => { + if (isVisitorMode) { + return; + } + showChangeMemoCreatedTsDialog(memo.id); }; @@ -140,7 +145,7 @@ const MemoCardDialog: React.FC = (props: Props) => { return ( <> - {!userService.isVisitorMode() && ( + {!isVisitorMode && (
@@ -159,7 +164,7 @@ const MemoCardDialog: React.FC = (props: Props) => { {utils.getDateTimeString(memo.createdTs)}

- {!userService.isVisitorMode() && ( + {!isVisitorMode && ( <>