]> BookStack Code Mirror - bookstack/commit
Reviewed recycle bin API PR and made changes
authorDan Brown <redacted>
Mon, 25 Apr 2022 16:54:59 +0000 (17:54 +0100)
committerDan Brown <redacted>
Mon, 25 Apr 2022 16:54:59 +0000 (17:54 +0100)
commitff8dadefee9e400bb46a54b301a8b701c4a0b61b
tree60a628de348e6509b35ad21aab7e95cf4ade243e
parent14bccae6bd93164c6fc647747654c0fccd8dffe7
Reviewed recycle bin API PR and made changes

Made the following changes, many of these are just to align with
existing conventions.

- Updated urls to be hypenated, instead of underscored, to match other system endpoints.
- Updated URL parameter to be `deletionId` instead of `id`, and removed the ID-based comment on controller methods, so the required ID model is clear from the URL alone, since its not clear from the URL endpoint alone like existing endpoints. This follows the pattern used in the "web" routes.
- Added extra detail on some controller method comments, and copied permission comment to each method.
- Removed existing field visibility mechanisms to use simpler model-based visibility since we didn't need anything too special here (After some of my other changes).
- Allowed the "deletable" model to be shown in response to provide a little more detail on the main deleted item.
- Updated parent/child-count loading to be on the "deletable" model instead of additional properties which results in simpler controller logic and enforces the idea these are relations on the deletable, not the deletion itself. It also removes additional exposure of model namespacing.
- Updated (int) casts to intval, just since that's our most common conversion method in the codebase.
- Testing: Removed `actingAsAuthorizedUser` and used the admin user instead to prevent extra auth steps on each test.
- Testing: Cut logic/data-checks from tests if already covered by other tests.
- Testing: Added simple assertions for delete/restore response data.
- Examples: Updated list example to reflect changes.

Review of PR #3377
To be followed up with changes to polymorphic relations to hide
namespacing.
app/Entities/Models/Deletion.php
app/Http/Controllers/Api/RecycleBinApiController.php
dev/api/responses/recycle-bin-destroy.json [moved from dev/api/responses/recycle_bin-destroy.json with 100% similarity]
dev/api/responses/recycle-bin-list.json [new file with mode: 0644]
dev/api/responses/recycle-bin-restore.json [moved from dev/api/responses/recycle_bin-restore.json with 100% similarity]
dev/api/responses/recycle_bin-list.json [deleted file]
routes/api.php
tests/Api/RecycleBinApiTest.php
Morty Proxy This is a proxified and sanitized view of the page, visit original site.