sanity-io / sanity

Sanity Studio – Rapidly configure content workspaces powered by structured content
https://www.sanity.io
MIT License
4.96k stars 390 forks source link

feat(sanity): use optimistic locking when publishing documents #6711

Closed juice49 closed 1 week ago

juice49 commented 2 weeks ago

Description

This branch adds optimistic locking when publishing documents via the Actions API by adopting its ifDraftRevisionId and ifPublishedRevisionId guards. These guards are a recent addition to the Actions API.

Optimistic locking ensures the editor can see the latest state of both the draft document they are publishing, and the published document they are choosing to replace.

Additionally, this branch adds a check prior to publishing that ensures Studio has a draft snapshot. This check is already in place when publishing via the Mutations API. It stands to reason that the editor must be able to see the draft they are choosing to publish.

What to review

Is the usage of the ifDraftRevisionId and ifPublishedRevisionId guards correct?

Testing

vercel[bot] commented 2 weeks ago

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

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2024 11:48am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2024 11:48am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2024 11:48am
1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **studio-workshop** | ⬜️ Ignored ([Inspect](https://vercel.com/sanity-io/studio-workshop/3DTfYbqv8QrcbT5kYpkpara2zmbb)) | [Visit Preview](https://studio-workshop-git-feat-sdx-1315-actions-api-optimistic-82358f.sanity.build) | | May 17, 2024 11:48am |
github-actions[bot] commented 2 weeks ago

No changes to documentation

github-actions[bot] commented 2 weeks ago

Component Testing Report Updated May 17, 2024 11:53 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 35s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 25s 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 16s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 3s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 6s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 20s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 30s 12 0 0