Skip to content

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

fix bulk download issue

Ashish Viradiyab5817050c4ae
diff --git a/components/view/viewer/dataroom-viewer.tsx b/components/view/viewer/dataroom-viewer.tsx
index 756ebc83..2525c2a1 100644
--- a/components/view/viewer/dataroom-viewer.tsx
+++ b/components/view/viewer/dataroom-viewer.tsx
@@ -132,6 +132,23 @@ export default function DataroomViewer({
return mixedItems.sort((a, b) => (a.orderIndex || 0) - (b.orderIndex || 0));
}, [folders, documents, folderId, accessControls]);
+const allDocumentsCanDownload = useMemo(() => {
+ if (!allowDownload) return false;
+
+ if (!documents || documents.length === 0) return false;
+
+ return documents.some((doc) => {
+ if (doc.versions[0].type === "notion") return false;
+
+ const accessControl = accessControls.find(
+ (access) => access.itemId === doc.dataroomDocumentId,
+ );
+
+ return accessControl?.canDownload ?? true;
+ });
+}, [documents, accessControls, allowDownload]);
+
+
const renderItem = (item: FolderOrDocument) => {
if ("versions" in item) {
return (
@@ -141,7 +158,7 @@ export default function DataroomViewer({
linkId={linkId}
viewId={viewId}
isPreview={!!isPreview}
- allowDownload={allowDownload}
+ allowDownload={allowDownload && item.canDownload}
/>
);
}
@@ -163,7 +180,7 @@ export default function DataroomViewer({
linkId={linkId}
viewId={viewId}
dataroom={dataroom}
- allowDownload={allowDownload}
+ allowDownload={allDocumentsCanDownload}
isPreview={isPreview}
dataroomId={dataroom?.id}
viewerId={viewerId}