Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
Merge branch 'main' into 267/indexFile
Marc Seitz149116650821
diff --cc components/view/dataroom/nav-dataroom.tsxindex a56ecf2e,3ff4917e..4694f7d4--- a/components/view/dataroom/nav-dataroom.tsx+++ b/components/view/dataroom/nav-dataroom.tsx@@@ -3,15 -3,12 +3,13 @@@ import Link from "next/link"import React, { useEffect, useState } from "react";import { DataroomBrand } from "@prisma/client";- import { Download, MessagesSquareIcon } from "lucide-react";+ import { BadgeInfoIcon, Download, MessagesSquareIcon } from "lucide-react";import { toast } from "sonner";- import { timeAgo } from "@/lib/utils";+ import { formatDate } from "@/lib/utils";import {+ ButtonTooltip,Tooltip,TooltipContent,TooltipTrigger,@@@ -32,9 -28,7 +30,10 @@@ export default function DataroomNav(dataroomId,viewerId,conversationsEnabled,+ enableIndexFile,+ isEmbedded,+ viewerEmail,+ isTeamMember,}: {allowDownload?: boolean;brand?: Partial<DataroomBrand>;@@@ -45,9 -39,7 +44,10 @@@dataroomId?: string;viewerId?: string;conversationsEnabled?: boolean;+ enableIndexFile?: boolean;+ isEmbedded?: boolean;+ viewerEmail?: string;+ isTeamMember?: boolean;}) {const [loading, setLoading] = useState<boolean>(false);const [showConversations, setShowConversations] = useState<boolean>(false);diff --cc components/view/viewer/dataroom-viewer.tsxindex fc344e01,26bb53a6..a0b20952--- a/components/view/viewer/dataroom-viewer.tsx+++ b/components/view/viewer/dataroom-viewer.tsx@@@ -188,9 -215,7 +221,10 @@@ export default function DataroomViewer(dataroomId={dataroom?.id}viewerId={viewerId}conversationsEnabled={viewData.conversationsEnabled}+ enableIndexFile={enableIndexFile}+ isEmbedded={isEmbedded}+ viewerEmail={viewerEmail}+ isTeamMember={viewData.isTeamMember}/><divstyle={{ height: "calc(100vh - 64px)" }}diff --cc pages/api/links/[id]/index.tsindex fa3a6cf8,a579be49..1d5d1b3d--- a/pages/api/links/[id]/index.ts+++ b/pages/api/links/[id]/index.ts@@@ -252,66 -251,68 +253,69 @@@ export default async function handle});}- // Update the link in the database- const updatedLink = await prisma.link.update({- where: { id, teamId },- data: {- documentId: documentLink ? targetId : null,- dataroomId: dataroomLink ? targetId : null,- password: hashedPassword,- name: linkData.name || null,- emailProtected:- linkData.audienceType === LinkAudienceType.GROUP- ? true- : linkData.emailProtected,- emailAuthenticated: linkData.emailAuthenticated,- allowDownload: linkData.allowDownload,- allowList: linkData.allowList,- denyList: linkData.denyList,- expiresAt: exat,- domainId: domainObj?.id || null,- domainSlug: domain || null,- slug: slug || null,- enableIndexFile: enableIndexFile,- enableNotification: linkData.enableNotification,- enableFeedback: linkData.enableFeedback,- enableScreenshotProtection: linkData.enableScreenshotProtection,- enableCustomMetatag: linkData.enableCustomMetatag,- metaTitle: linkData.metaTitle || null,- metaDescription: linkData.metaDescription || null,- metaImage: linkData.metaImage || null,- metaFavicon: linkData.metaFavicon || null,- ...(linkData.customFields && {- customFields: {- deleteMany: {}, // Delete all existing custom fields- createMany: {- data: linkData.customFields.map((field: any, index: number) => ({- type: field.type,- identifier: field.identifier,- label: field.label,- placeholder: field.placeholder,- required: field.required,- disabled: field.disabled,- orderIndex: index,- })),- skipDuplicates: true,+ const updatedLink = await prisma.$transaction(async (tx) => {+ const link = await tx.link.update({+ where: { id, teamId },+ data: {+ documentId: documentLink ? targetId : null,+ dataroomId: dataroomLink ? targetId : null,+ password: hashedPassword,+ name: linkData.name || null,+ emailProtected:+ linkData.audienceType === LinkAudienceType.GROUP+ ? true+ : linkData.emailProtected,+ emailAuthenticated: linkData.emailAuthenticated,+ allowDownload: linkData.allowDownload,+ allowList: linkData.allowList,+ denyList: linkData.denyList,+ expiresAt: exat,+ domainId: domainObj?.id || null,+ domainSlug: domain || null,+ slug: slug || null,++ enableIndexFile: linkData.enableIndexFile,+ enableNotification: linkData.enableNotification,+ enableFeedback: linkData.enableFeedback,+ enableScreenshotProtection: linkData.enableScreenshotProtection,+ enableCustomMetatag: linkData.enableCustomMetatag,+ metaTitle: linkData.metaTitle || null,+ metaDescription: linkData.metaDescription || null,+ metaImage: linkData.metaImage || null,+ metaFavicon: linkData.metaFavicon || null,+ ...(linkData.customFields && {+ customFields: {+ deleteMany: {}, // Delete all existing custom fields+ createMany: {+ data: linkData.customFields.map(+ (field: any, index: number) => ({+ type: field.type,+ identifier: field.identifier,+ label: field.label,+ placeholder: field.placeholder,+ required: field.required,+ disabled: field.disabled,+ orderIndex: index,+ }),+ ),+ skipDuplicates: true,+ },},- },- }),- enableQuestion: linkData.enableQuestion,- ...(linkData.enableQuestion && {- feedback: {- upsert: {- create: {- data: {- question: linkData.questionText,- type: linkData.questionType,+ }),+ enableQuestion: linkData.enableQuestion,+ ...(linkData.enableQuestion && {+ feedback: {+ upsert: {+ create: {+ data: {+ question: linkData.questionText,+ type: linkData.questionType,+ },},- },- update: {- data: {- question: linkData.questionText,- type: linkData.questionType,+ update: {+ data: {+ question: linkData.questionText,+ type: linkData.questionType,+ },},},},diff --cc pages/api/links/index.tsindex 629fd148,d478c2a2..1a17e724--- a/pages/api/links/index.ts+++ b/pages/api/links/index.ts@@@ -119,87 -123,109 +124,110 @@@ export default async function handler}// Fetch the link and its related document from the database- const link = await prisma.link.create({- data: {- documentId: documentLink ? targetId : null,- dataroomId: dataroomLink ? targetId : null,- linkType,- teamId,- password: hashedPassword,- name: linkData.name || null,- emailProtected:- linkData.audienceType === LinkAudienceType.GROUP- ? true- : linkData.emailProtected,- emailAuthenticated: linkData.emailAuthenticated,- expiresAt: exat,- allowDownload: linkData.allowDownload,- domainId: domainObj?.id || null,- domainSlug: domain || null,- slug: slug || null,- enableNotification: linkData.enableNotification,- enableFeedback: linkData.enableFeedback,- enableScreenshotProtection: linkData.enableScreenshotProtection,- enableCustomMetatag: linkData.enableCustomMetatag,- metaTitle: linkData.metaTitle || null,- metaDescription: linkData.metaDescription || null,- metaImage: linkData.metaImage || null,- metaFavicon: linkData.metaFavicon || null,- allowList: linkData.allowList,- denyList: linkData.denyList,- enableConversation: linkData.enableConversation,- audienceType: linkData.audienceType,- enableIndexFile: enableIndexFile,- groupId:- linkData.audienceType === LinkAudienceType.GROUP- ? linkData.groupId- : null,- ...(linkData.enableQuestion && {- enableQuestion: linkData.enableQuestion,- feedback: {- create: {- data: {- question: linkData.questionText,- type: linkData.questionType,+ const updatedLink = await prisma.$transaction(async (tx) => {+ const link = await tx.link.create({+ data: {+ documentId: documentLink ? targetId : null,+ dataroomId: dataroomLink ? targetId : null,+ linkType,+ teamId,+ password: hashedPassword,+ name: linkData.name || null,+ emailProtected:+ linkData.audienceType === LinkAudienceType.GROUP+ ? true+ : linkData.emailProtected,+ emailAuthenticated: linkData.emailAuthenticated,+ expiresAt: exat,+ allowDownload: linkData.allowDownload,+ domainId: domainObj?.id || null,+ domainSlug: domain || null,+ slug: slug || null,++ enableIndexFile: enableIndexFile,+ enableNotification: linkData.enableNotification,+ enableFeedback: linkData.enableFeedback,+ enableScreenshotProtection: linkData.enableScreenshotProtection,+ enableCustomMetatag: linkData.enableCustomMetatag,+ metaTitle: linkData.metaTitle || null,+ metaDescription: linkData.metaDescription || null,+ metaImage: linkData.metaImage || null,+ metaFavicon: linkData.metaFavicon || null,+ allowList: linkData.allowList,+ denyList: linkData.denyList,+ audienceType: linkData.audienceType,+ groupId:+ linkData.audienceType === LinkAudienceType.GROUP+ ? linkData.groupId+ : null,+ ...(linkData.enableQuestion && {+ enableQuestion: linkData.enableQuestion,+ feedback: {+ create: {+ data: {+ question: linkData.questionText,+ type: linkData.questionType,+ },},},- },- }),- ...(linkData.enableAgreement && {- enableAgreement: linkData.enableAgreement,- agreementId: linkData.agreementId,- }),- ...(linkData.enableWatermark && {- enableWatermark: linkData.enableWatermark,- watermarkConfig: linkData.watermarkConfig,- }),- showBanner: linkData.showBanner,- ...(linkData.customFields && {- customFields: {- createMany: {- data: linkData.customFields.map(- (field: any, index: number) => ({- type: field.type,- identifier: field.identifier,- label: field.label,- placeholder: field.placeholder,- required: field.required,- disabled: field.disabled,- orderIndex: index,- }),- ),+ }),+ ...(linkData.enableAgreement && {+ enableAgreement: linkData.enableAgreement,+ agreementId: linkData.agreementId,+ }),+ ...(linkData.enableWatermark && {+ enableWatermark: linkData.enableWatermark,+ watermarkConfig: linkData.watermarkConfig,+ }),+ ...(linkData.enableUpload && {+ enableUpload: linkData.enableUpload,+ isFileRequestOnly: linkData.isFileRequestOnly,+ uploadFolderId: linkData.uploadFolderId,+ }),+ showBanner: linkData.showBanner,+ ...(linkData.customFields && {+ customFields: {+ createMany: {+ data: linkData.customFields.map(+ (field: any, index: number) => ({+ type: field.type,+ identifier: field.identifier,+ label: field.label,+ placeholder: field.placeholder,+ required: field.required,+ disabled: field.disabled,+ orderIndex: index,+ }),+ ),+ },},- },- }),- ...(linkData.enableUpload && {- enableUpload: linkData.enableUpload,- isFileRequestOnly: linkData.isFileRequestOnly,- uploadFolderId: linkData.uploadFolderId,- }),- },- include: {- customFields: true,- },+ }),+ },+ include: {+ customFields: true,+ },+ });++ let tags: Partial<Tag>[] = [];+ if (linkData.tags?.length) {+ // create tag items+ await tx.tagItem.createMany({+ data: linkData.tags.map((tagId: string) => ({+ tagId,+ itemType: "LINK_TAG",+ linkId: link.id,+ taggedBy: userId,+ })),+ skipDuplicates: true,+ });++ // return tags+ tags = await tx.tag.findMany({+ where: { id: { in: linkData.tags } },+ select: { id: true, name: true, color: true, description: true },+ });+ }++ return { ...link, tags };});const linkWithView = {