Skip to content

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

Hide Bulk Download if every doc not downloadable

Ashish Viradiya520491a8fe45
diff --git a/components/view/DataroomViewer.tsx b/components/view/DataroomViewer.tsx
index 5304a957..21afc0e5 100644
--- a/components/view/DataroomViewer.tsx
+++ b/components/view/DataroomViewer.tsx
@@ -102,6 +102,19 @@ export default function DataroomViewer({
[folderId, folders],
);
+ 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]);
+
// create a mixedItems array with folders and documents of the current folder and memoize it
const mixedItems = useMemo(() => {
const mixedItems: FolderOrDocument[] = [
@@ -158,7 +171,7 @@ export default function DataroomViewer({
linkId={linkId}
viewId={viewId}
dataroom={dataroom}
- allowDownload={allowDownload}
+ allowDownload={allDocumentsCanDownload}
isPreview={isPreview}
/>
<div