Skip to content

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

feat: add download only icon to document and add missing fileSize

Marc Seitzbefa2ab384cb
diff --git a/components/documents/document-header.tsx b/components/documents/document-header.tsx
index 4dd36566..79321ad1 100644
--- a/components/documents/document-header.tsx
+++ b/components/documents/document-header.tsx
@@ -7,6 +7,7 @@ import { Document, DocumentVersion } from "@prisma/client";
import {
AlertCircleIcon,
BetweenHorizontalStartIcon,
+ CloudDownloadIcon,
FileDownIcon,
SheetIcon,
Sparkles,
@@ -455,6 +456,15 @@ export default function DocumentHeader({
</span>
</ButtonTooltip>
)}
+
+ {prismaDocument.downloadOnly && (
+ <ButtonTooltip content="Download only">
+ <span className="text-xs">
+ <CloudDownloadIcon className="h-6 w-6" />
+ <span className="sr-only">This document is download only</span>
+ </span>
+ </ButtonTooltip>
+ )}
</div>
<div className="flex items-center gap-x-4 md:gap-x-2">
@@ -508,6 +518,7 @@ export default function DocumentHeader({
{prismaDocument.type !== "notion" &&
prismaDocument.type !== "sheet" &&
+ prismaDocument.type !== "zip" &&
prismaDocument.assistantEnabled && (
<Button
className="group hidden h-8 space-x-1 whitespace-nowrap bg-gradient-to-r from-[#16222A] via-emerald-500 to-[#16222A] text-xs duration-200 ease-linear hover:bg-right md:flex lg:h-9 lg:text-sm"
@@ -580,7 +591,8 @@ export default function DocumentHeader({
</DropdownMenuItem>
{prismaDocument.type !== "notion" &&
- prismaDocument.type !== "sheet" && (
+ prismaDocument.type !== "sheet" &&
+ prismaDocument.type !== "zip" && (
<DropdownMenuItem
onClick={() =>
activateOrRedirectAssistant(prismaDocument)
@@ -595,6 +607,7 @@ export default function DocumentHeader({
</DropdownMenuGroup>
{primaryVersion.type !== "notion" &&
primaryVersion.type !== "sheet" &&
+ primaryVersion.type !== "zip" &&
(!prismaDocument.assistantEnabled ? (
<DropdownMenuItem
onClick={() =>
diff --git a/components/links/link-sheet/agreement-panel/index.tsx b/components/links/link-sheet/agreement-panel/index.tsx
index c4217a66..68486f9b 100644
--- a/components/links/link-sheet/agreement-panel/index.tsx
+++ b/components/links/link-sheet/agreement-panel/index.tsx
@@ -72,7 +72,7 @@ export default function AgreementSheet({
return;
}
- const { type, data, numPages } = await putFile({
+ const { type, data, numPages, fileSize } = await putFile({
file: currentFile,
teamId: teamId!,
});
@@ -83,6 +83,7 @@ export default function AgreementSheet({
storageType: type!,
contentType: contentType,
supportedFileType: supportedFileType,
+ fileSize: fileSize,
};
// create a document in the database
const response = await createAgreementDocument({
diff --git a/components/welcome/containers/upload-container.tsx b/components/welcome/containers/upload-container.tsx
index 313ab127..9d7c21c6 100644
--- a/components/welcome/containers/upload-container.tsx
+++ b/components/welcome/containers/upload-container.tsx
@@ -60,7 +60,7 @@ export function UploadContainer({
return;
}
- const { type, data, numPages } = await putFile({
+ const { type, data, numPages, fileSize } = await putFile({
file: currentFile,
teamId,
});
@@ -74,6 +74,7 @@ export function UploadContainer({
storageType: type!,
contentType: contentType,
supportedFileType: supportedFileType,
+ fileSize: fileSize,
};
// create a document in the database
const response = await createDocument({
diff --git a/components/welcome/special-upload.tsx b/components/welcome/special-upload.tsx
index ab2ed381..37e7e733 100644
--- a/components/welcome/special-upload.tsx
+++ b/components/welcome/special-upload.tsx
@@ -92,7 +92,7 @@ export default function DeckGeneratorUpload() {
return;
}
- const { type, data, numPages } = await putFile({
+ const { type, data, numPages, fileSize } = await putFile({
file: currentFile,
teamId,
});
@@ -106,6 +106,7 @@ export default function DeckGeneratorUpload() {
storageType: type!,
contentType: contentType,
supportedFileType: supportedFileType,
+ fileSize: fileSize,
};
// create a document in the database
const response = await createDocument({
diff --git a/lib/documents/create-document.ts b/lib/documents/create-document.ts
index 1af7c194..823ba322 100644
--- a/lib/documents/create-document.ts
+++ b/lib/documents/create-document.ts
@@ -79,6 +79,7 @@ export const createAgreementDocument = async ({
folderPathName: folderPathName,
type: documentData.supportedFileType,
contentType: documentData.contentType,
+ fileSize: documentData.fileSize,
}),
});
diff --git a/pages/api/teams/[teamId]/documents/agreement.ts b/pages/api/teams/[teamId]/documents/agreement.ts
index 82cc6084..afad50ce 100644
--- a/pages/api/teams/[teamId]/documents/agreement.ts
+++ b/pages/api/teams/[teamId]/documents/agreement.ts
@@ -9,6 +9,7 @@ import { errorhandler } from "@/lib/errorHandler";
import notion from "@/lib/notion";
import prisma from "@/lib/prisma";
import { getTeamWithUsersAndDocument } from "@/lib/team/helper";
+import { convertFilesToPdfTask } from "@/lib/trigger/convert-files";
import { CustomUser } from "@/lib/types";
import { getExtension, log } from "@/lib/utils";
@@ -38,6 +39,7 @@ export default async function handle(
numPages,
type: fileType,
folderPathName,
+ fileSize,
} = req.body as {
name: string;
url: string;
@@ -45,6 +47,7 @@ export default async function handle(
numPages?: number;
type?: string;
folderPathName?: string;
+ fileSize?: number;
};
try {
@@ -94,6 +97,7 @@ export default async function handle(
type: type,
storageType,
numPages: numPages,
+ fileSize: fileSize,
isPrimary: true,
versionNumber: 1,
},
@@ -106,6 +110,22 @@ export default async function handle(
},
});
+ if (type === "docs") {
+ console.log("converting docx to pdf");
+ // Trigger convert-files-to-pdf task
+ await convertFilesToPdfTask.trigger(
+ {
+ documentId: document.id,
+ documentVersionId: document.versions[0].id,
+ teamId,
+ },
+ {
+ idempotencyKey: `${teamId}-${document.versions[0].id}`,
+ tags: [`team_${teamId}`, `document_${document.id}`],
+ },
+ );
+ }
+
// skip triggering convert-pdf-to-image job for "notion" / "excel" documents
if (type === "pdf") {
// trigger document uploaded event to trigger convert-pdf-to-image job