From 7d90b4787572a7cd2f14239b01603ec743c26c68 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 4 Jul 2023 20:53:07 +0800 Subject: [PATCH] chore: update shortcut view --- web/src/components/CreateShortcutDialog.tsx | 43 +++++---------------- web/src/components/ShortcutListView.tsx | 2 + web/src/components/ShortcutView.tsx | 11 +++++- web/src/pages/Home.tsx | 3 +- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/web/src/components/CreateShortcutDialog.tsx b/web/src/components/CreateShortcutDialog.tsx index 53aa90e..f41ecff 100644 --- a/web/src/components/CreateShortcutDialog.tsx +++ b/web/src/components/CreateShortcutDialog.tsx @@ -4,7 +4,6 @@ import { useTranslation } from "react-i18next"; import { toast } from "react-hot-toast"; import { shortcutService } from "../services"; import useLoading from "../hooks/useLoading"; -import { showCommonDialog } from "./Alert"; import Icon from "./Icon"; interface Props { @@ -97,22 +96,6 @@ const CreateShortcutDialog: React.FC = (props: Props) => { }); }; - const handleDeleteShortcutButtonClick = () => { - if (!shortcutId) { - return; - } - - showCommonDialog({ - title: "Delete Shortcut", - content: `Are you sure to delete shortcut \`${state.shortcutCreate.name}\`? You can not undo this action.`, - style: "danger", - onConfirm: async () => { - await shortcutService.deleteShortcutById(shortcutId); - onClose(); - }, - }); - }; - const handleSaveBtnClick = async () => { if (!state.shortcutCreate.name) { toast.error("Name is required"); @@ -208,23 +191,17 @@ const CreateShortcutDialog: React.FC = (props: Props) => { ))} +

+ {t(`shortcut.visibility.${state.shortcutCreate.visibility.toLowerCase()}.description`)} +

-
-
- {isEditing && ( - - )} -
-
- - -
+
+ +
diff --git a/web/src/components/ShortcutListView.tsx b/web/src/components/ShortcutListView.tsx index 1537612..50e923a 100644 --- a/web/src/components/ShortcutListView.tsx +++ b/web/src/components/ShortcutListView.tsx @@ -18,6 +18,8 @@ const ShortcutListView: React.FC = (props: Props) => { })} +

Total {shortcutList.length} data

+ {editingShortcutId && ( { }); }, [shortcut.link]); + const gotoShortcutLink = () => { + window.open(shortifyLink, "_blank"); + }; + const handleCopyButtonClick = () => { copy(shortifyLink); toast.success("Shortcut link copied to clipboard."); @@ -61,10 +65,13 @@ const ShortcutView = (props: Props) => { )} - + @@ -123,7 +130,7 @@ const ShortcutView = (props: Props) => {
- + {shortcut.view} visits
diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx index 533451c..607f831 100644 --- a/web/src/pages/Home.tsx +++ b/web/src/pages/Home.tsx @@ -65,7 +65,8 @@ const Home: React.FC = () => {

No shortcuts found.

) : (