From cffd6b143142765dd9af51491f23ee943660ea4c Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 25 Jun 2023 22:14:04 +0800 Subject: [PATCH] chore: update shortcut view --- web/src/components/CreateShortcutDialog.tsx | 5 +-- web/src/components/Header.tsx | 5 ++- web/src/components/ShortcutView.tsx | 45 +++++++++++-------- web/src/components/VisibilityIcon.tsx | 20 +++++++++ web/src/components/setting/AccountSection.tsx | 2 +- 5 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 web/src/components/VisibilityIcon.tsx diff --git a/web/src/components/CreateShortcutDialog.tsx b/web/src/components/CreateShortcutDialog.tsx index b7ecc12..bef2b1f 100644 --- a/web/src/components/CreateShortcutDialog.tsx +++ b/web/src/components/CreateShortcutDialog.tsx @@ -128,11 +128,10 @@ const CreateShortcutDialog: React.FC = (props: Props) => { Name *
- s/ diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx index 47090e9..159d575 100644 --- a/web/src/components/Header.tsx +++ b/web/src/components/Header.tsx @@ -2,6 +2,7 @@ import { Link, useNavigate } from "react-router-dom"; import { useAppSelector } from "../stores"; import Icon from "./Icon"; import Dropdown from "./common/Dropdown"; +import { Avatar } from "@mui/joy"; const Header: React.FC = () => { const navigate = useNavigate(); @@ -24,11 +25,12 @@ const Header: React.FC = () => { - + {user.nickname} } + actionsClassName="!w-36" actions={ <> { } - actionsClassName="!w-40" >
diff --git a/web/src/components/ShortcutView.tsx b/web/src/components/ShortcutView.tsx index 4502ede..0e0168d 100644 --- a/web/src/components/ShortcutView.tsx +++ b/web/src/components/ShortcutView.tsx @@ -1,12 +1,13 @@ -import copy from "copy-to-clipboard"; -import { absolutifyLink } from "../helpers/utils"; -import toast from "react-hot-toast"; -import { showCommonDialog } from "./Alert"; -import { shortcutService } from "../services"; import { Tooltip } from "@mui/joy"; +import copy from "copy-to-clipboard"; +import toast from "react-hot-toast"; +import { shortcutService } from "../services"; +import { useAppSelector } from "../stores"; +import { absolutifyLink } from "../helpers/utils"; +import { showCommonDialog } from "./Alert"; import Icon from "./Icon"; import Dropdown from "./common/Dropdown"; -import { useAppSelector } from "../stores"; +import VisibilityIcon from "./VisibilityIcon"; interface Props { shortcut: Shortcut; @@ -38,13 +39,13 @@ const ShortcutView = (props: Props) => { }; return ( -
+

- handleCopyButtonClick(shortcut)}> - o/ +

@@ -63,19 +64,19 @@ const ShortcutView = (props: Props) => { <> } @@ -83,8 +84,8 @@ const ShortcutView = (props: Props) => {
{shortcut.description &&

{shortcut.description}

} - {shortcut.tags.length > 0 && false && ( -
+ {shortcut.tags.length > 0 && ( +
{shortcut.tags.map((tag) => { return ( @@ -97,15 +98,21 @@ const ShortcutView = (props: Props) => { )}
-
+
{shortcut.creator.nickname}
-
+
+ + {shortcut.visibility} +
+ + +
- {shortcut.view} + {shortcut.view} visits
diff --git a/web/src/components/VisibilityIcon.tsx b/web/src/components/VisibilityIcon.tsx new file mode 100644 index 0000000..183d4ff --- /dev/null +++ b/web/src/components/VisibilityIcon.tsx @@ -0,0 +1,20 @@ +import Icon from "./Icon"; + +interface Props { + visibility: Visibility; + className?: string; +} + +const VisibilityIcon = (props: Props) => { + const { visibility, className } = props; + if (visibility === "PRIVATE") { + return ; + } else if (visibility === "WORKSPACE") { + return ; + } else if (visibility === "PUBLIC") { + return ; + } + return null; +}; + +export default VisibilityIcon; diff --git a/web/src/components/setting/AccountSection.tsx b/web/src/components/setting/AccountSection.tsx index 24bc56d..35f9edb 100644 --- a/web/src/components/setting/AccountSection.tsx +++ b/web/src/components/setting/AccountSection.tsx @@ -16,7 +16,7 @@ const AccountSection: React.FC = () => {

Account

{user.nickname} - {isAdmin && Admin} + {isAdmin && Admin}

Email: