Skip to content

[API] Recycle bin endpoints - #3377

Merged
ssddanbrown merged 3 commits into
BookStackApp:developmentfrom
bourdaisj:recycle_bin_api_endpoints
Apr 25, 2022
Merged

ssddanbrown merged 3 commits into
BookStackApp:developmentfrom
bourdaisj:recycle_bin_api_endpoints

Conversation

@bourdaisj

Copy link
Copy Markdown
Contributor

Related to: #3372
This is a draft PR to discuss and make sure I'm on the right track.

@bourdaisj bourdaisj changed the title Start recycle bin API endpoints: list, restore, delete [API] Recycle bin endpoints Apr 7, 2022
@ssddanbrown

Copy link
Copy Markdown
Member

Hi @Julesdevops,
This is looking great so far, can't see any major things to change at this time.
Just let me know when all is implemented & ready from your side and I'll jump in for a full review.

@bourdaisj
bourdaisj force-pushed the recycle_bin_api_endpoints branch from 9dd12c5 to 782291b Compare April 21, 2022 20:21
@bourdaisj
bourdaisj force-pushed the recycle_bin_api_endpoints branch from 782291b to f14e6e8 Compare April 21, 2022 20:27
@bourdaisj

Copy link
Copy Markdown
Contributor Author

I think the three endpoints I already implemented are fine as-is.
I'm thinking about adding a fourth one, 'read', which would returns the full chain of deleted items (children & parents) with their ids as well as some (limited) informations about them.
Wdyt? @ssddanbrown

@ssddanbrown

Copy link
Copy Markdown
Member

@Julesdevops I would prefer the most minimal approach that covers your use-case, which sounds like it may be covered by the existing three?

If (and only if) the extra detail was really needed I'd be tempted to say an additional parameter on the existing book/chapter/page/shelf "read" endpoints might be better suited to avoid needing a more complex implementation for this specific use-case.

@ssddanbrown

Copy link
Copy Markdown
Member

@Julesdevops Let me know your intention either way. No rush on the actual work but I'll be wrapping up the next feature release over the next week so, if you're happy with the current state, I can plan to sneak this in v22.04 otherwise we can plan for a latter release.

@bourdaisj

Copy link
Copy Markdown
Contributor Author

@ssddanbrown It already covers my use-case indeed. If someone is facing a more complex use-case someday I'd be happy to follow-up on this though.
I'll do a little pass on the code, doc and then I will mark this as ready for review

@bourdaisj
bourdaisj force-pushed the recycle_bin_api_endpoints branch 5 times, most recently from ea66904 to 5307cdb Compare April 24, 2022 08:33
@bourdaisj
bourdaisj force-pushed the recycle_bin_api_endpoints branch from 5307cdb to 14bccae Compare April 24, 2022 08:53
@bourdaisj
bourdaisj marked this pull request as ready for review April 24, 2022 08:55
@ssddanbrown ssddanbrown added this to the v22.04 milestone Apr 25, 2022
ssddanbrown added a commit that referenced this pull request Apr 25, 2022
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.
ssddanbrown added a commit that referenced this pull request Apr 25, 2022
- Means we can use these simpler types in API response, As desired in #3377.

Closes #3395
@ssddanbrown
ssddanbrown merged commit 14bccae into BookStackApp:development Apr 25, 2022
@ssddanbrown

ssddanbrown commented Apr 25, 2022

Copy link
Copy Markdown
Member

Thanks again for this @Julesdevops, Now merged for next release.

During review, I did make a series of changes detailed in commit ff8dade. Everything was functionally great and high-quality, most of the changes I made were just alignment with existing codebase conventions. The main significant other change was around how entity children and parent details were provided back on the list response. If you have any queries on my changes feel free to ask.

I wasn't a fan of exposing internal namespacing for API use (deletable_type) but I saw the value in having this for identification and filtering, so I also followed this up with 0930e85 which simplifies all internal morph types within the database to simple page/book/chapter/bookshelf names instead of namespaces.

@bourdaisj

Copy link
Copy Markdown
Contributor Author

@ssddanbrown Fair enough. Thanks for following up on this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants