papermark icon indicating copy to clipboard operation
papermark copied to clipboard

[đŸ•šī¸] Add the ability to move folders into other folders

Open mfts opened this issue 1 year ago â€ĸ 26 comments

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:

  • a folder can contain documents
  • a folder can contain folders that contain documents
  • a folder should be moved to a deeply nested folder
  • the UI should also update once the folder is moved

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.

mfts avatar Oct 14 '24 06:10 mfts

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.

oss-gg[bot] avatar Oct 14 '24 06:10 oss-gg[bot]

/assign

rajgupta-ml avatar Oct 14 '24 07:10 rajgupta-ml

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 🚀

oss-gg[bot] avatar Oct 14 '24 07:10 oss-gg[bot]

/assign

Anky9972 avatar Oct 16 '24 11:10 Anky9972

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.

oss-gg[bot] avatar Oct 16 '24 11:10 oss-gg[bot]

/assign

zaineli avatar Oct 16 '24 21:10 zaineli

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 🚀

oss-gg[bot] avatar Oct 16 '24 21:10 oss-gg[bot]

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

Khaan25 avatar Oct 17 '24 07:10 Khaan25

/assign

manameaaus avatar Oct 17 '24 12:10 manameaaus

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 🚀

oss-gg[bot] avatar Oct 17 '24 12:10 oss-gg[bot]

/assign

ebe25 avatar Oct 19 '24 08:10 ebe25

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

oss-gg[bot] avatar Oct 19 '24 08:10 oss-gg[bot]

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

mfts avatar Oct 19 '24 10:10 mfts

@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] avatar Oct 21 '24 09:10 oss-gg[bot]

@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.

oss-gg[bot] avatar Oct 22 '24 00:10 oss-gg[bot]

/assign

Nithin-532 avatar Oct 22 '24 10:10 Nithin-532

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

oss-gg[bot] avatar Oct 22 '24 10:10 oss-gg[bot]

/assign

Nithin-532 avatar Oct 22 '24 12:10 Nithin-532

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

oss-gg[bot] avatar Oct 22 '24 12:10 oss-gg[bot]

/assign

Nithin-532 avatar Oct 24 '24 05:10 Nithin-532

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

oss-gg[bot] avatar Oct 24 '24 05:10 oss-gg[bot]

@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.

  • Byimaan

SubhPB avatar Oct 25 '24 18:10 SubhPB

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?

Khaan25 avatar Oct 26 '24 04:10 Khaan25

@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.

SubhPB avatar Oct 26 '24 16:10 SubhPB

/assign

SubhPB avatar Nov 08 '24 23:11 SubhPB

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

oss-gg[bot] avatar Nov 08 '24 23:11 oss-gg[bot]