Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

hide processing documents in the dataroom viewer

Ashish Viradiyaa38bd5329d7b
diff --git a/components/links/link-sheet/custom-fields-panel/custom-field.tsx b/components/links/link-sheet/custom-fields-panel/custom-field.tsx
index 09394a7b..73a82f0f 100644
--- a/components/links/link-sheet/custom-fields-panel/custom-field.tsx
+++ b/components/links/link-sheet/custom-fields-panel/custom-field.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState, useCallback, memo } from "react";
+import { memo, useEffect, useState } from "react";
import { Trash2 } from "lucide-react";
diff --git a/components/view/dataroom/document-card.tsx b/components/view/dataroom/document-card.tsx
index 7e3595cf..96bb417d 100644
--- a/components/view/dataroom/document-card.tsx
+++ b/components/view/dataroom/document-card.tsx
@@ -7,6 +7,7 @@ import { useTheme } from "next-themes";
import { toast } from "sonner";
import { timeAgo } from "@/lib/utils";
+import { cn } from "@/lib/utils";
import { fileIcon } from "@/lib/utils/get-file-icon";
import { Button } from "@/components/ui/button";
@@ -35,6 +36,7 @@ type DocumentsCardProps = {
viewId?: string;
isPreview: boolean;
allowDownload: boolean;
+ isProcessing?: boolean;
};
export default function DocumentCard({
@@ -43,6 +45,7 @@ export default function DocumentCard({
viewId,
isPreview,
allowDownload,
+ isProcessing = false,
}: DocumentsCardProps) {
const { theme, systemTheme } = useTheme();
const canDownload = document.canDownload && allowDownload;
@@ -57,6 +60,14 @@ export default function DocumentCard({
};
const handleDocumentClick = (e: React.MouseEvent) => {
+ if (isProcessing) {
+ e.preventDefault();
+ toast.error(
+ "Document is still processing. Please wait a moment and try again.",
+ );
+ return;
+ }
+
e.preventDefault();
// Open in new tab
if (domain && slug) {
@@ -156,7 +167,12 @@ export default function DocumentCard({
return (
<>
- <li className="group/row relative flex items-center justify-between rounded-lg border-0 p-3 ring-1 ring-gray-200 transition-all hover:bg-secondary hover:ring-gray-300 dark:bg-secondary dark:ring-gray-700 hover:dark:ring-gray-500 sm:p-4">
+ <li
+ className={cn(
+ "group/row relative flex items-center justify-between rounded-lg border-0 p-3 ring-1 ring-gray-200 transition-all hover:bg-secondary hover:ring-gray-300 dark:bg-secondary dark:ring-gray-700 hover:dark:ring-gray-500 sm:p-4",
+ isProcessing && "cursor-not-allowed opacity-60",
+ )}
+ >
<div className="z-0 flex min-w-0 shrink items-center space-x-2 sm:space-x-4">
<div className="mx-0.5 flex w-8 items-center justify-center text-center sm:mx-1">
{fileIcon({
@@ -172,8 +188,14 @@ export default function DocumentCard({
<button
onClick={handleDocumentClick}
className="w-full truncate"
+ disabled={isProcessing}
>
<span>{document.name}</span>
+ {isProcessing && (
+ <span className="ml-2 text-xs text-muted-foreground">
+ (Processing...)
+ </span>
+ )}
<span className="absolute inset-0" />
</button>
</h2>
@@ -185,7 +207,7 @@ export default function DocumentCard({
</div>
</div>
</div>
- {canDownload && (
+ {canDownload && !isProcessing && (
<div className="z-10">
<DropdownMenu>
<DropdownMenuTrigger asChild>
diff --git a/components/view/viewer/dataroom-viewer.tsx b/components/view/viewer/dataroom-viewer.tsx
index 075bf07c..a93f8c46 100644
--- a/components/view/viewer/dataroom-viewer.tsx
+++ b/components/view/viewer/dataroom-viewer.tsx
@@ -1,4 +1,4 @@
-import { useMemo } from "react";
+import { memo, useMemo } from "react";
import React from "react";
import {
@@ -7,11 +7,12 @@ import {
ViewerGroupAccessControls,
} from "@prisma/client";
import * as SheetPrimitive from "@radix-ui/react-dialog";
-import { PanelLeftIcon, XIcon } from "lucide-react";
+import { AlertCircle, PanelLeftIcon, RefreshCw, XIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import { ViewFolderTree } from "@/components/datarooms/folders";
+import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import {
Breadcrumb,
BreadcrumbItem,
@@ -74,6 +75,34 @@ const getParentFolders = (
return breadcrumbFolders;
};
+const ProcessingBanner = memo(() => {
+ return (
+ <Alert className="mt-2">
+ <AlertCircle className="h-4 w-4" />
+ <AlertTitle>Processing Documents</AlertTitle>
+ <AlertDescription className="flex items-center justify-between">
+ <span>
+ Some documents are still processing. Please wait a moment and refresh
+ the page to see updates.
+ </span>
+ <button
+ onClick={() => window.location.reload()}
+ className={cn(
+ "ml-4 flex items-center space-x-1 rounded-md px-2 py-1 text-xs transition-colors",
+ "bg-black text-white hover:bg-gray-800",
+ "dark:bg-white dark:text-black dark:hover:bg-gray-200",
+ )}
+ >
+ <RefreshCw className="h-3 w-3" />
+ <span>Refresh</span>
+ </button>
+ </AlertDescription>
+ </Alert>
+ );
+});
+
+ProcessingBanner.displayName = "ProcessingBanner";
+
export default function DataroomViewer({
brand,
viewId,
@@ -147,8 +176,20 @@ export default function DataroomViewer({
return mixedItems.sort((a, b) => (a.orderIndex || 0) - (b.orderIndex || 0));
}, [folders, documents, folderId, accessControls]);
+ const hasProcessingDocuments = useMemo(() => {
+ return documents?.some(
+ (doc) =>
+ ["docs", "slides", "pdf"].includes(doc.versions[0].type) &&
+ !doc.versions[0].hasPages,
+ );
+ }, [documents]);
+
const renderItem = (item: FolderOrDocument) => {
if ("versions" in item) {
+ const isProcessing =
+ ["docs", "slides", "pdf"].includes(item.versions[0].type) &&
+ !item.versions[0].hasPages;
+
return (
<DocumentCard
key={item.id}
@@ -157,6 +198,7 @@ export default function DataroomViewer({
viewId={viewId}
isPreview={!!isPreview}
allowDownload={allowDownload && item.canDownload}
+ isProcessing={isProcessing}
/>
);
}
@@ -285,6 +327,7 @@ export default function DataroomViewer({
)}
</div>
</div>
+ {hasProcessingDocuments && <ProcessingBanner />}
<ul role="list" className="-mx-4 space-y-4 overflow-auto p-4">
{mixedItems.map(renderItem)}
</ul>