From 0198a29fbe971cfda9ad0381aab42216d4e184d8 Mon Sep 17 00:00:00 2001 From: Kenneth Date: Sun, 28 Dec 2025 22:53:43 +0000 Subject: [PATCH] feat(drive-web): also display expired share links --- .../src/sharing/item-share-dialog.tsx | 175 +++++++++++++----- 1 file changed, 127 insertions(+), 48 deletions(-) diff --git a/apps/drive-web/src/sharing/item-share-dialog.tsx b/apps/drive-web/src/sharing/item-share-dialog.tsx index 5d0a72e..1625074 100644 --- a/apps/drive-web/src/sharing/item-share-dialog.tsx +++ b/apps/drive-web/src/sharing/item-share-dialog.tsx @@ -10,8 +10,10 @@ import { CheckIcon, CopyIcon, EllipsisIcon, + Link2OffIcon, LinkIcon, LockKeyholeIcon, + PlusIcon, } from "lucide-react" import type React from "react" import { createContext, useContext, useMemo, useRef, useState } from "react" @@ -19,6 +21,7 @@ import { CrossfadeIcon, type CrossfadeIconHandle, } from "@/components/crossfade-icon" +import { DateInput, type DateInputHandle } from "@/components/date-input" import { Button } from "@/components/ui/button" import { ButtonGroup } from "@/components/ui/button-group" import { @@ -36,7 +39,27 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { Input } from "@/components/ui/input" +import { Kbd } from "@/components/ui/kbd" +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover" +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select" +import { Separator } from "@/components/ui/separator" +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/tooltip" import { copyToClipboardMutation } from "@/lib/clipboard" +import { cn } from "@/lib/utils" import { createShareMutationAtom, deleteShareMutationAtom, @@ -45,28 +68,6 @@ import { updateShareMutationAtom, } from "@/sharing/api" import type { DirectoryItem } from "@/vfs/vfs" -import { DateInput, type DateInputHandle } from "../components/date-input" -import { Checkbox } from "../components/ui/checkbox" -import { Kbd } from "../components/ui/kbd" -import { Label } from "../components/ui/label" -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "../components/ui/popover" -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "../components/ui/select" -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "../components/ui/tooltip" -import { cn } from "../lib/utils" import type { Share } from "./share" type ItemShareDialogProps = { @@ -120,14 +121,24 @@ function PublicAccessSection({ item }: { item: DirectoryItem }) { const fileSharesQuery = useAtomValue(fileSharesQueryAtom(item.id)) const directorySharesQuery = useAtomValue(directorySharesQueryAtom(item.id)) + const sortShares = (shares: Share[]) => + [...shares].sort((a, b) => { + if (a.expiresAt && b.expiresAt) { + return a.expiresAt.getTime() - b.expiresAt.getTime() + } + return 0 + }) + const { data: fileShares, isLoading: isLoadingFileShares } = useQuery({ ...fileSharesQuery, enabled: item.kind === "file", + select: sortShares, }) const { data: directoryShares, isLoading: isLoadingDirectoryShares } = useQuery({ ...directorySharesQuery, enabled: item.kind === "directory", + select: sortShares, }) let shares: Share[] = [] @@ -157,10 +168,12 @@ function PublicAccessSection({ item }: { item: DirectoryItem }) { ) } else { content = ( -