Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

feat: add option to open link details

daniel31x1304c69bb05fb1
diff --git a/components/LinkViews/LinkComponents/LinkActions.tsx b/components/LinkViews/LinkComponents/LinkActions.tsx
index 833cef51..18da9723 100644
--- a/components/LinkViews/LinkComponents/LinkActions.tsx
+++ b/components/LinkViews/LinkComponents/LinkActions.tsx
@@ -18,9 +18,16 @@ type Props = {
link: LinkIncludingShortenedCollectionAndTags;
collection: CollectionIncludingMembersAndLinkCount;
btnStyle?: string;
+ linkModal: boolean;
+ setLinkModal: (value: boolean) => void;
};
-export default function LinkActions({ link, btnStyle }: Props) {
+export default function LinkActions({
+ link,
+ btnStyle,
+ linkModal,
+ setLinkModal,
+}: Props) {
const { t } = useTranslation();
const permissions = usePermissions(link.collection.id as number);
@@ -28,7 +35,6 @@ export default function LinkActions({ link, btnStyle }: Props) {
const pinLink = usePinLink();
- const [linkModal, setLinkModal] = useState(false);
const [editLinkModal, setEditLinkModal] = useState(false);
const [deleteLinkModal, setDeleteLinkModal] = useState(false);
diff --git a/components/LinkViews/LinkComponents/LinkCard.tsx b/components/LinkViews/LinkComponents/LinkCard.tsx
index 0e8a93b6..b5076c37 100644
--- a/components/LinkViews/LinkComponents/LinkCard.tsx
+++ b/components/LinkViews/LinkComponents/LinkCard.tsx
@@ -119,6 +119,8 @@ export default function LinkCard({ link, columns, editMode }: Props) {
const router = useRouter();
const isPublicRoute = router.pathname.startsWith("/public") ? true : false;
+ const [linkModal, setLinkModal] = useState(false);
+
useEffect(() => {
let interval: NodeJS.Timeout | null = null;
@@ -166,7 +168,9 @@ export default function LinkCard({ link, columns, editMode }: Props) {
>
<div
className="rounded-2xl cursor-pointer h-full flex flex-col justify-between"
- onClick={() => !editMode && openLink(link, user)}
+ onClick={() =>
+ !editMode && openLink(link, user, () => setLinkModal(true))
+ }
>
{show.image && (
<div>
@@ -243,7 +247,12 @@ export default function LinkCard({ link, columns, editMode }: Props) {
{/* Overlay on hover */}
<div className="absolute pointer-events-none top-0 left-0 right-0 bottom-0 bg-base-100 bg-opacity-0 group-hover:bg-opacity-20 group-focus-within:opacity-20 rounded-2xl duration-100"></div>
- <LinkActions link={link} collection={collection} />
+ <LinkActions
+ link={link}
+ collection={collection}
+ linkModal={linkModal}
+ setLinkModal={(e) => setLinkModal(e)}
+ />
{!isPublicRoute && <LinkPin link={link} />}
</div>
);
diff --git a/components/LinkViews/LinkComponents/LinkList.tsx b/components/LinkViews/LinkComponents/LinkList.tsx
index 5e6314ba..9256803e 100644
--- a/components/LinkViews/LinkComponents/LinkList.tsx
+++ b/components/LinkViews/LinkComponents/LinkList.tsx
@@ -97,6 +97,9 @@ export default function LinkCardCompact({ link, editMode }: Props) {
const router = useRouter();
let isPublic = router.pathname.startsWith("/public") ? true : undefined;
+
+ const [linkModal, setLinkModal] = useState(false);
+
return (
<>
<div
@@ -113,7 +116,9 @@ export default function LinkCardCompact({ link, editMode }: Props) {
>
<div
className="flex items-center cursor-pointer w-full min-h-12"
- onClick={() => !editMode && openLink(link, user)}
+ onClick={() =>
+ !editMode && openLink(link, user, () => setLinkModal(true))
+ }
>
{show.icon && (
<div className="shrink-0">
@@ -149,7 +154,13 @@ export default function LinkCardCompact({ link, editMode }: Props) {
</div>
</div>
{!isPublic && <LinkPin link={link} btnStyle="btn-ghost" />}
- <LinkActions link={link} collection={collection} btnStyle="btn-ghost" />
+ <LinkActions
+ link={link}
+ collection={collection}
+ btnStyle="btn-ghost"
+ linkModal={linkModal}
+ setLinkModal={(e) => setLinkModal(e)}
+ />
</div>
<div className="last:hidden rounded-none my-0 mx-1 border-t border-base-300 h-[1px]"></div>
</>
diff --git a/components/LinkViews/LinkComponents/LinkMasonry.tsx b/components/LinkViews/LinkComponents/LinkMasonry.tsx
index 5211a381..5a4b30d9 100644
--- a/components/LinkViews/LinkComponents/LinkMasonry.tsx
+++ b/components/LinkViews/LinkComponents/LinkMasonry.tsx
@@ -147,6 +147,8 @@ export default function LinkMasonry({ link, editMode, columns }: Props) {
editMode &&
(permissions === true || permissions?.canCreate || permissions?.canDelete);
+ const [linkModal, setLinkModal] = useState(false);
+
return (
<div
ref={ref}
@@ -161,7 +163,9 @@ export default function LinkMasonry({ link, editMode, columns }: Props) {
>
<div
className="rounded-2xl cursor-pointer"
- onClick={() => !editMode && openLink(link, user)}
+ onClick={() =>
+ !editMode && openLink(link, user, () => setLinkModal(true))
+ }
>
{show.image && formatAvailable(link, "preview") && (
<div>
@@ -254,7 +258,12 @@ export default function LinkMasonry({ link, editMode, columns }: Props) {
{/* Overlay on hover */}
<div className="absolute pointer-events-none top-0 left-0 right-0 bottom-0 bg-base-100 bg-opacity-0 group-hover:bg-opacity-20 group-focus-within:opacity-20 rounded-2xl duration-100"></div>
- <LinkActions link={link} collection={collection} />
+ <LinkActions
+ link={link}
+ collection={collection}
+ linkModal={linkModal}
+ setLinkModal={(e) => setLinkModal(e)}
+ />
{!isPublic && <LinkPin link={link} />}
</div>
);
diff --git a/lib/client/openLink.ts b/lib/client/openLink.ts
index 42d81c92..8f2c0f34 100644
--- a/lib/client/openLink.ts
+++ b/lib/client/openLink.ts
@@ -7,9 +7,11 @@ import { LinksRouteTo } from "@prisma/client";
const openLink = (
link: LinkIncludingShortenedCollectionAndTags,
- user: AccountSettings
+ user: AccountSettings,
+ openModal: () => void
) => {
if (user.linksRouteTo === LinksRouteTo.DETAILS) {
+ openModal();
} else {
window.open(generateLinkHref(link, user), "_blank");
}