Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Small folder fix

Steven Teybbe900cabb5c
diff --git a/apps/web/lib/analytics/get-folder-ids-to-filter.ts b/apps/web/lib/analytics/get-folder-ids-to-filter.ts
index 76dd47d28b..9462199b4e 100644
--- a/apps/web/lib/analytics/get-folder-ids-to-filter.ts
+++ b/apps/web/lib/analytics/get-folder-ids-to-filter.ts
@@ -1,3 +1,4 @@
+import { prisma } from "@dub/prisma";
import { Project } from "@prisma/client";
import { getFolders } from "../folder/get-folders";
import { getPlanCapabilities } from "../plan-capabilities";
@@ -18,6 +19,7 @@ export const getFolderIdsToFilter = async ({
const { canManageFolderPermissions } = getPlanCapabilities(workspace.plan);
+ // if rbac is enabled, we need to get all folders the user has access to
if (canManageFolderPermissions) {
const folders = await getFolders({
workspaceId: workspace.id,
@@ -26,6 +28,15 @@ export const getFolderIdsToFilter = async ({
pageSize: 1000, // TODO: might need to handle this if folks have > 1000 folders in the future
});
+ folderIds = folders.map((folder) => folder.id).concat("");
+ // else, just get all folders for the workspace
+ } else {
+ const folders = await prisma.folder.findMany({
+ where: {
+ projectId: workspace.id,
+ },
+ });
+
folderIds = folders.map((folder) => folder.id).concat("");
}
diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsx
index eeced57977..dc72772f8a 100644
--- a/apps/web/ui/links/link-card.tsx
+++ b/apps/web/ui/links/link-card.tsx
@@ -5,6 +5,7 @@ import {
ExpandingArrow,
useIntersectionObserver,
useMediaQuery,
+ useRouterStuff,
} from "@dub/ui";
import Link from "next/link";
import { useRouter, useSearchParams } from "next/navigation";
@@ -55,6 +56,7 @@ const LinkCardInner = memo(({ link }: { link: ResponseLink }) => {
const searchParams = useSearchParams();
const selectedFolderId = searchParams.get("folderId");
const { slug, defaultFolderId } = useWorkspace();
+ const { queryParams } = useRouterStuff();
const entry = useIntersectionObserver(ref);
const isInView = entry?.isIntersecting;
@@ -102,7 +104,14 @@ const LinkCardInner = memo(({ link }: { link: ResponseLink }) => {
showFolderIcon && {
banner: (
<Link
- href={`/${slug}/links?folderId=${folder?.id}`}
+ href={
+ folder
+ ? (queryParams({
+ set: { folderId: folder?.id || "" },
+ getNewPath: true,
+ }) as string)
+ : "#"
+ }
className="group flex items-center justify-between gap-2 rounded-t-xl border-b border-neutral-100 bg-neutral-50 px-5 py-2 text-xs"
>
<div className="flex items-center gap-1.5">