Skip to content

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

feat: add "home" folder to move folder modal

Marc Seitz326e83fbcc1e
diff --git a/components/sidebar-folders.tsx b/components/sidebar-folders.tsx
index 533cfee1..15213791 100644
--- a/components/sidebar-folders.tsx
+++ b/components/sidebar-folders.tsx
@@ -185,16 +185,27 @@ const SidebarFoldersSelection = ({
return [];
}, [folders]);
+ // Create a virtual "Home" folder
+ const homeFolder: Partial<FolderWithDocuments> = {
+ // @ts-ignore
+ id: null,
+ name: "Home",
+ path: "/",
+ childFolders: nestedFolders,
+ documents: [],
+ };
+
return (
<FileTree>
- {nestedFolders.map((folder) => (
- <FolderComponentSelection
- key={folder.id}
- folder={folder}
- selectedFolder={selectedFolder}
- setSelectedFolder={setSelectedFolder}
- />
- ))}
+ {/* {nestedFolders.map((folder) => ( */}
+ <FolderComponentSelection
+ // key={folder.id}
+ // @ts-ignore
+ folder={homeFolder}
+ selectedFolder={selectedFolder}
+ setSelectedFolder={setSelectedFolder}
+ />
+ {/* ))} */}
</FileTree>
);
};
diff --git a/pages/api/teams/[teamId]/documents/move.ts b/pages/api/teams/[teamId]/documents/move.ts
index fe4e72c8..c5d07991 100644
--- a/pages/api/teams/[teamId]/documents/move.ts
+++ b/pages/api/teams/[teamId]/documents/move.ts
@@ -21,7 +21,7 @@ export default async function handle(
const { teamId } = req.query as { teamId: string };
const { documentIds, folderId } = req.body as {
documentIds: string[];
- folderId: string;
+ folderId: string | null;
};
// Ensure the user is an admin of the team
@@ -51,6 +51,15 @@ export default async function handle(
},
});
+ // Get new path for folder unless folderId is null
+ let folder: { path: string } | null = null;
+ if (folderId) {
+ folder = await prisma.folder.findUnique({
+ where: { id: folderId },
+ select: { path: true },
+ });
+ }
+
if (updatedDocuments.count === 0) {
return res.status(404).end("No documents were updated");
}
@@ -60,6 +69,7 @@ export default async function handle(
return res.status(200).json({
message: "Document moved successfully",
updatedCount: updatedDocuments.count,
+ newPath: folder?.path,
});
} else {
// We only allow PATCH requests