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

feat: releases v0.5 #2081

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

feat: releases v0.5 #2081

wants to merge 29 commits into from

Conversation

pedrobonamin
Copy link
Contributor

Pre read

This branch builds on top of releases branch, which includes the necessary packages updates.

  • @sanity/client: 6.22.2-bundle-perspective
  • sanity: corel
  • @sanity/ui: local tar file (will be updated soon to a npm version)
  • @sanity/icons: local tar file (will be updated soon to a npm version)

Next steps:

  • Support for previews outside of the studio, think on adding the bundlePerspective data as a query param
  • update applySourceDocuments in the client to work with perspectives. Investigate what this does.
  • Test things and find bugs.
  • Creating a version document from presentation doesn't work as expected

Changes:

With the introduction of releases the perspective is now a global studio concern and a new type of perspective has been introduced bundle.{releaseId}

Example of a published release selection
Screenshot 2024-10-31 at 13 58 23
Screenshot 2024-10-31 at 13 58 38

Video 🎥

Video explaining the details https://www.loom.com/share/3894e17c19b247548dccf3976f661a29?sid=59625a39-bdbf-400f-ad9c-d4243acf4018

The issue with the drafts is now fixed.

Perspective selector removed

Given we have this new perspective selector, the draft | published selector from Presentation tool was removed

<RevisionSwitcher/> removed

This is not needed anymore, structure now knows about perspectives and it infers them from the global state and the form reacts according to the perspective selected.

Loaders updated.

The loaders LiveQueries and LoaderQueries were updated to use the bundlePerspective param.

Perspective type updated to include bundle.${string}

The global perspective can be any of published | previewDrafts | bundle.${string} this has been reflected in the code by updating the types were needed, this could be centralized instead of manually adding it everywhere, but wanted to easily reflect the intention in code for the review.
This is relevant at the moment we need to query the data. When receiving a bundle.${string} perspective it should not use the perspective option in client.fetch , instead, it should use the bundlePerspective option, which takes an array of perspectives.

How does bundlePerspective works:
bundles perspective allows the client to fetch data in a similar way as previewDrafts, but instead of only stacking changes of published and drafts, it allows us to stack multiple perspectives inside.
So given you have the following documents:

-  foo, drafts.foo, versions.summer.foo
-  bar, versions.winter.bar
  • If you use bundlePerspective="summer", you will get the documents versions.summer.foo and bar
  • If you use bundlePerspective="winter,summer,drafts", you will get the documents versions.summer.fooand - -versions.winter.bar (This supports multiple perspectives in one query)
  • if you use bundlePerspective="drafts", you will get drafts.foo and bar

This bundlePerspective array is exposed by the usePerspective hook from sanity which takes care of applying the perspectives in the correct order, the perspectives will apply on top of each other from right to left.
So if the same document is in two perspectives, it will be returned only in the first one found.

@pedrobonamin pedrobonamin requested a review from a team as a code owner November 4, 2024 10:16
Copy link

vercel bot commented Nov 4, 2024

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

Name Status Preview Comments Updated (UTC)
live-visual-editing-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 2:46pm
visual-editing-next-with-i18n ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 2:46pm
visual-editing-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 2:46pm
7 Skipped Deployments
Name Status Preview Comments Updated (UTC)
visual-editing-astro ⬜️ Ignored (Inspect) Visit Preview Nov 6, 2024 2:46pm
visual-editing-next ⬜️ Ignored (Inspect) Visit Preview Nov 6, 2024 2:46pm
visual-editing-nuxt ⬜️ Ignored (Inspect) Visit Preview Nov 6, 2024 2:46pm
visual-editing-page-builder-demo ⬜️ Ignored (Inspect) Visit Preview Nov 6, 2024 2:46pm
visual-editing-remix ⬜️ Ignored (Inspect) Visit Preview Nov 6, 2024 2:46pm
visual-editing-studio ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 2:46pm
visual-editing-svelte ⬜️ Ignored (Inspect) Visit Preview Nov 6, 2024 2:46pm

@pedrobonamin pedrobonamin mentioned this pull request Nov 4, 2024
4 tasks
@pedrobonamin pedrobonamin changed the base branch from releases to main November 4, 2024 10:58
@vercel vercel bot temporarily deployed to Preview – visual-editing-astro November 4, 2024 11:05 Inactive
pedrobonamin and others added 15 commits November 6, 2024 14:09
* chore: find cause

* fix: handle comlink disconnect

* chore: remove debug code
* chore: fix live-next build

* fix: support bundle perspective
…2084)

* chore(release-overlay-previews): add simple release overlay previews

wip improve data fetching

wip ui

tidy up comments

tidy up postmessagereleases

ensure preview is only shown when data attribute is set

* chore(release-overlay-previews): use useReleases hook

* chore(release-overlay-previews): add releases.data to comlink useEffect deps

* fix: update how the nearestRelease is obtained

---------

Co-authored-by: pedrobonamin <[email protected]>
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.

4 participants