diff --git a/frontend/extension/src/components/ShortcutView.tsx b/frontend/extension/src/components/ShortcutView.tsx index a034be1..f760cee 100644 --- a/frontend/extension/src/components/ShortcutView.tsx +++ b/frontend/extension/src/components/ShortcutView.tsx @@ -28,7 +28,7 @@ const ShortcutView = (props: Props) => {
{favicon ? ( - + ) : ( )} diff --git a/frontend/web/src/components/CollectionView.tsx b/frontend/web/src/components/CollectionView.tsx index e4b42d0..20e6f20 100644 --- a/frontend/web/src/components/CollectionView.tsx +++ b/frontend/web/src/components/CollectionView.tsx @@ -3,13 +3,15 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import useNavigateTo from "@/hooks/useNavigateTo"; +import useResponsiveWidth from "@/hooks/useResponsiveWidth"; import { useAppSelector } from "@/stores"; import useCollectionStore from "@/stores/v1/collection"; import { Collection } from "@/types/proto/api/v2/collection_service"; import { Visibility } from "@/types/proto/api/v2/common"; import { showCommonDialog } from "./Alert"; -import CreateCollectionDialog, { ShortcutItem } from "./CreateCollectionDialog"; +import CreateCollectionDialog from "./CreateCollectionDialog"; import Icon from "./Icon"; +import ShortcutView from "./ShortcutView"; import Dropdown from "./common/Dropdown"; interface Props { @@ -19,6 +21,7 @@ interface Props { const CollectionView = (props: Props) => { const { collection } = props; const { t } = useTranslation(); + const { sm } = useResponsiveWidth(); const navigateTo = useNavigateTo(); const collectionStore = useCollectionStore(); const { shortcutList } = useAppSelector((state) => state.shortcut); @@ -82,7 +85,9 @@ const CollectionView = (props: Props) => {
{shortcuts.map((shortcut) => { - return handleShortcutClick(shortcut)} />; + return ( + handleShortcutClick(shortcut)} /> + ); })}
diff --git a/frontend/web/src/components/CreateCollectionDialog.tsx b/frontend/web/src/components/CreateCollectionDialog.tsx index ad3de28..ae130cb 100644 --- a/frontend/web/src/components/CreateCollectionDialog.tsx +++ b/frontend/web/src/components/CreateCollectionDialog.tsx @@ -1,12 +1,8 @@ import { Button, Input, Modal, ModalDialog, Radio, RadioGroup } from "@mui/joy"; -import classNames from "classnames"; import { isUndefined } from "lodash-es"; import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import { useTranslation } from "react-i18next"; -import { Link } from "react-router-dom"; -import { getFaviconWithGoogleS2 } from "@/helpers/utils"; -import useResponsiveWidth from "@/hooks/useResponsiveWidth"; import { useAppSelector } from "@/stores"; import useCollectionStore from "@/stores/v1/collection"; import { Collection } from "@/types/proto/api/v2/collection_service"; @@ -14,6 +10,7 @@ import { Visibility } from "@/types/proto/api/v2/common"; import { convertVisibilityFromPb } from "@/utils/visibility"; import useLoading from "../hooks/useLoading"; import Icon from "./Icon"; +import ShortcutView from "./ShortcutView"; interface Props { collectionId?: number; @@ -206,7 +203,7 @@ const CreateCollectionDialog: React.FC = (props: Props) => {
{selectedShortcuts.map((shortcut) => { return ( - = (props: Props) => { })} {unselectedShortcuts.map((shortcut) => { return ( - = (props: Props) => { ); }; -interface ShortcutItemProps { - shortcut: Shortcut; - className?: string; - onClick?: () => void; -} - -export const ShortcutItem = (props: ShortcutItemProps) => { - const { shortcut, className, onClick } = props; - const { sm } = useResponsiveWidth(); - const favicon = getFaviconWithGoogleS2(shortcut.link); - - return ( -
- - {favicon ? ( - - ) : ( - - )} - -
-
- -
- {shortcut.title} - {shortcut.title ? ( - (s/{shortcut.name}) - ) : ( - <> - s/ - {shortcut.name} - - )} -
-
-
-
- - - -
- ); -}; - export default CreateCollectionDialog; diff --git a/frontend/web/src/components/ShortcutCard.tsx b/frontend/web/src/components/ShortcutCard.tsx index 4b287fe..7184103 100644 --- a/frontend/web/src/components/ShortcutCard.tsx +++ b/frontend/web/src/components/ShortcutCard.tsx @@ -37,7 +37,7 @@ const ShortcutCard = (props: Props) => {
{favicon ? ( - + ) : ( )} diff --git a/frontend/web/src/components/ShortcutView.tsx b/frontend/web/src/components/ShortcutView.tsx index 51be104..f55ff90 100644 --- a/frontend/web/src/components/ShortcutView.tsx +++ b/frontend/web/src/components/ShortcutView.tsx @@ -1,69 +1,65 @@ import classNames from "classnames"; import { Link } from "react-router-dom"; -import { absolutifyLink, getFaviconWithGoogleS2 } from "../helpers/utils"; +import { getFaviconWithGoogleS2 } from "../helpers/utils"; import Icon from "./Icon"; import ShortcutActionsDropdown from "./ShortcutActionsDropdown"; interface Props { shortcut: Shortcut; className?: string; + showActions?: boolean; + alwaysShowLink?: boolean; + onClick?: () => void; } const ShortcutView = (props: Props) => { - const { shortcut, className } = props; - const shortcutLink = absolutifyLink(`/s/${shortcut.name}`); + const { shortcut, className, showActions, alwaysShowLink, onClick } = props; const favicon = getFaviconWithGoogleS2(shortcut.link); return ( - <> -
+ + {favicon ? ( + + ) : ( + + )} + +
+ {shortcut.title ? ( + <> + {shortcut.title} + (s/{shortcut.name}) + + ) : ( + <> + s/ + {shortcut.name} + )} - > -
- + + + + {showActions && ( +
+ +
+ )} +
); }; diff --git a/frontend/web/src/components/ShortcutsContainer.tsx b/frontend/web/src/components/ShortcutsContainer.tsx index b60d46d..417820b 100644 --- a/frontend/web/src/components/ShortcutsContainer.tsx +++ b/frontend/web/src/components/ShortcutsContainer.tsx @@ -21,7 +21,7 @@ const ShortcutsContainer: React.FC = (props: Props) => { )} > {shortcutList.map((shortcut) => { - return ; + return ; })}
); diff --git a/frontend/web/src/pages/CollectionSpace.tsx b/frontend/web/src/pages/CollectionSpace.tsx index 7f49379..f32d7f5 100644 --- a/frontend/web/src/pages/CollectionSpace.tsx +++ b/frontend/web/src/pages/CollectionSpace.tsx @@ -2,8 +2,8 @@ import { Divider } from "@mui/joy"; import classNames from "classnames"; import { useEffect, useState } from "react"; import { Link, useParams } from "react-router-dom"; -import { ShortcutItem } from "@/components/CreateCollectionDialog"; import Icon from "@/components/Icon"; +import ShortcutView from "@/components/ShortcutView"; import useResponsiveWidth from "@/hooks/useResponsiveWidth"; import useCollectionStore from "@/stores/v1/collection"; import useShortcutStore from "@/stores/v1/shortcut"; @@ -66,16 +66,19 @@ const CollectionSpace = () => {

{collection.description}

-
+
{shortcuts.map((shortcut) => { return ( - handleShortcutClick(shortcut)} /> ); diff --git a/frontend/web/src/pages/ShortcutDetail.tsx b/frontend/web/src/pages/ShortcutDetail.tsx index 4ad8dc0..a70031b 100644 --- a/frontend/web/src/pages/ShortcutDetail.tsx +++ b/frontend/web/src/pages/ShortcutDetail.tsx @@ -59,7 +59,7 @@ const ShortcutDetail = () => {
{favicon ? ( - + ) : ( )}