From d960fdcfb79caf257fed6b68cc169a785003d965 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 21 Dec 2020 17:33:16 +0800 Subject: ... --- .../src/app/views/timeline-common/TimelinePageTemplate.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx') diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index 6c57e91d..3833cdd9 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -11,6 +11,7 @@ import { usePostList, useTimelineInfo, } from "@/services/timeline"; +import { getHttpBookmarkClient } from "@/http/bookmark"; import { TimelineMemberDialog } from "./TimelineMember"; import TimelinePropertyChangeDialog from "./TimelinePropertyChangeDialog"; @@ -116,6 +117,19 @@ export default function TimelinePageTemplate( ? onManage : undefined, onMember: () => setDialog("member"), + onBookmark: + user != null + ? () => { + void getHttpBookmarkClient() + .put(name, user.token) + .then(() => { + pushAlert({ + message: "Succeeded to add bookmark!", //TODO: i18n + type: "success", + }); + }); + } + : undefined, }; if (type === "cache") { -- cgit v1.2.3 From e89f8c73fe646e43f66a9f869b56267557c96df5 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 23 Dec 2020 22:35:11 +0800 Subject: ... --- FrontEnd/src/app/services/user.ts | 4 ++++ .../app/views/timeline-common/TimelineCardTemplate.tsx | 9 +++++++++ .../app/views/timeline-common/TimelinePageTemplate.tsx | 16 +++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx') diff --git a/FrontEnd/src/app/services/user.ts b/FrontEnd/src/app/services/user.ts index 0166bce0..7a60b474 100644 --- a/FrontEnd/src/app/services/user.ts +++ b/FrontEnd/src/app/services/user.ts @@ -43,6 +43,10 @@ export class AuthUser implements User { get hasAllTimelineAdministrationPermission(): boolean { return this.permissions.includes("AllTimelineManagement"); } + + get hasHighlightTimelineAdministrationPermission(): boolean { + return this.permissions.includes("HighlightTimelineManagement"); + } } export interface LoginCredentials { diff --git a/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx index a47b3d76..ffec1a90 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx @@ -3,6 +3,7 @@ import clsx from "clsx"; import { useTranslation } from "react-i18next"; import { Dropdown, Button } from "react-bootstrap"; import Svg from "react-inlinesvg"; +import starIcon from "bootstrap-icons/icons/star.svg"; import bookmarkIcon from "bootstrap-icons/icons/bookmark.svg"; import { timelineVisibilityTooltipTranslationMap } from "@/services/timeline"; @@ -36,6 +37,7 @@ function TimelineCardTemplate({ infoArea, manageArea, onBookmark, + onHighlight, toggleCollapse, syncStatus, className, @@ -55,6 +57,13 @@ function TimelineCardTemplate({ {t(timelineVisibilityTooltipTranslationMap[timeline.visibility])}
+ {onHighlight != null ? ( + + ) : null} {onBookmark != null ? ( ( .put(name, user.token) .then(() => { pushAlert({ - message: "Succeeded to add bookmark!", //TODO: i18n + message: "Succeeded to add bookmark!", // TODO: i18n + type: "success", + }); + }); + } + : undefined, + onHighlight: + user != null && user.hasHighlightTimelineAdministrationPermission + ? () => { + void getHttpHighlightClient() + .put(name, user.token) + .then(() => { + pushAlert({ + message: "Succeeded to add highlight!", // TODO: i18n type: "success", }); }); -- cgit v1.2.3 From 8af803cb0da57af1355ad28cd056cb5dcf6d6915 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 3 Jan 2021 19:35:36 +0800 Subject: ... --- FrontEnd/src/app/locales/en/translation.json | 4 +++- FrontEnd/src/app/locales/zh/translation.json | 4 +++- .../src/app/views/timeline-common/TimelinePageTemplate.tsx | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx') diff --git a/FrontEnd/src/app/locales/en/translation.json b/FrontEnd/src/app/locales/en/translation.json index 414cc747..596b5217 100644 --- a/FrontEnd/src/app/locales/en/translation.json +++ b/FrontEnd/src/app/locales/en/translation.json @@ -106,7 +106,9 @@ "title": "Confirm Delete", "prompt": "Are you sure to delete the post? This operation is not recoverable." } - } + }, + "addHighlightSuccess": "Succeeded to add highlight.", + "addBookmarkSuccess": "Succeeded to add bookmark." }, "user": { "username": "username", diff --git a/FrontEnd/src/app/locales/zh/translation.json b/FrontEnd/src/app/locales/zh/translation.json index bbee28af..e15e177e 100644 --- a/FrontEnd/src/app/locales/zh/translation.json +++ b/FrontEnd/src/app/locales/zh/translation.json @@ -106,7 +106,9 @@ "title": "确认删除", "prompt": "确定删除这个消息?这个操作不可撤销。" } - } + }, + "addHighlightSuccess": "成功添加高光。", + "addBookmarkSuccess": "成功添加书签。" }, "user": { "username": "用户名", diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index 21720601..7f5c8206 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -125,7 +125,10 @@ export default function TimelinePageTemplate( .put(name, user.token) .then(() => { pushAlert({ - message: "Succeeded to add bookmark!", // TODO: i18n + message: { + type: "i18n", + key: "timeline.addBookmarkSuccess", + }, type: "success", }); }); @@ -138,7 +141,10 @@ export default function TimelinePageTemplate( .put(name, user.token) .then(() => { pushAlert({ - message: "Succeeded to add highlight!", // TODO: i18n + message: { + type: "i18n", + key: "timeline.addHighlightSuccess", + }, type: "success", }); }); -- cgit v1.2.3