The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix folder bugs
Steven Tey20d4c932129e
diff --git a/apps/web/app/api/folders/[folderId]/route.ts b/apps/web/app/api/folders/[folderId]/route.tsindex 32aeb3e7e2..79398674a4 100644--- a/apps/web/app/api/folders/[folderId]/route.ts+++ b/apps/web/app/api/folders/[folderId]/route.ts@@ -51,7 +51,8 @@ export const PATCH = withWorkspace(if (!canManageFolderPermissions && accessLevel !== "write") {throw new DubApiError({code: "forbidden",- message: "You are not allowed to manage permissions for this folder.",+ message:+ "You can only set access levels for folders on Business plans and above. Upgrade to Business to continue.",});}diff --git a/apps/web/lib/swr/use-folder-permissions.ts b/apps/web/lib/swr/use-folder-permissions.tsindex 5d15ff1170..0c17df6bbb 100644--- a/apps/web/lib/swr/use-folder-permissions.ts+++ b/apps/web/lib/swr/use-folder-permissions.ts@@ -1,3 +1,4 @@+import { getPlanCapabilities } from "@/lib/plan-capabilities";import { FolderPermission, FolderWithPermissions } from "@/lib/types";import { fetcher } from "@dub/utils";import useSWR from "swr";@@ -28,11 +29,13 @@ export function useCheckFolderPermission(folderId: string | null,action: FolderPermission,) {- const { folders, isLoading } = useFolderPermissions();+ const { plan } = useWorkspace();+ const { folders } = useFolderPermissions();+ const { canManageFolderPermissions } = getPlanCapabilities(plan);- // if (isLoading) {- // return false;- // }+ if (!canManageFolderPermissions) {+ return true;+ }if (!folderId) {return true;diff --git a/apps/web/ui/folders/folder-icon.tsx b/apps/web/ui/folders/folder-icon.tsxindex 9aa82cd3a5..69b17a2791 100644--- a/apps/web/ui/folders/folder-icon.tsx+++ b/apps/web/ui/folders/folder-icon.tsx@@ -8,42 +8,44 @@ import {} from "@dub/ui/icons";import { cn } from "@dub/utils";-const FolderOpen = ({ className }: { className: string }) => {- return <Folder className={cn("text-blue-800", className)} />;-};-const folderIconsMap: Record<FolderAccessLevel | "new" | "unsorted" | "none",{borderColor: string;bgColor: string;icon: React.ElementType;+ iconClassName: string;}> = {read: {borderColor: "border-indigo-200",bgColor: "bg-indigo-100",icon: FolderShield,+ iconClassName: "text-[#3730A3]",},write: {borderColor: "border-blue-200",bgColor: "bg-blue-100",- icon: FolderOpen,+ icon: Folder,+ iconClassName: "text-blue-800",},none: {borderColor: "border-orange-200",bgColor: "bg-orange-100",icon: FolderLock,+ iconClassName: "text-[#9A3412]",},new: {borderColor: "border-neutral-200",bgColor: "bg-neutral-100",icon: FolderPlus,+ iconClassName: "text-[#1F2937]",},unsorted: {borderColor: "border-green-200",bgColor: "bg-green-100",icon: FolderBookmark,+ iconClassName: "text-[#166534]",},} as const;@@ -65,15 +67,18 @@ export const FolderIcon = ({folder,shape = "rounded",className,- iconClassName,}: {folder: Pick<FolderProps, "id" | "accessLevel">;shape?: "rounded" | "square";className?: string;- iconClassName?: string;}) => {const iconType = determineFolderIcon(folder);- const { borderColor, bgColor, icon: Icon } = folderIconsMap[iconType];+ const {+ borderColor,+ bgColor,+ icon: Icon,+ iconClassName,+ } = folderIconsMap[iconType];return (<divdiff --git a/apps/web/ui/folders/folder-permissions-panel.tsx b/apps/web/ui/folders/folder-permissions-panel.tsxindex 8996c4d62d..fb4c69be82 100644--- a/apps/web/ui/folders/folder-permissions-panel.tsx+++ b/apps/web/ui/folders/folder-permissions-panel.tsx@@ -87,7 +87,7 @@ const FolderPermissionsPanel = ({setIsUpdating(false);if (!response.ok) {- const error = await response.json();+ const { error } = await response.json();toast.error(error.message);return;}@@ -105,7 +105,12 @@ const FolderPermissionsPanel = ({!canUpdateFolder && "cursor-not-allowed bg-neutral-100",)}value={workspaceAccessLevel || folder?.accessLevel || ""}- disabled={isUpdating || !canUpdateFolder || isLoadingPermissions}+ disabled={+ isUpdating ||+ isLoadingPermissions ||+ !canUpdateFolder ||+ !canManageFolderPermissions+ }onChange={(e) => updateWorkspaceAccessLevel(e.target.value)}>{Object.keys(FOLDER_WORKSPACE_ACCESS).map((access) => (diff --git a/apps/web/ui/links/link-controls.tsx b/apps/web/ui/links/link-controls.tsxindex 34d776e1cd..2b8b7d07fb 100644--- a/apps/web/ui/links/link-controls.tsx+++ b/apps/web/ui/links/link-controls.tsx@@ -14,7 +14,13 @@ import {useCopyToClipboard,useKeyboardShortcut,} from "@dub/ui";-import { BoxArchive, CircleCheck, Copy, QRCode } from "@dub/ui/icons";+import {+ BoxArchive,+ CircleCheck,+ Copy,+ FolderBookmark,+ QRCode,+} from "@dub/ui/icons";import { cn, isDubDomain, nanoid, punycode } from "@dub/utils";import { CopyPlus, Delete, FolderInput } from "lucide-react";import { useParams, useSearchParams } from "next/navigation";@@ -179,7 +185,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {setOpenPopover(false);setShowLinkBuilder(true);}}- icon={<PenWriting className="h-4 w-4" />}+ icon={<PenWriting className="size-4" />}shortcut="E"className="h-9 px-2 font-medium"disabledTooltip={@@ -195,7 +201,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {setOpenPopover(false);setShowLinkQRModal(true);}}- icon={<QRCode className="h-4 w-4" />}+ icon={<QRCode className="size-4" />}shortcut="Q"className="h-9 px-2 font-medium"/>@@ -206,7 +212,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {setOpenPopover(false);setShowDuplicateLinkModal(true);}}- icon={<CopyPlus className="h-4 w-4" />}+ icon={<CopyPlus className="size-4" />}shortcut="D"className="h-9 px-2 font-medium"disabledTooltip={@@ -221,9 +227,9 @@ export function LinkControls({ link }: { link: ResponseLink }) {onClick={() => copyLinkId()}icon={copiedLinkId ? (- <CircleCheck className="h-4 w-4" />+ <CircleCheck className="size-4" />) : (- <Copy className="h-4 w-4" />+ <Copy className="size-4" />)}shortcut="I"@@ -238,7 +244,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {variant="outline"shortcut="M"className="h-9 px-2 font-medium"- icon={<BoxArchive className="h-4 w-4" />}+ icon={<FolderBookmark className="size-4 text-neutral-600" />}onClick={() => {setOpenPopover(false);setShowMoveLinkToFolderModal(true);@@ -258,7 +264,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {setOpenPopover(false);setShowArchiveLinkModal(true);}}- icon={<BoxArchive className="h-4 w-4" />}+ icon={<BoxArchive className="size-4" />}shortcut="A"className="h-9 px-2 font-medium"disabledTooltip={@@ -275,7 +281,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {setOpenPopover(false);setShowTransferLinkModal(true);}}- icon={<FolderInput className="h-4 w-4" />}+ icon={<FolderInput className="size-4" />}shortcut="T"className="h-9 px-2 font-medium"disabledTooltip={@@ -298,7 +304,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {setOpenPopover(false);setShowDeleteLinkModal(true);}}- icon={<Delete className="h-4 w-4" />}+ icon={<Delete className="size-4" />}shortcut="X"className="h-9 px-2 font-medium"disabled={isRootLink || isProgramLink}@@ -318,7 +324,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {onClick={() => handleBanLink()}className="group flex w-full items-center justify-between rounded-md p-2 text-left text-sm font-medium text-red-600 transition-all duration-75 hover:bg-red-600 hover:text-white">- <IconMenu text="Ban" icon={<Delete className="h-4 w-4" />} />+ <IconMenu text="Ban" icon={<Delete className="size-4" />} /><kbd className="hidden rounded bg-red-100 px-2 py-0.5 text-xs font-light text-red-600 transition-all duration-75 group-hover:bg-red-500 group-hover:text-white sm:inline-block">B</kbd>diff --git a/apps/web/ui/links/link-not-found.tsx b/apps/web/ui/links/link-not-found.tsxindex ad492fe845..882bbe758e 100644--- a/apps/web/ui/links/link-not-found.tsx+++ b/apps/web/ui/links/link-not-found.tsx@@ -10,8 +10,8 @@ export default function LinkNotFound() {Link Not Found</h1><p className="z-10 max-w-sm text-center text-sm text-neutral-600">- Bummer! The link you are looking for does not exist. You either typed in- the wrong URL or don't have access to this link.+ Bummer! The link you are looking for does not exist. Adjust your filters+ to yield more results.</p><imgsrc="https://assets.dub.co/misc/not-found.svg"diff --git a/apps/web/ui/links/links-container.tsx b/apps/web/ui/links/links-container.tsxindex d7bd88f89b..12054b1f91 100644--- a/apps/web/ui/links/links-container.tsx+++ b/apps/web/ui/links/links-container.tsx@@ -23,7 +23,6 @@ import { AnimatedEmptyState } from "../shared/animated-empty-state";import ArchivedLinksHint from "./archived-links-hint";import { LinkCard } from "./link-card";import LinkCardPlaceholder from "./link-card-placeholder";-import LinkNotFound from "./link-not-found";import { LinksDisplayContext } from "./links-display-provider";export type ResponseLink = ExpandedLinkProps & {@@ -112,12 +111,14 @@ function LinksList({))}</CardList></LinksListContext.Provider>- ) : isFiltered ? (- <LinkNotFound />) : (<AnimatedEmptyState- title="No links found"- description="Start creating short links for your marketing campaigns, referral programs, and more."+ title={isFiltered ? "No links found" : "No links yet"}+ description={+ isFiltered+ ? "Bummer! There are no links that match your filters. Adjust your filters to yield more results."+ : "Start creating short links for your marketing campaigns, referral programs, and more."+ }cardContent={<><Hyperlink className="size-4 text-neutral-700" />@@ -127,13 +128,15 @@ function LinksList({</div></>}- addButton={- <div>- <CreateLinkButton />- </div>- }- learnMoreHref="https://dub.co/help/article/how-to-create-link"- learnMoreClassName="h-10"+ {...(!isFiltered && {+ addButton: (+ <div>+ <CreateLinkButton />+ </div>+ ),+ learnMoreHref: "https://dub.co/help/article/how-to-create-link",+ learnMoreClassName: "h-10",+ })}/>)}diff --git a/apps/web/ui/modals/link-builder/index.tsx b/apps/web/ui/modals/link-builder/index.tsxindex 00c4c9f1b7..1acc33d6fe 100644--- a/apps/web/ui/modals/link-builder/index.tsx+++ b/apps/web/ui/modals/link-builder/index.tsx@@ -183,6 +183,12 @@ function LinkBuilderInner({useEffect(() => {if (key?.endsWith("-copy")) keyRef.current?.select();}, []);+ const searchParamsFolderId = searchParams.get("folderId");+ useEffect(() => {+ if (searchParamsFolderId) {+ setValue("folderId", searchParamsFolderId);+ }+ }, [searchParamsFolderId]);const { domains, loading, primaryDomain } = useAvailableDomains({currentDomain: domain,diff --git a/packages/ui/src/icons/nucleo/folder-bookmark.tsx b/packages/ui/src/icons/nucleo/folder-bookmark.tsxindex e0973bad60..2205f6a561 100644--- a/packages/ui/src/icons/nucleo/folder-bookmark.tsx+++ b/packages/ui/src/icons/nucleo/folder-bookmark.tsx@@ -8,11 +8,12 @@ export function FolderBookmark(props: SVGProps<SVGSVGElement>) {height="16"fill="none"viewBox="0 0 16 16"- {...props}+ className={props.className}><g clipPath="url(#clip0_430_4502)"><g- stroke="#166534"+ fill="none"+ stroke="currentColor"strokeLinecap="round"strokeLinejoin="round"strokeWidth="1.5"diff --git a/packages/ui/src/icons/nucleo/folder-lock.tsx b/packages/ui/src/icons/nucleo/folder-lock.tsxindex ca366a3055..16c23809ad 100644--- a/packages/ui/src/icons/nucleo/folder-lock.tsx+++ b/packages/ui/src/icons/nucleo/folder-lock.tsx@@ -12,7 +12,7 @@ export function FolderLock(props: SVGProps<SVGSVGElement>) {><g clipPath="url(#clip0_714_1369)"><g- stroke="#9A3412"+ stroke="currentColor"strokeLinecap="round"strokeLinejoin="round"strokeWidth="1.5"diff --git a/packages/ui/src/icons/nucleo/folder-plus.tsx b/packages/ui/src/icons/nucleo/folder-plus.tsxindex 60d8360250..bcd2289387 100644--- a/packages/ui/src/icons/nucleo/folder-plus.tsx+++ b/packages/ui/src/icons/nucleo/folder-plus.tsx@@ -12,7 +12,7 @@ export function FolderPlus(props: SVGProps<SVGSVGElement>) {><g clipPath="url(#clip0_791_85)"><g- stroke="#1F2937"+ stroke="currentColor"strokeLinecap="round"strokeLinejoin="round"strokeWidth="1.5"diff --git a/packages/ui/src/icons/nucleo/folder-shield.tsx b/packages/ui/src/icons/nucleo/folder-shield.tsxindex eb1268bdd3..94dbccec69 100644--- a/packages/ui/src/icons/nucleo/folder-shield.tsx+++ b/packages/ui/src/icons/nucleo/folder-shield.tsx@@ -12,7 +12,7 @@ export function FolderShield(props: SVGProps<SVGSVGElement>) {><g clipPath="url(#clip0_563_3026)"><g- stroke="#3730A3"+ stroke="currentColor"strokeLinecap="round"strokeLinejoin="round"strokeWidth="1.5"