mfts / papermark

Papermark is the open-source DocSend alternative with built-in analytics and custom domains.
https://papermark.io
GNU Affero General Public License v3.0
5.34k stars 726 forks source link

[🕹ī¸] Add the ability to move folders into other folders #933

Open mfts opened 1 week ago

mfts commented 1 week ago

What side quest or challenge are you solving?

Currently we can only move documents (individually or multiple) into a folder. However, we want to add the ability to move a folder (that may or may not contain documents and folders with documents and so on) into another folder.

This enables full flexibility and saves a lot of time for users if they made a mistake and uploaded the documents in the wrong place. Google drive is a good example how they manage that.

Please be meticulous with the implementation. We don't need something quick and dirty but stable and fail-safe.

Considerations:

Points

750 Points

Provide proof that you've completed the task

Open a PR with the working code and a detailed explanation of what you did, the use cases you tested and if possible, a video showing the solution.

oss-gg[bot] commented 1 week ago

You already have an open issue assigned to you here. Once that's closed or unassigned, only then we recommend you to take up more.

rajgupta-ml commented 1 week ago

/assign

oss-gg[bot] commented 1 week ago

Assigned to @rajgupta-ml! Please open a draft PR linking this issue within 48h ⚠ī¸ If we can't detect a PR from you linking this issue in 48h, you'll be unassigned automatically 🕹ī¸ Excited to have you ship this 🚀

Anky9972 commented 1 week ago

/assign

oss-gg[bot] commented 1 week ago

You already have an open issue assigned to you here. Once that's closed or unassigned, only then we recommend you to take up more.

zaineli commented 1 week ago

/assign

oss-gg[bot] commented 1 week ago

Assigned to @zaineli! Please open a draft PR linking this issue within 48h ⚠ī¸ If we can't detect a PR from you linking this issue in 48h, you'll be unassigned automatically 🕹ī¸ Excited to have you ship this 🚀

Khaan25 commented 1 week ago

I have built this in a past project but without a drag and drop functionality. If that's okay then I can take over this issue and finish it. @mfts

manameaaus commented 1 week ago

/assign

oss-gg[bot] commented 1 week ago

Assigned to @manameaaus! Please open a draft PR linking this issue within 48h ⚠ī¸ If we can't detect a PR from you linking this issue in 48h, you'll be unassigned automatically 🕹ī¸ Excited to have you ship this 🚀

ebe25 commented 1 week ago

/assign

oss-gg[bot] commented 1 week ago

This issue is already assigned to another person. Please find more issues here.

mfts commented 1 week ago

@Khaan25 after @manameaaus's time is up, feel free to open a PR

oss-gg[bot] commented 5 days ago

@zaineli, Just a little reminder: Please open a draft PR linking this issue within 12 hours. If we can't detect a PR in 12h, you will be unassigned automatically.

oss-gg[bot] commented 4 days ago

@manameaaus, Just a little reminder: Please open a draft PR linking this issue within 12 hours. If we can't detect a PR in 12h, you will be unassigned automatically.

Nithin-532 commented 4 days ago

/assign

oss-gg[bot] commented 4 days ago

This issue is already assigned to another person. Please find more issues here.

Nithin-532 commented 4 days ago

/assign

oss-gg[bot] commented 4 days ago

This issue is already assigned to another person. Please find more issues here.

Nithin-532 commented 2 days ago

/assign

oss-gg[bot] commented 2 days ago

This issue is already assigned to another person. Please find more issues here.

SubhPB commented 1 day ago

@mfts
Hello, it's me again. I been working on this problem and almost complete it (tested and coded apis, modified existing frontend code to be compatible with this new functionality) and everything is going very fine. But there is one issue. Suppose user wants to move a folder "MoveMeFolder" who have 20 subfolders. i need to be very careful and i need to perform the updation with caution because one wrong update can broke the entire code. Here is what my concern is: If there are 20 subfolders (could have their sub-folders), and we know how much important it is to correctly update the fields especially the path field of each sub-folder and their sub-folders. We can ensure it by updating each and every child and their sub childs . This way, we gonna overwhelm our database specifically if user moving folders very frequently. I'm trying to figure out the best optimal solution, i would appreciate if you have any suggestion to help make me better code decision. Thanks.

Khaan25 commented 16 hours ago

Aren't you using Primary Key, Foreign Key? It's very easy to make folder and sub folder and very fast and optimal. You don't need to move all sub folders etc. Could you share your code?

SubhPB commented 4 hours ago

@Khaan25 Great bro!. i think, i was not able to explain the problem well. Let me create an example and consider as follow:

  FolderA --> path = /folder-a
  ----FolderAA --> path = /folder-a/folder-aa
  ----FolderAB --> path = /folder-a/folder-ab
  --------FolderABA --> path =/folder-a/folder-ab/folder-aba

  FolderB --> path = /folder-b
  ----FolderBA --> path = /folder-b/folder-ba

Now Assume user want to move FolderA into FolderB and using the query.

           prisma.folder.update({
                    where: {
                        id: folder.id, // FolderA 's ID
                        teamId: teamId
                    },
                    data: {
                        path: `${ rootFolderPath ?? "" }/${slugify(folder.name)}`, // So that folder A's path will be /folder-b/folder-a
                        parentId: parentFolderId // newParentId means FolderB's ID
                    }
                })

After this, this is the output we will get

  FolderB --> path = /folder-b
  ----FolderBA --> path = /folder-b/folder-ba
  ----FolderA --> path = /folder-b/folder-a
  --------FolderAA --> path = /folder-a/folder-aa 
  --------FolderAB --> path = /folder-a/folder-ab
  ------------FolderABA --> path =/folder-a/folder-ab/folder-aba

You see the path of FolderAA, FolderAB, FolderABA still same. i know that we can update this nestly something like

     data: {
              ...,
              childFolders: {
                           updateMany : {...}
              }
      }

is this really the last solution?, how deeply we can keep doing this especially when depth level is fully dynamic? @Khaan25 Let me know if you can help me out with an another solution.