webiny / webiny-js

Open-source serverless enterprise CMS. Includes a headless CMS, page builder, form builder, and file manager. Easy to customize and expand. Deploys to AWS.
https://www.webiny.com
Other
7.22k stars 588 forks source link

Ensure Folders Cannot Be Deleted If They Contain Content (Including Inaccessible Content) #4191

Open adrians5j opened 6 days ago

adrians5j commented 6 days ago

Changes

This PR includes two improvements related to checking if a folder can be deleted.

Most importantly, upon deleting a folder, we now take into consideration the possibility that a folder might contain folders or content (e.g. files or CMS entries) to which the user does not have access. Because this was previously not the case, deletion of a folder would succeed in case it contained folders or content to which the user does not have access.

Also, prior to this PR, deletion of a CMS entries folder would not succeed if a folder had CMS entries (which is the correct behaviour), but it would incorrectly succeed if a folder had child folders. Deletion of a folder should be prevented in case a folder contains at least one content entry or one folder.

Additional Changes

Refactored the existing code (three lifecycle hooks that perform these checks), and also tests a bit.

How Has This Been Tested?

Added Jest tests.

Documentation

Changelog.