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.71k stars 765 forks source link

Added the error free and tested functionality to move folders into another folder. Work for all types of folders (#933) #1379

Open SubhPB opened 2 weeks ago

SubhPB commented 2 weeks ago

In this pull request, i enabled the user to move folders into another folder. It also works for dataroom folders. It is complete error free and fully tested as it was said in #933 .

An overview of what changes i have made:

Created 2 new api endpoints one for simple folder and other for dataroom folder.

1. /api/teams/[teamId]/folders/move         [PATCH]
2. /api/teams/[teamId]/datarooms/[id]/folders/move        [PATCH]

i has implemented all the security checks and also solved all the possible edge cases. There were multiple edge cases. i worked very hard in code readability you can easily read and check how i have solved all of those. All update is handled very preciously and smoothly in a careful way.

Modified Existing Components such as SidebarSelectionTree for both (Folder and DataroomFolder)

In order to make those components compatible with this new feature i had to implement an optional filter function so that user can't select any invalid new parent folder. This change is 100% compatible with existing code

New Modal specific to move folders into another folder

I introduced a new modal capable to handle both types of folders. Upon form submission it do a good job to check the validity, also give the appropriate meaningful errors if user selects an invalid new parent folder. It internally calls move-folders-into-folder a newly created function to make the API request

Modified existing component named FolderCard

This component did not have any option about move folder. but now i have included a new option of move folder and it also works for both types of folders.

Here is the video of my solution.

https://github.com/user-attachments/assets/2c607697-fcb9-4316-9038-f562bd313ab9

@mfts All code has been done in a clean way with meaningful comments. This was a bit complex problem but i believe it would not be hard for anyone to understand the code and solution. I would be very happy to get feedback about my solution and how overall my code was. Please feel free to ask if you need any modification or anything in the code.

vercel[bot] commented 2 weeks ago

@SubhPB is attempting to deploy a commit to the mftsio Team on Vercel.

A member of the Team first needs to authorize it.

SubhPB commented 2 weeks ago

@mfts Please let me know if there will be something to do in this code or if you want me to add more videos as proof or any more explanation about code. Thank you