From e62eebf9060943e547741d29d56e6d009831a88d Mon Sep 17 00:00:00 2001 From: Johnny Date: Mon, 22 Dec 2025 08:53:54 +0800 Subject: [PATCH] chore: refactor tooltip usage and remove unused components --- frontend/web/src/App.tsx | 5 +- .../web/src/components/CollectionView.tsx | 52 ++-- frontend/web/src/components/ShortcutCard.tsx | 230 +++++++++--------- .../web/src/components/ui/animated-card.tsx | 22 -- frontend/web/src/components/ui/input.tsx | 2 +- frontend/web/src/pages/ShortcutDashboard.tsx | 4 +- frontend/web/src/pages/ShortcutDetail.tsx | 110 ++++----- frontend/web/src/pages/WorkspaceSetting.tsx | 14 +- 8 files changed, 195 insertions(+), 244 deletions(-) delete mode 100644 frontend/web/src/components/ui/animated-card.tsx diff --git a/frontend/web/src/App.tsx b/frontend/web/src/App.tsx index dd72942..5baffc0 100644 --- a/frontend/web/src/App.tsx +++ b/frontend/web/src/App.tsx @@ -1,6 +1,7 @@ import { useTheme } from "next-themes"; import { useEffect } from "react"; import { Outlet } from "react-router-dom"; +import { TooltipProvider } from "@/components/ui/tooltip"; import { useWorkspaceStore } from "@/stores"; import useNavigateTo from "./hooks/useNavigateTo"; import { FeatureType } from "./stores/workspace"; @@ -63,9 +64,9 @@ function App() { }, [colorScheme]); return ( - <> + - + ); } diff --git a/frontend/web/src/components/CollectionView.tsx b/frontend/web/src/components/CollectionView.tsx index f280d75..1ba5c0a 100644 --- a/frontend/web/src/components/CollectionView.tsx +++ b/frontend/web/src/components/CollectionView.tsx @@ -4,7 +4,7 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import { toast } from "sonner"; -import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { absolutifyLink } from "@/helpers/utils"; import useNavigateTo from "@/hooks/useNavigateTo"; import useResponsiveWidth from "@/hooks/useResponsiveWidth"; @@ -76,33 +76,29 @@ const CollectionView = (props: Props) => {

{collection.description}

- - - - - - - - Share - - - - - - - - Open all - - + + + + + + + Share + + + + + + Open all + {showAdminActions && ( { }; return ( - - -
-
+ + +
+ {shortcut.tags.map((tag) => { + return ( + viewStore.setFilter({ tag: tag })} + > + #{tag} + + ); + })} + {shortcut.tags.length === 0 && No tags} +
+
+ + + + {creator.nickname.substring(0, 2).toUpperCase()} + + + +

{creator.nickname}

+
+
+ + +
viewStore.setFilter({ visibility: shortcut.visibility })} + > + + {t(`shortcut.visibility.${shortcut.visibility.toLowerCase()}.self`)} +
+
+ +

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

+
+
+ + - + + {t("shortcut.visits", { count: shortcut.viewCount })} - -
-
- -
-
-
- {shortcut.tags.map((tag) => { - return ( - viewStore.setFilter({ tag: tag })} - > - #{tag} - - ); - })} - {shortcut.tags.length === 0 && No tags} -
-
- - - - {creator.nickname.substring(0, 2).toUpperCase()} - - - -

{creator.nickname}

-
-
- - -
viewStore.setFilter({ visibility: shortcut.visibility })} - > - - {t(`shortcut.visibility.${shortcut.visibility.toLowerCase()}.self`)} -
-
- -

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

-
-
- - - - - {t("shortcut.visits", { count: shortcut.viewCount })} - - - -

View count

-
-
-
- - + + +

View count

+
+ +
+ ); }; diff --git a/frontend/web/src/components/ui/animated-card.tsx b/frontend/web/src/components/ui/animated-card.tsx deleted file mode 100644 index bab88b3..0000000 --- a/frontend/web/src/components/ui/animated-card.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { motion } from "framer-motion"; -import { forwardRef } from "react"; -import { Card, CardProps } from "@/components/ui/card"; - -const AnimatedCard = forwardRef(({ className, children, ...props }, ref) => { - return ( - - - {children} - - - ); -}); - -AnimatedCard.displayName = "AnimatedCard"; - -export { AnimatedCard }; diff --git a/frontend/web/src/components/ui/input.tsx b/frontend/web/src/components/ui/input.tsx index 42122a9..a89c2a1 100644 --- a/frontend/web/src/components/ui/input.tsx +++ b/frontend/web/src/components/ui/input.tsx @@ -6,7 +6,7 @@ const Input = React.forwardRef>( { <>
-
+
{
- - - - - - Copy - - - - - - - - QR Code - - + + + + + Copy + + + + + + QR Code + {havePermission && ( { {shortcut.tags.length === 0 && No tags}
- - - -
- - {creator.nickname} -
-
- Creator -
-
- - - -
- - {t(`shortcut.visibility.${shortcut.visibility.toLowerCase()}.self`)} -
-
- {t(`shortcut.visibility.${shortcut.visibility.toLowerCase()}.description`)} -
-
- - - -
- - {shortcut.viewCount} visits -
-
- View count -
-
+ + +
+ + {creator.nickname} +
+
+ Creator +
+ + +
+ + {t(`shortcut.visibility.${shortcut.visibility.toLowerCase()}.self`)} +
+
+ {t(`shortcut.visibility.${shortcut.visibility.toLowerCase()}.description`)} +
+ + +
+ + {shortcut.viewCount} visits +
+
+ View count +
diff --git a/frontend/web/src/pages/WorkspaceSetting.tsx b/frontend/web/src/pages/WorkspaceSetting.tsx index c40a355..abe2672 100644 --- a/frontend/web/src/pages/WorkspaceSetting.tsx +++ b/frontend/web/src/pages/WorkspaceSetting.tsx @@ -1,10 +1,9 @@ -import { useEffect } from "react"; import { Link } from "react-router-dom"; +import { toast } from "sonner"; import Icon from "@/components/Icon"; import WorkspaceGeneralSettingSection from "@/components/setting/WorkspaceGeneralSettingSection"; import WorkspaceMembersSection from "@/components/setting/WorkspaceMembersSection"; import WorkspaceSecuritySection from "@/components/setting/WorkspaceSecuritySection"; -import { Alert, AlertDescription } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import { useUserStore, useWorkspaceStore } from "@/stores"; @@ -16,22 +15,13 @@ const WorkspaceSetting = () => { const currentUser = useUserStore().getCurrentUser(); const isAdmin = currentUser.role === Role.ADMIN; - useEffect(() => { - if (!isAdmin) { - window.location.href = "/"; - } - }, []); - if (!isAdmin) { + toast.error("Only workspace admins can access workspace settings."); return null; } return (
- - - You can see the settings items below because you are an Admin. -

Subscription