Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use discard in delete action when document is not published #6535

Merged
merged 1 commit into from
May 6, 2024

Conversation

cngonzalez
Copy link
Member

Description

The delete action in server side document actions requires a published document. In those cases when there is not a published document, we can't use this endpoint.

This PR adds logic for those cases by using the discard endpoint instead, and adds a few tests.

What to review

That the logic makes sense and this is how we want to proceed. We can always work with other teams to ensure we're doing something semantic that won't hinder us later.

Testing

This PR adds two tests for the delete action.

@cngonzalez cngonzalez requested a review from a team as a code owner April 30, 2024 16:38
@cngonzalez cngonzalez requested review from bjoerge and removed request for a team April 30, 2024 16:38
Copy link

vercel bot commented Apr 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview May 6, 2024 10:09pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2024 10:09pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2024 10:09pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview May 6, 2024 10:09pm

return vXClient.observable.request({
url: `/data/actions/${dataset}`,
method: 'post',
tag: 'document.delete',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've maintained the tag as document.delete so we have a sense of what the user's intent was. We can change it to document.discard if we don't like this choice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a problem with changing this to "document.discard", The fact that the button says "Delete" in this case feels more coincidental, and you could argue that it might as well say "Discard draft" when there is no published document.

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Apr 30, 2024

Component Testing Report Updated May 6, 2024 10:13 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 27s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 31s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 6s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 5s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 21s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 23s 9 0 0

Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work - thanks for adding tests ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants