The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
More folder updates
Tim Wilson052f14058d11
diff --git a/apps/web/app/api/folders/[folderId]/route.ts b/apps/web/app/api/folders/[folderId]/route.tsindex 238e116c3f..702ae82d9c 100644--- a/apps/web/app/api/folders/[folderId]/route.ts+++ b/apps/web/app/api/folders/[folderId]/route.ts@@ -42,7 +42,7 @@ export const PATCH = withWorkspace(async ({ req, params, workspace, session }) => {const { folderId } = params;- const { name, accessLevel } = updateFolderSchema.parse(+ const { name, description, accessLevel } = updateFolderSchema.parse(await parseRequestBody(req),);@@ -76,6 +76,7 @@ export const PATCH = withWorkspace(},data: {name,+ description,accessLevel,},});diff --git a/apps/web/app/api/folders/route.ts b/apps/web/app/api/folders/route.tsindex 5547b583c8..8b31096c03 100644--- a/apps/web/app/api/folders/route.ts+++ b/apps/web/app/api/folders/route.ts@@ -48,7 +48,7 @@ export const GET = withWorkspace(// POST /api/folders - create a folder for a workspaceexport const POST = withWorkspace(async ({ req, workspace, headers, session }) => {- const { name, accessLevel } = createFolderSchema.parse(+ const { name, description, accessLevel } = createFolderSchema.parse(await parseRequestBody(req),);@@ -87,6 +87,7 @@ export const POST = withWorkspace(id: createId({ prefix: "fold_" }),projectId: workspace.id,name,+ description,accessLevel,users: {create: {diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/folders/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/folders/page-client.tsxindex 5fd461925d..a0a33f9609 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/folders/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/folders/page-client.tsx@@ -23,8 +23,11 @@ export const FoldersPageClient = () => {const searchParams = useSearchParams();const { queryParams } = useRouterStuff();- const { folders, loading, isValidating } = useFolders({+ const { folders, isValidating } = useFolders({includeParams: ["search", "page"],+ options: {+ keepPreviousData: true,+ },});const { data: foldersCount } = useFoldersCount({@@ -55,7 +58,7 @@ export const FoldersPageClient = () => {</div><div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">- {loading ? (+ {!folders ? (Array.from({ length: 6 }).map((_, idx) => (<FolderCardPlaceholder key={idx} />))diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsxindex 1448add3f9..18b157c557 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx@@ -87,7 +87,7 @@ export function WorkspaceLinksPageControls() {<><LinkBuilder /><div className="hidden sm:block">- <CreateLinkButton />+ <CreateLinkButton className="h-9" /></div></>);diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex 06ebaf0ac3..acaf4afc16 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -536,7 +536,10 @@ export type FolderWithPermissions = {permissions: FolderPermission[];};-export type FolderSummary = Pick<Folder, "id" | "name" | "accessLevel">;+export type FolderSummary = Pick<+ Folder,+ "id" | "name" | "description" | "accessLevel"+>;export type RewardProps = z.infer<typeof RewardSchema>;diff --git a/apps/web/ui/folders/add-folder-form.tsx b/apps/web/ui/folders/add-folder-form.tsxindex 3cc047ef38..e106c3ad37 100644--- a/apps/web/ui/folders/add-folder-form.tsx+++ b/apps/web/ui/folders/add-folder-form.tsx@@ -101,7 +101,7 @@ export const AddFolderForm = ({ onSuccess, onCancel }: AddFolderFormProps) => {{step === 1 ? (<div className="mt-6"><label>- <span className="text-content-emphasis text-sm font-medium">+ <span className="text-content-emphasis block text-sm font-medium">Name</span><div className="mt-2 flex rounded-md">@@ -126,8 +126,9 @@ export const AddFolderForm = ({ onSuccess, onCancel }: AddFolderFormProps) => {</label><label className="mt-6 block">- <span className="text-content-emphasis text-sm font-medium">- Description+ <span className="text-content-emphasis block text-sm font-medium">+ Description{" "}+ <span className="text-content-subtle">(optional)</span></span><textareaclassName="mt-2 block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"diff --git a/apps/web/ui/folders/edit-folder-form.tsx b/apps/web/ui/folders/edit-folder-form.tsxnew file mode 100644index 0000000000..76c1d80959--- /dev/null+++ b/apps/web/ui/folders/edit-folder-form.tsx@@ -0,0 +1,96 @@+import { mutatePrefix } from "@/lib/swr/mutate";+import useWorkspace from "@/lib/swr/use-workspace";+import { Folder } from "@/lib/types";+import {+ FOLDER_MAX_DESCRIPTION_LENGTH,+ updateFolderSchema,+} from "@/lib/zod/schemas/folders";+import { Button } from "@dub/ui";+import { useForm } from "react-hook-form";+import { toast } from "sonner";+import { z } from "zod";+import { MaxCharactersCounter } from "../shared/max-characters-counter";++export function EditFolderForm({+ folder,+}: {+ folder: Pick<Folder, "id" | "name" | "description">;+}) {+ const { id: workspaceId } = useWorkspace();++ const {+ handleSubmit,+ register,+ control,+ reset,+ formState: { isDirty, isSubmitting },+ } = useForm<Pick<z.infer<typeof updateFolderSchema>, "name" | "description">>(+ {+ defaultValues: {+ name: folder.name,+ description: folder.description,+ },+ },+ );++ return (+ <form+ onSubmit={handleSubmit(async (data) => {+ const response = await fetch(+ `/api/folders/${folder.id}?workspaceId=${workspaceId}`,+ {+ method: "PATCH",+ body: JSON.stringify(data),+ },+ );++ if (!response.ok) {+ const { error } = await response.json();+ toast.error(error.message);+ return;+ }++ reset(data);+ mutatePrefix("/api/folders");+ toast.success("Folder updated successfully!");+ })}+ >+ <label>+ <span className="text-content-emphasis block text-sm font-medium">+ Name+ </span>+ <div className="mt-2 flex rounded-md">+ <input+ type="text"+ className="block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"+ placeholder="Acme Links"+ {...register("name", { required: true })}+ />+ </div>+ </label>++ <label className="mt-6 block">+ <span className="text-content-emphasis block text-sm font-medium">+ Description <span className="text-content-subtle">(optional)</span>+ </span>+ <textarea+ className="mt-2 block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"+ {...register("description")}+ />+ <MaxCharactersCounter+ control={control}+ name="description"+ maxLength={FOLDER_MAX_DESCRIPTION_LENGTH}+ />+ </label>++ <Button+ type="submit"+ className="mt-6 h-8 w-fit rounded-lg px-3"+ disabled={!isDirty}+ loading={isSubmitting}+ text="Save changes"+ />+ </form>+ );+}diff --git a/apps/web/ui/folders/edit-folder-panel.tsx b/apps/web/ui/folders/edit-folder-panel.tsxnew file mode 100644index 0000000000..a50dc290b7--- /dev/null+++ b/apps/web/ui/folders/edit-folder-panel.tsx@@ -0,0 +1,336 @@+import { updateUserRoleInFolder } from "@/lib/actions/folders/update-folder-user-role";+import {+ FOLDER_USER_ROLE,+ FOLDER_WORKSPACE_ACCESS,+} from "@/lib/folder/constants";+import { getPlanCapabilities } from "@/lib/plan-capabilities";+import {+ useCheckFolderPermission,+ useFolderPermissions,+} from "@/lib/swr/use-folder-permissions";+import { useFolderUsers } from "@/lib/swr/use-folder-users";+import useWorkspace from "@/lib/swr/use-workspace";+import { Folder, FolderUser } from "@/lib/types";+import { FolderUserRole } from "@dub/prisma/client";+import {+ Avatar,+ BlurImage,+ Button,+ Sheet,+ Tooltip,+ TooltipContent,+} from "@dub/ui";+import { UserCheck } from "@dub/ui/icons";+import { cn, OG_AVATAR_URL } from "@dub/utils";+import { useSession } from "next-auth/react";+import { useAction } from "next-safe-action/hooks";+import { useState } from "react";+import { toast } from "sonner";+import { mutate } from "swr";+import { AnimatedEmptyState } from "../shared/animated-empty-state";+import { X } from "../shared/icons";+import { EditFolderForm } from "./edit-folder-form";++interface EditFolderPanelProps {+ showPanel: boolean;+ setShowPanel: (showPanel: boolean) => void;+ folder: Pick<Folder, "id" | "name" | "description" | "accessLevel">;+ onSuccess?: () => void;+}++const EditFolderPanelContent = ({+ showPanel,+ folder,+}: EditFolderPanelProps) => {+ const { id: workspaceId, slug, logo, name, plan } = useWorkspace();++ const [isUpdating, setIsUpdating] = useState(false);+ const [workspaceAccessLevel, setWorkspaceAccessLevel] = useState<string>();++ const { isLoading: isLoadingPermissions } = useFolderPermissions();+ const canUpdateFolder = useCheckFolderPermission(folder.id, "folders.write");++ const { canManageFolderPermissions } = getPlanCapabilities(plan);++ const {+ users,+ isLoading: isUsersLoading,+ isValidating: isUsersValidating,+ } = useFolderUsers({ folderId: folder.id, enabled: showPanel });++ const updateWorkspaceAccessLevel = async (accessLevel: string) => {+ setIsUpdating(true);+ setWorkspaceAccessLevel(accessLevel);++ const response = await fetch(+ `/api/folders/${folder.id}?workspaceId=${workspaceId}`,+ {+ method: "PATCH",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ accessLevel: accessLevel === "" ? null : accessLevel,+ }),+ },+ );++ setIsUpdating(false);++ if (!response.ok) {+ const { error } = await response.json();+ toast.error(error.message);+ return;+ }++ toast.success("Workspace access updated!");+ await mutate(+ (key) => typeof key === "string" && key.startsWith(`/api/folders`),+ );+ };++ const selectDropdown = (+ <select+ className={cn(+ "appearance-none rounded-md border border-neutral-200 bg-white pl-3 pr-8 text-sm text-neutral-900 focus:border-neutral-300 focus:ring-neutral-300",+ !canUpdateFolder && "cursor-not-allowed bg-neutral-100",+ )}+ value={workspaceAccessLevel || folder?.accessLevel || ""}+ disabled={+ isUpdating ||+ isLoadingPermissions ||+ !canUpdateFolder ||+ !canManageFolderPermissions+ }+ onChange={(e) => updateWorkspaceAccessLevel(e.target.value)}+ >+ {Object.keys(FOLDER_WORKSPACE_ACCESS).map((access) => (+ <option value={access} key={access}>+ {FOLDER_WORKSPACE_ACCESS[access]}+ </option>+ ))}+ <option value="" key="no-access">+ No access+ </option>+ </select>+ );++ return (+ <>+ <div className="sticky top-0 z-10 border-b border-neutral-200 bg-white">+ <div className="flex h-16 items-center justify-between px-6 py-4">+ <Sheet.Title className="text-lg font-semibold">+ Edit folder+ </Sheet.Title>+ <Sheet.Close asChild>+ <Button+ variant="outline"+ icon={<X className="size-5" />}+ className="h-auto w-fit p-1"+ />+ </Sheet.Close>+ </div>+ </div>+ <div className="scrollbar-hide flex size-full grow flex-col overflow-y-auto bg-zinc-50">+ <div className="bg-white px-8 py-6">+ <EditFolderForm folder={folder} />+ </div>+ <div className="border-border-subtle border-t px-8 py-6">+ {/* Workspace-level access */}+ <div>+ <span className="text-sm font-medium text-neutral-900">+ Workspace+ </span>+ <div className="relative mt-3 flex items-center justify-between gap-4">+ <div className="flex min-w-12 items-center gap-2">+ <BlurImage+ src={logo || `${OG_AVATAR_URL}${name}`}+ alt={name || "Workspace logo"}+ className="size-8 shrink-0 overflow-hidden rounded-full"+ width={32}+ height={32}+ />+ <span className="truncate whitespace-nowrap text-sm text-neutral-800">+ {name}+ </span>+ </div>++ {canManageFolderPermissions ? (+ selectDropdown+ ) : (+ <Tooltip+ content={+ <TooltipContent+ title="You can only set custom folder permissions on a Business plan and above."+ cta="Upgrade to Business"+ href={`/${slug}/upgrade`}+ target="_blank"+ />+ }+ align="end"+ >+ {selectDropdown}+ </Tooltip>+ )}+ </div>+ </div>++ {/* Users */}+ <div className="mt-4">+ <span className="text-sm font-medium text-neutral-900">+ Folder Users+ </span>+ {!canManageFolderPermissions ? (+ <AnimatedEmptyState+ title="Folder permissions"+ description="Add and manage users permissions to this folder"+ cardContent={+ <>+ <UserCheck className="size-4 text-neutral-700" />+ <div className="h-2.5 w-28 min-w-0 rounded-sm bg-neutral-200" />+ </>+ }+ className="border-none"+ learnMoreHref={`/${slug}/upgrade`}+ learnMoreText="Upgrade to Business"+ />+ ) : (+ <div className="mt-4 grid grid-cols-[minmax(0,1fr)] gap-3">+ {isUsersValidating || isUsersLoading || false+ ? [...Array(3)].map((_, i) => (+ <FolderUserPlaceholder key={i} />+ ))+ : folder &&+ users?.map((user) => (+ <FolderUserRow+ key={user.id}+ user={user}+ folder={folder}+ />+ ))}+ </div>+ )}+ </div>+ </div>+ </div>+ </>+ );+};++const EditFolderPanel = (props: EditFolderPanelProps) => {+ return (+ <Sheet open={props.showPanel} onOpenChange={props.setShowPanel}>+ <EditFolderPanelContent {...props} />+ </Sheet>+ );+};++const FolderUserRow = ({+ user,+ folder,+}: {+ user: FolderUser;+ folder: Pick<Folder, "id" | "name" | "accessLevel">;+}) => {+ const { data: session } = useSession();+ const { id: workspaceId } = useWorkspace();+ const [role, setRole] = useState<FolderUserRole>(user.role);++ const canUpdateRole = useCheckFolderPermission(+ folder.id,+ "folders.users.write",+ );++ const { executeAsync, isPending } = useAction(updateUserRoleInFolder, {+ onSuccess: () => {+ toast.success("Role updated!");+ },+ onError: ({ error }) => {+ toast.error(error.serverError);+ },+ });++ const isCurrentUser = user.email === session?.user?.email;+ const disableRoleUpdate = !canUpdateRole || isPending || isCurrentUser;++ return (+ <div key={user.id} className="flex items-center justify-between gap-3">+ <div className="flex min-w-12 items-center gap-3">+ <Avatar user={user} className="size-8" />+ <div className="min-w-0">+ <h3 className="truncate text-xs font-medium text-neutral-800">+ {user.name || user.email}+ </h3>+ <p className="truncate text-xs font-normal text-neutral-400">+ {user.email}+ </p>+ </div>+ </div>++ <div className="flex items-center gap-3">+ <select+ className={cn(+ "cursor-pointer appearance-none rounded-md border border-neutral-200 bg-white pl-3 pr-8 text-sm text-neutral-900 focus:border-neutral-300 focus:ring-neutral-300",+ disableRoleUpdate && "cursor-not-allowed bg-neutral-100",+ )}+ value={role === null ? "" : role}+ disabled={disableRoleUpdate}+ onChange={(e) => {+ if (!folder || !workspaceId) {+ return;+ }++ const role = (e.target.value as FolderUserRole) || null;++ executeAsync({+ workspaceId,+ folderId: folder.id,+ userId: user.id,+ role,+ });++ setRole(role);+ }}+ >+ {Object.keys(FOLDER_USER_ROLE).map((role) => (+ <option value={role} key={role}>+ {FOLDER_USER_ROLE[role]}+ </option>+ ))}++ <option value="" key="no-access">+ No access+ </option>+ </select>+ </div>+ </div>+ );+};++const FolderUserPlaceholder = () => (+ <div className="flex items-center justify-between gap-3">+ <div className="flex items-center gap-3">+ <div className="size-8 animate-pulse rounded-full bg-neutral-200" />+ <div className="flex flex-col">+ <div className="h-4 w-24 animate-pulse rounded bg-neutral-200" />+ <div className="mt-1 h-3 w-32 animate-pulse rounded bg-neutral-200" />+ </div>+ </div>+ <div className="my-px h-9 w-24 animate-pulse rounded bg-neutral-200" />+ </div>+);++export function useEditFolderPanel(+ folder: Pick<Folder, "id" | "name" | "description" | "accessLevel">,+) {+ const [showEditFolderPanel, setShowEditFolderPanel] = useState(false);++ return {+ setShowEditFolderPanel,+ editFolderPanel: (+ <EditFolderPanel+ showPanel={showEditFolderPanel}+ setShowPanel={setShowEditFolderPanel}+ folder={folder}+ />+ ),+ };+}diff --git a/apps/web/ui/folders/folder-actions.tsx b/apps/web/ui/folders/folder-actions.tsxindex 8d78bfd67c..a6ca5988e2 100644--- a/apps/web/ui/folders/folder-actions.tsx+++ b/apps/web/ui/folders/folder-actions.tsx@@ -21,7 +21,7 @@ import { useDeleteFolderModal } from "../modals/delete-folder-modal";import { useRenameFolderModal } from "../modals/rename-folder-modal";import { useDefaultFolderModal } from "../modals/set-default-folder-modal";import { Delete, ThreeDots } from "../shared/icons";-import { useFolderPermissionsPanel } from "./folder-permissions-panel";+import { useEditFolderPanel } from "./edit-folder-panel";import { isDefaultFolder } from "./utils";export const FolderActions = ({@@ -33,6 +33,7 @@ export const FolderActions = ({onDelete?: () => void;className?: string;}) => {+ console.log(folder);const router = useRouter();const [openPopover, setOpenPopover] = useState(false);const { slug: workspaceSlug, defaultFolderId } = useWorkspace();@@ -50,8 +51,10 @@ export const FolderActions = ({folder,});- const { folderPermissionsPanel, setShowFolderPermissionsPanel } =- useFolderPermissionsPanel(folder);+ const {+ editFolderPanel: folderPermissionsPanel,+ setShowEditFolderPanel: setShowFolderPermissionsPanel,+ } = useEditFolderPanel(folder);const copyFolderId = () => {toast.promise(copyToClipboard(folder.id), {@@ -216,7 +219,7 @@ export const FolderActions = ({className,)}onClick={() => setOpenPopover(true)}- icon={<ThreeDots className="size-4 shrink-0 text-neutral-500" />}+ icon={<ThreeDots className="size-4 shrink-0 text-neutral-600" />}/></Popover></>diff --git a/apps/web/ui/folders/folder-permissions-panel.tsx b/apps/web/ui/folders/folder-permissions-panel.tsxdeleted file mode 100644index 0da41c968b..0000000000--- a/apps/web/ui/folders/folder-permissions-panel.tsx+++ /dev/null@@ -1,376 +0,0 @@-import { updateUserRoleInFolder } from "@/lib/actions/folders/update-folder-user-role";-import {- FOLDER_USER_ROLE,- FOLDER_WORKSPACE_ACCESS,-} from "@/lib/folder/constants";-import { getPlanCapabilities } from "@/lib/plan-capabilities";-import { useFolderLinkCount } from "@/lib/swr/use-folder-link-count";-import {- useCheckFolderPermission,- useFolderPermissions,-} from "@/lib/swr/use-folder-permissions";-import { useFolderUsers } from "@/lib/swr/use-folder-users";-import useWorkspace from "@/lib/swr/use-workspace";-import { Folder, FolderUser } from "@/lib/types";-import { FolderUserRole } from "@dub/prisma/client";-import { Avatar, BlurImage, Button, Tooltip, TooltipContent } from "@dub/ui";-import { Globe, UserCheck } from "@dub/ui/icons";-import { cn, nFormatter, OG_AVATAR_URL, pluralize } from "@dub/utils";-import { useSession } from "next-auth/react";-import { useAction } from "next-safe-action/hooks";-import { useState } from "react";-import { toast } from "sonner";-import { mutate } from "swr";-import { Drawer } from "vaul";-import { AnimatedEmptyState } from "../shared/animated-empty-state";-import { X } from "../shared/icons";-import { FolderIcon } from "./folder-icon";-import { RequestFolderEditAccessButton } from "./request-edit-button";--// TODO-// Use the new `<Sheet />` component--interface FolderPermissionsPanelProps {- showPanel: boolean;- setShowPanel: (showPanel: boolean) => void;- folder: Pick<Folder, "id" | "name" | "accessLevel">;- onSuccess?: () => void;-}--const FolderPermissionsPanel = ({- showPanel,- setShowPanel,- folder,-}: FolderPermissionsPanelProps) => {- const { id: workspaceId, slug, logo, name, plan } = useWorkspace();-- const [isUpdating, setIsUpdating] = useState(false);- const [workspaceAccessLevel, setWorkspaceAccessLevel] = useState<string>();-- const { isLoading: isLoadingPermissions } = useFolderPermissions();- const canUpdateFolder = useCheckFolderPermission(folder.id, "folders.write");- const canCreateLinks = useCheckFolderPermission(- folder.id,- "folders.links.write",- );-- const { canManageFolderPermissions } = getPlanCapabilities(plan);-- const {- users,- isLoading: isUsersLoading,- isValidating: isUsersValidating,- } = useFolderUsers({ folderId: folder.id, enabled: showPanel });-- const { folderLinkCount } = useFolderLinkCount({ folderId: folder.id });-- const updateWorkspaceAccessLevel = async (accessLevel: string) => {- setIsUpdating(true);- setWorkspaceAccessLevel(accessLevel);-- const response = await fetch(- `/api/folders/${folder.id}?workspaceId=${workspaceId}`,- {- method: "PATCH",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({- accessLevel: accessLevel === "" ? null : accessLevel,- }),- },- );-- setIsUpdating(false);-- if (!response.ok) {- const { error } = await response.json();- toast.error(error.message);- return;- }-- toast.success("Workspace access updated!");- await mutate(- (key) => typeof key === "string" && key.startsWith(`/api/folders`),- );- };-- const selectDropdown = (- <select- className={cn(- "appearance-none rounded-md border border-neutral-200 bg-white pl-3 pr-8 text-sm text-neutral-900 focus:border-neutral-300 focus:ring-neutral-300",- !canUpdateFolder && "cursor-not-allowed bg-neutral-100",- )}- value={workspaceAccessLevel || folder?.accessLevel || ""}- disabled={- isUpdating ||- isLoadingPermissions ||- !canUpdateFolder ||- !canManageFolderPermissions- }- onChange={(e) => updateWorkspaceAccessLevel(e.target.value)}- >- {Object.keys(FOLDER_WORKSPACE_ACCESS).map((access) => (- <option value={access} key={access}>- {FOLDER_WORKSPACE_ACCESS[access]}- </option>- ))}- <option value="" key="no-access">- No access- </option>- </select>- );-- return (- <Drawer.Root open={showPanel} onOpenChange={setShowPanel} direction="right">- <Drawer.Portal>- <Drawer.Overlay className="fixed inset-0 bg-black/20" />- <Drawer.Content- className="fixed bottom-2 right-2 top-2 z-10 flex w-[calc(100%-16px)] outline-none md:w-[540px]"- style={- // 8px between edge of screen and drawer- { "--initial-transform": "calc(100% + 8px)" } as React.CSSProperties- }- >- <div className="scrollbar-hide flex size-full grow flex-col overflow-y-auto rounded-lg bg-zinc-50">- <div className="flex items-center justify-between border-b border-neutral-200 px-8 py-5">- <Drawer.Title className="text-xl font-medium text-zinc-900">- Folder permissions- </Drawer.Title>- <Drawer.Description className="sr-only">- Configure permissions for the "{folder.name}" folder- </Drawer.Description>- <Drawer.Close asChild>- <Button- variant="outline"- icon={<X className="size-5" />}- className="h-auto w-fit p-1"- />- </Drawer.Close>- </div>- <div className="px-8 py-6">- <div className="flex flex-col justify-between rounded-xl border border-neutral-200 bg-white px-5 py-4 sm:h-36">- <div className="flex items-start justify-between">- <FolderIcon folder={folder} />- {!isLoadingPermissions && !canCreateLinks && (- <RequestFolderEditAccessButton- folderId={folder.id}- workspaceId={workspaceId!}- />- )}- </div>- <div>- <span className="flex items-center justify-start gap-1.5 text-sm font-medium text-neutral-900">- <span className="truncate">{folder.name}</span>- {folder.id === "unsorted" && (- <div className="rounded bg-neutral-100 p-1">- <div className="text-xs font-normal text-black">- Unsorted- </div>- </div>- )}- </span>-- <div className="mt-1.5 flex items-center gap-1 text-neutral-500">- <Globe className="size-3.5" />- <span className="text-sm font-normal">- {nFormatter(folderLinkCount, { full: true })}{" "}- {pluralize("link", folderLinkCount)}- </span>- </div>- </div>- </div>-- {/* Workspace-level access */}- <div className="mt-6">- <span className="text-sm font-medium text-neutral-900">- Workspace- </span>- <div className="relative mt-3 flex items-center justify-between gap-4">- <div className="flex min-w-12 items-center gap-2">- <BlurImage- src={logo || `${OG_AVATAR_URL}${name}`}- alt={name || "Workspace logo"}- className="size-8 shrink-0 overflow-hidden rounded-full"- width={32}- height={32}- />- <span className="truncate whitespace-nowrap text-sm text-neutral-800">- {name}- </span>- </div>-- {canManageFolderPermissions ? (- selectDropdown- ) : (- <Tooltip- content={- <TooltipContent- title="You can only set custom folder permissions on a Business plan and above."- cta="Upgrade to Business"- href={`/${slug}/upgrade`}- target="_blank"- />- }- align="end"- >- {selectDropdown}- </Tooltip>- )}- </div>- </div>-- {/* Users */}- <div className="mt-4">- <span className="text-sm font-medium text-neutral-900">- Folder Users- </span>- {!canManageFolderPermissions ? (- <AnimatedEmptyState- title="Folder permissions"- description="Add and manage users permissions to this folder"- cardContent={- <>- <UserCheck className="size-4 text-neutral-700" />- <div className="h-2.5 w-28 min-w-0 rounded-sm bg-neutral-200" />- </>- }- className="border-none"- learnMoreHref={`/${slug}/upgrade`}- learnMoreText="Upgrade to Business"- />- ) : (- <div className="mt-4 grid grid-cols-[minmax(0,1fr)] gap-3">- {isUsersValidating || isUsersLoading || false- ? [...Array(3)].map((_, i) => (- <FolderUserPlaceholder key={i} />- ))- : folder &&- users?.map((user) => (- <FolderUserRow- key={user.id}- user={user}- folder={folder}- />- ))}- </div>- )}- </div>- </div>- </div>- </Drawer.Content>- </Drawer.Portal>- </Drawer.Root>- );-};--const FolderUserRow = ({- user,- folder,-}: {- user: FolderUser;- folder: Pick<Folder, "id" | "name" | "accessLevel">;-}) => {- const { data: session } = useSession();- const { id: workspaceId } = useWorkspace();- const [role, setRole] = useState<FolderUserRole>(user.role);-- const canUpdateRole = useCheckFolderPermission(- folder.id,- "folders.users.write",- );-- const { executeAsync, isPending } = useAction(updateUserRoleInFolder, {- onSuccess: () => {- toast.success("Role updated!");- },- onError: ({ error }) => {- toast.error(error.serverError);- },- });-- const isCurrentUser = user.email === session?.user?.email;- const disableRoleUpdate = !canUpdateRole || isPending || isCurrentUser;-- return (- <div key={user.id} className="flex items-center justify-between gap-3">- <div className="flex min-w-12 items-center gap-3">- <Avatar user={user} className="size-8" />- <div className="min-w-0">- <h3 className="truncate text-xs font-medium text-neutral-800">- {user.name || user.email}- </h3>- <p className="truncate text-xs font-normal text-neutral-400">- {user.email}- </p>- </div>- </div>-- <div className="flex items-center gap-3">- <select- className={cn(- "cursor-pointer appearance-none rounded-md border border-neutral-200 bg-white pl-3 pr-8 text-sm text-neutral-900 focus:border-neutral-300 focus:ring-neutral-300",- disableRoleUpdate && "cursor-not-allowed bg-neutral-100",- )}- value={role === null ? "" : role}- disabled={disableRoleUpdate}- onChange={(e) => {- if (!folder || !workspaceId) {- return;- }-- const role = (e.target.value as FolderUserRole) || null;-- executeAsync({- workspaceId,- folderId: folder.id,- userId: user.id,- role,- });-- setRole(role);- }}- >- {Object.keys(FOLDER_USER_ROLE).map((role) => (- <option value={role} key={role}>- {FOLDER_USER_ROLE[role]}- </option>- ))}-- <option value="" key="no-access">- No access- </option>- </select>- </div>- </div>- );-};--const FolderUserPlaceholder = () => (- <div className="flex items-center justify-between gap-3">- <div className="flex items-center gap-3">- <div className="size-8 animate-pulse rounded-full bg-neutral-200" />- <div className="flex flex-col">- <div className="h-4 w-24 animate-pulse rounded bg-neutral-200" />- <div className="mt-1 h-3 w-32 animate-pulse rounded bg-neutral-200" />- </div>- </div>- <div className="my-px h-9 w-24 animate-pulse rounded bg-neutral-200" />- </div>-);--export function useFolderPermissionsPanel(- folder: Pick<Folder, "id" | "name" | "accessLevel">,-) {- const [showFolderPermissionsPanel, setShowFolderPermissionsPanel] =- useState(false);-- return {- setShowFolderPermissionsPanel,- folderPermissionsPanel: (- <FolderPermissionsPanel- showPanel={showFolderPermissionsPanel}- setShowPanel={setShowFolderPermissionsPanel}- folder={folder}- />- ),- };-}diff --git a/apps/web/ui/layout/page-content/page-content-with-side-panel.tsx b/apps/web/ui/layout/page-content/page-content-with-side-panel.tsxindex 02bfd6c05a..22b8311e79 100644--- a/apps/web/ui/layout/page-content/page-content-with-side-panel.tsx+++ b/apps/web/ui/layout/page-content/page-content-with-side-panel.tsx@@ -85,7 +85,8 @@ export function PageContentWithSidePanel({className={cn("absolute right-0 top-0 h-full min-h-0 w-0 overflow-hidden bg-white shadow-lg transition-[width]","@[960px]/page-content:shadow-none @[960px]/page-content:relative",- isSidePanelOpen && "w-full sm:w-[340px]",+ isSidePanelOpen &&+ "@[960px]/page-content:z-auto z-10 w-full sm:w-[340px]",)}><div className="border-border-subtle flex size-full min-h-0 w-full flex-col border-l sm:w-[340px]">