Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
Merge branch 'main' into 252/preview-button
Marc Seitz80a50f24129e
diff --cc components/links/links-table.tsxindex b22de25f,dac75ad1..b12b66b2--- a/components/links/links-table.tsx+++ b/components/links/links-table.tsx@@@ -68,17 -70,10 +70,19 @@@ import LinkSheet,DEFAULT_LINK_PROPS,type DEFAULT_LINK_TYPE,} from "./link-sheet";+ import { DataroomLinkSheet } from "./link-sheet/dataroom-link-sheet";+ import { PermissionsSheet } from "./link-sheet/permissions-sheet";import { TagColumn } from "./link-sheet/tags/tag-details";import LinksVisitors from "./links-visitors";+import { PreviewButton } from "./preview-button";++const isDocumentProcessing = (version?: DocumentVersion) => {+ if (!version) return false;+ return (+ !version.hasPages &&+ ["pdf", "slides", "docs", "cad"].includes(version.type!)+ );+};export default function LinksTable({targetType,@@@ -407,176 -554,158 +570,149 @@@</TableHeader><TableBody>{processedLinks && processedLinks.length > 0 ? (- processedLinks- .filter((link) => !link.isArchived)- .map((link) => (- <Collapsible key={link.id} asChild>- <>- <TableRow- key={link.id}- className={cn(- "group/row",- popoverOpen === link.id && "bg-gray-100",- )}- >- <TableCell className="w-[250px] truncate font-medium">- <div className="flex items-center gap-x-2">- {link.groupId ? (- <ButtonTooltip content="Group Link">- <BoxesIcon className="size-4" />- </ButtonTooltip>- ) : null}- {link.name || `Link #${link.id.slice(-5)}`}- {link.isNew && !link.isUpdated && (- <Badge- variant="outline"- className="border-emerald-600/80 text-emerald-600/80"- >- New- </Badge>- )}- {link.isUpdated && (- <Badge- variant="outline"- className="border-blue-500/80 text-blue-500/80"- >- Updated- </Badge>- )}- {link.domainId && isFree ? (- <span className="ml-2 rounded-full bg-destructive px-2.5 py-0.5 text-xs text-foreground ring-1 ring-destructive">- Inactive- </span>- ) : null}- </div>- </TableCell>- <TableCell className="flex items-center gap-x-2 sm:min-w-[300px] md:min-w-[400px] lg:min-w-[450px]">- <div- className={cn(- `group/cell relative flex w-full items-center gap-x-4 overflow-hidden truncate rounded-sm px-3 py-1.5 text-center text-secondary-foreground transition-all group-hover/row:ring-1 group-hover/row:ring-gray-400 group-hover/row:dark:ring-gray-100 md:py-1`,- link.domainId && isFree- ? "bg-destructive hover:bg-red-700 hover:dark:bg-red-200"- : "bg-secondary hover:bg-emerald-700 hover:dark:bg-emerald-200",- popoverOpen === link.id &&- "ring-1 ring-gray-400 dark:ring-gray-100",+ processedLinks.map((link) => (+ <Collapsible key={link.id} asChild>+ <>+ <TableRow+ key={link.id}+ className={cn(+ "group/row",+ popoverOpen === link.id && "bg-gray-100",+ link.isArchived &&+ "bg-gray-50 opacity-50 dark:bg-gray-700",+ )}+ >+ <TableCell className="w-[250px] truncate font-medium">+ <div className="flex items-center gap-x-2">+ {link.groupId ? (+ <ButtonTooltip content="Group Link">+ <BoxesIcon className="size-4" />+ </ButtonTooltip>+ ) : null}+ {link.name || `Link #${link.id.slice(-5)}`}+ {link.isNew && !link.isUpdated && (+ <Badge+ variant="outline"+ className="border-emerald-600/80 text-emerald-600/80"+ >+ New+ </Badge>+ )}+ {link.isUpdated && (+ <Badge+ variant="outline"+ className="border-blue-500/80 text-blue-500/80"+ >+ Updated+ </Badge>+ )}+ {link.domainId && isFree ? (+ <span className="ml-2 rounded-full bg-destructive px-2.5 py-0.5 text-xs text-foreground ring-1 ring-destructive">+ Inactive+ </span>+ ) : null}+ </div>+ </TableCell>+ <TableCell className="flex items-center gap-x-2 sm:min-w-[300px] md:min-w-[400px] lg:min-w-[450px]">+ <div+ className={cn(+ `group/cell relative flex w-full items-center gap-x-4 overflow-hidden truncate rounded-sm px-3 py-1.5 text-center text-secondary-foreground transition-all group-hover/row:ring-1 group-hover/row:ring-gray-400 group-hover/row:dark:ring-gray-100 md:py-1`,+ link.domainId && isFree+ ? "bg-destructive hover:bg-red-700 hover:dark:bg-red-200"+ : "bg-secondary hover:bg-emerald-700 hover:dark:bg-emerald-200",+ popoverOpen === link.id &&+ "ring-1 ring-gray-400 dark:ring-gray-100",+ )}+ >+ {/* Progress bar */}- {primaryVersion &&- !primaryVersion.hasPages &&- ["pdf", "slides", "docs", "cad"].includes(- primaryVersion.type!,- ) && (++ {isDocumentProcessing(primaryVersion) &&++ primaryVersion && (+ <FileProcessStatusBar+ documentVersionId={primaryVersion.id}+ className="absolute bottom-0 left-0 right-0 top-0 z-20 flex h-full items-center gap-x-8"+ // @ts-ignore: mutateDocument is not present on datarooms but on document pages+ mutateDocument={mutateDocument}+ />)}- >- {/* Progress bar */}- {isDocumentProcessing(primaryVersion) &&- primaryVersion && (- <FileProcessStatusBar- documentVersionId={primaryVersion.id}- className="absolute bottom-0 left-0 right-0 top-0 z-20 flex h-full items-center gap-x-8"- // @ts-ignore: mutateDocument is not present on datarooms but on document pages- mutateDocument={mutateDocument}- />- )}- <div className="flex w-full whitespace-nowrap text-sm group-hover/cell:opacity-0">- {link.domainId- ? `https://${link.domainSlug}/${link.slug}`- : `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}`}- </div>-- {link.domainId && isFree ? (- <button- className="absolute bottom-0 left-0 right-0 top-0 z-10 hidden w-full whitespace-nowrap text-center text-sm group-hover/cell:block group-hover/cell:text-primary-foreground"- onClick={() =>- router.push("/settings/billing")- }- title="Upgrade to activate link"- >- Upgrade to activate link- </button>- ) : (- <button- className="absolute bottom-0 left-0 right-0 top-0 z-10 hidden w-full whitespace-nowrap text-center text-xs group-hover/cell:block group-hover/cell:text-primary-foreground sm:text-sm"- onClick={() =>- handleCopyToClipboard(- link.domainId- ? `https://${link.domainSlug}/${link.slug}`- : `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}`,- )- }- title="Copy & Share"- >- Copy & Share- </button>- )}+ <div className="flex w-full whitespace-nowrap text-sm group-hover/cell:opacity-0">+ {link.domainId+ ? `https://${link.domainSlug}/${link.slug}`+ : `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}`}</div>- <PreviewButton- link={link}- isProcessing={isDocumentProcessing(- primaryVersion,- )}- onPreview={handlePreviewLink}- />- {isMobile ? (- <ButtonTooltip content="Edit link">- <Button- variant={"link"}- size={"icon"}- className="group h-7 w-8"- onClick={() => handleEditLink(link)}- >- <span className="sr-only">Edit link</span>- <Settings2Icon className="text-gray-400 group-hover:text-gray-500" />- </Button>- </ButtonTooltip>++ {link.domainId && isFree ? (+ <button+ className="absolute bottom-0 left-0 right-0 top-0 z-10 hidden w-full whitespace-nowrap text-center text-sm group-hover/cell:block group-hover/cell:text-primary-foreground"+ onClick={() => router.push("/settings/billing")}+ title="Upgrade to activate link"+ >+ Upgrade to activate link+ </button>) : (- <Popover- open={popoverOpen === link.id}- onOpenChange={() => {}}+ <button+ className="absolute bottom-0 left-0 right-0 top-0 z-10 hidden w-full whitespace-nowrap text-center text-xs group-hover/cell:block group-hover/cell:text-primary-foreground sm:text-sm"+ onClick={() =>+ handleCopyToClipboard(+ link.domainId+ ? `https://${link.domainSlug}/${link.slug}`+ : `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}`,+ )+ }+ title="Copy & Share">- <PopoverTrigger asChild>- <Button- variant="link"- className={cn(- "h-7 font-normal hover:no-underline focus-visible:ring-0 focus-visible:ring-offset-0",- popoverOpen === link.id- ? "text-foreground"- : "text-muted-foreground hover:text-foreground",- )}- size="sm"- onClick={(e) => {- e.preventDefault();- handleEditLink(link);- }}- onMouseDown={(e) => e.preventDefault()}- onMouseEnter={() => {- hoverTimeout.current = setTimeout(- () => setPopoverOpen(link.id),- 250,- );- }}- onMouseLeave={() => {- if (hoverTimeout.current)- clearTimeout(hoverTimeout.current);-- // Add delay before closing to prevent flickering- hoverTimeout.current = setTimeout(- () => setPopoverOpen(null),- 100,- );- }}- >- <Settings2Icon strokeWidth={1.75} />- <span className="whitespace-nowrap">- {countActiveSettings(link)}{" "}- {countActiveSettings(link) === 1- ? "control"- : "controls"}- </span>- </Button>- </PopoverTrigger>- <PopoverContent- side="top"- align="start"- className="w-56 p-0"+ Copy & Share+ </button>+ )}+ </div>- <ButtonTooltip content="Preview link">- <Button- variant={"link"}- size={"icon"}- className="group h-7 w-8"- onClick={() => handlePreviewLink(link)}- >- <span className="sr-only">Preview link</span>- <EyeIcon className="text-gray-400 group-hover:text-gray-500" />- </Button>- </ButtonTooltip>++ <PreviewButton++ link={link}++ isProcessing={isDocumentProcessing(primaryVersion)}++ onPreview={handlePreviewLink}++ />+ {targetType === "DATAROOM" &&+ link.permissionGroupId && (+ <ButtonTooltip content="Limited File Access">+ <FileSlidersIcon className="text-gray-400 group-hover:text-gray-500" />+ </ButtonTooltip>+ )}+ {isMobile ? (+ <ButtonTooltip content="Edit link">+ <Button+ variant={"link"}+ size={"icon"}+ className="group h-7 w-8"+ onClick={() => handleEditLink(link)}+ >+ <span className="sr-only">Edit link</span>+ <Settings2Icon className="text-gray-400 group-hover:text-gray-500" />+ </Button>+ </ButtonTooltip>+ ) : (+ <Popover+ open={popoverOpen === link.id}+ onOpenChange={() => {}}+ >+ <PopoverTrigger asChild>+ <Button+ variant="link"+ className={cn(+ "h-7 font-normal hover:no-underline focus-visible:ring-0 focus-visible:ring-offset-0",+ popoverOpen === link.id+ ? "text-foreground"+ : "text-muted-foreground hover:text-foreground",+ )}+ size="sm"+ onClick={(e) => {+ e.preventDefault();+ handleEditLink(link);+ }}+ onMouseDown={(e) => e.preventDefault()}onMouseEnter={() => {- if (hoverTimeout.current)- clearTimeout(hoverTimeout.current);- setPopoverOpen(link.id);+ hoverTimeout.current = setTimeout(+ () => setPopoverOpen(link.id),+ 250,+ );}}onMouseLeave={() => {if (hoverTimeout.current)@@@ -589,135 -718,183 +725,182 @@@);}}>- <LinkActiveControls- link={link}- onEditClick={(e) => {- e.preventDefault();- handleEditLink(link);- }}- />- </PopoverContent>- </Popover>- )}+ <Settings2Icon strokeWidth={1.75} />+ <span className="whitespace-nowrap">+ {countActiveSettings(link)}{" "}+ {countActiveSettings(link) === 1+ ? "control"+ : "controls"}+ </span>+ </Button>+ </PopoverTrigger>+ <PopoverContent+ side="top"+ align="start"+ className="w-56 p-0"+ onMouseEnter={() => {+ if (hoverTimeout.current)+ clearTimeout(hoverTimeout.current);+ setPopoverOpen(link.id);+ }}+ onMouseLeave={() => {+ if (hoverTimeout.current)+ clearTimeout(hoverTimeout.current);++ // Add delay before closing to prevent flickering+ hoverTimeout.current = setTimeout(+ () => setPopoverOpen(null),+ 100,+ );+ }}+ >+ <LinkActiveControls+ link={link}+ onEditClick={(e) => {+ e.preventDefault();+ handleEditLink(link);+ }}+ />+ </PopoverContent>+ </Popover>+ )}+ </TableCell>+ {hasAnyTags ? (+ <TableCell className="w-[250px] 2xl:w-auto">+ <TagColumn link={link} /></TableCell>- {hasAnyTags ? (- <TableCell className="w-[250px] 2xl:w-auto">- <TagColumn link={link} />- </TableCell>- ) : null}- <TableCell>- <CollapsibleTrigger- disabled={- Number(nFormatter(link._count.views)) === 0 ||- targetType === "DATAROOM"+ ) : null}+ <TableCell>+ <CollapsibleTrigger+ disabled={+ Number(nFormatter(link._count.views)) === 0 ||+ targetType === "DATAROOM"+ }+ >+ <div className="flex items-center space-x-1 [&[data-state=open]>svg.chevron]:rotate-180">+ <BarChart className="h-4 w-4 text-muted-foreground" />+ <p className="whitespace-nowrap text-sm text-muted-foreground">+ {nFormatter(link._count.views)}+ <span className="ml-1 hidden sm:inline-block">+ views+ </span>+ </p>+ {Number(nFormatter(link._count.views)) > 0 &&+ targetType !== "DATAROOM" ? (+ <ChevronDown className="chevron h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />+ ) : null}+ </div>+ </CollapsibleTrigger>+ </TableCell>+ <TableCell className="text-sm text-muted-foreground">+ {link.views[0] ? (+ <time+ dateTime={new Date(+ link.views[0].viewedAt,+ ).toISOString()}+ >+ {timeAgo(link.views[0].viewedAt)}+ </time>+ ) : (+ "-"+ )}+ </TableCell>+ <TableCell className="text-center">+ <div className="flex items-center justify-center gap-x-1">+ <Switch+ className="data-[state=checked]:bg-primary/80 data-[state=checked]:hover:bg-primary data-[state=unchecked]:hover:bg-muted-foreground/80"+ id={`${link.id}-active-switch`}+ checked={!link.isArchived}+ onCheckedChange={(checked) =>+ handleArchiveLink(+ link.id,+ link.documentId ?? link.dataroomId ?? "",+ checked,+ )}+ disabled={loadingLinks.has(link.id)}+ />+ <Label+ className="font-normal"+ htmlFor={`${link.id}-active-switch`}>- <div className="flex items-center space-x-1 [&[data-state=open]>svg.chevron]:rotate-180">- <BarChart className="h-4 w-4 text-muted-foreground" />- <p className="whitespace-nowrap text-sm text-muted-foreground">- {nFormatter(link._count.views)}- <span className="ml-1 hidden sm:inline-block">- views- </span>- </p>- {Number(nFormatter(link._count.views)) > 0 &&- targetType !== "DATAROOM" ? (- <ChevronDown className="chevron h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />- ) : null}- </div>- </CollapsibleTrigger>- </TableCell>- <TableCell className="text-sm text-muted-foreground">- {link.views[0] ? (- <time- dateTime={new Date(- link.views[0].viewedAt,- ).toISOString()}+ {link.isArchived ? "No" : "Yes"}+ </Label>+ </div>+ </TableCell>+ <TableCell className="text-center sm:text-right">+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ variant="ghost"+ className="h-8 w-8 p-0 group-hover/row:ring-1 group-hover/row:ring-gray-200 group-hover/row:dark:ring-gray-700">- {timeAgo(link.views[0].viewedAt)}- </time>- ) : (- "-"- )}- </TableCell>- <TableCell className="text-center sm:text-right">- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- variant="ghost"- className="h-8 w-8 p-0 group-hover/row:ring-1 group-hover/row:ring-gray-200 group-hover/row:dark:ring-gray-700"- >- <span className="sr-only">Open menu</span>- <MoreHorizontal className="h-4 w-4" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuLabel>Actions</DropdownMenuLabel>- <DropdownMenuSeparator />- <DropdownMenuItem- onClick={() => handleEditLink(link)}- >- <Settings2Icon className="mr-2 h-4 w-4" />- Edit Link- </DropdownMenuItem>- <DropdownMenuItem- onClick={() => handlePreviewLink(link)}- >- <EyeIcon className="mr-2 h-4 w-4" />- Preview Link- </DropdownMenuItem>- <DropdownMenuItem- disabled={!canAddLinks}- onClick={() => handleDuplicateLink(link)}- >- <CopyPlusIcon className="mr-2 h-4 w-4" />- Duplicate Link- </DropdownMenuItem>- {features?.embedding ? (+ <span className="sr-only">Open menu</span>+ <MoreHorizontal className="h-4 w-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuLabel>Actions</DropdownMenuLabel>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ onClick={() => handleEditLink(link)}+ >+ <Settings2Icon className="mr-2 h-4 w-4" />+ Edit Link+ </DropdownMenuItem>+ {targetType === "DATAROOM" &&+ link.audienceType !==+ LinkAudienceType.GROUP && (<DropdownMenuItem- onClick={() => {- setSelectedEmbedLink({- id: link.id,- name:- link.name ||- `Link #${link.id.slice(-5)}`,- });- setEmbedModalOpen(true);- }}+ onClick={() => handleEditPermissions(link)}+ disabled={isLoading}>- <Code2Icon className="mr-2 h-4 w-4" />- Get Embed Code+ <FileSlidersIcon className="mr-2 h-4 w-4" />+ Edit File Permissions</DropdownMenuItem>- ) : null}- <DropdownMenuItem- className="text-destructive focus:bg-destructive focus:text-destructive-foreground"- onClick={() =>- handleArchiveLink(- link.id,- link.documentId ?? link.dataroomId ?? "",- link.isArchived,- )- }- >- <ArchiveIcon className="mr-2 h-4 w-4" />- Archive- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- </TableCell>- </TableRow>- <CollapsibleContent asChild>- <LinksVisitors- linkName={link.name || "No link name"}- linkId={link.id}- />- </CollapsibleContent>- </>- </Collapsible>- ))+ )}+ <DropdownMenuItem+ onClick={() => handlePreviewLink(link)}+ >+ <EyeIcon className="mr-2 h-4 w-4" />+ Preview Link+ </DropdownMenuItem>+ <DropdownMenuItem+ disabled={!canAddLinks}+ onClick={() => handleDuplicateLink(link)}+ >+ <CopyPlusIcon className="mr-2 h-4 w-4" />+ Duplicate Link+ </DropdownMenuItem>- <DropdownMenuItem- onClick={() => {- setSelectedEmbedLink({- id: link.id,- name:- link.name ||- `Link #${link.id.slice(-5)}`,- });- setEmbedModalOpen(true);- }}- >- <Code2Icon className="mr-2 h-4 w-4" />- Get Embed Code- </DropdownMenuItem>++ <DropdownMenuItem++ onClick={() => {++ setSelectedEmbedLink({++ id: link.id,++ name:++ link.name || `Link #${link.id.slice(-5)}`,++ });++ setEmbedModalOpen(true);++ }}++ >++ <Code2Icon className="mr-2 h-4 w-4" />++ Get Embed Code++ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </TableCell>+ </TableRow>+ <CollapsibleContent asChild>+ <LinksVisitors+ linkName={link.name || "No link name"}+ linkId={link.id}+ />+ </CollapsibleContent>+ </>+ </Collapsible>+ ))) : (<TableRow>- <TableCell colSpan={5}>+ <TableCell colSpan={hasAnyTags ? 7 : 6}><div className="flex w-full flex-col items-center justify-center gap-4 rounded-xl py-4"><div className="hidden rounded-full sm:block"><div