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: add and use prefersLatestPublished parameter in DocumentPaneProvider #6486

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

cngonzalez
Copy link
Member

Description

In Presentation, users were having a somewhat misleading experience when clicking on a popover (which used an intent link) to load a document in the side pane. The document pane would show the latest revision, even if the users were looking at the "published" perspective.

This PR adds a parameter that can be read from an intent link (e.g., https://example.sanity.studio/production/intent/edit/id=the-page-id;type=page;prefersLatestPublished=true) which sets the revision of the latest published document on first load.

The document will then load in a readOnly state to that last published revision. Users can then switch revisions if needed.

What to review

You can test this out by running the studio locally and using an intent link like: http://localhost:3333/test/intent/edit/id=grrm;type=author;prefersLatestPublished=true

For documents that have never been published, or have been unpublished, it should default to the draft.

This is a bit of a blunt hammer. useEffect here might be a bit inelegant or intensive, and there may be more precautions to take to ensure we're not resetting state unnecessarily.

However, DocumentPaneProvider seems to be the only place where we have easy access to a document's _rev parameter. It might be more overhead to have the timelineStore look it up from history, and it doesn't seem to be available earlier in routing.

Testing

I unfortunately did not see a testing suite for the DocumentPaneProvider. Please let me know if I should add this in Storybook.

@cngonzalez cngonzalez requested a review from a team as a code owner April 25, 2024 20:29
@cngonzalez cngonzalez requested review from bjoerge and removed request for a team April 25, 2024 20:29
Copy link

vercel bot commented Apr 25, 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 Apr 29, 2024 0:52am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2024 0:52am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2024 0:52am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Apr 29, 2024 0:52am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Apr 25, 2024

Component Testing Report Updated Apr 29, 2024 12:56 PM (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) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 20s 6 3 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 4s 14 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 5s 18 0 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) 21s 9 0 0

Copy link
Member

@stipsan stipsan left a comment

Choose a reason for hiding this comment

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

@cngonzalez cngonzalez force-pushed the sdx-1291/add-prefers-latest-published branch from bbdb4d8 to ea8e9f8 Compare April 29, 2024 12:47
@cngonzalez cngonzalez added this pull request to the merge queue Apr 29, 2024
Merged via the queue into next with commit 3da55ae Apr 29, 2024
39 checks passed
@cngonzalez cngonzalez deleted the sdx-1291/add-prefers-latest-published branch April 29, 2024 12:58
github-merge-queue bot added a commit that referenced this pull request May 2, 2024
* fix(pte): show toolbar as active only if all blocks have tool active

* fix(pte): show toolbar as active only if all blocks have tool active

* fix(pte): correct toggling of marks when part mark is selected

* fix(core): change scrollintoview block to be nearest (#6328)

* fix(core): set scroll boundary to nearest (#6310)

* fix(core): set scroll boundary to nearest

* fix(core): add smooth scroll behavior

* fix(sanity): remove smooth behavior

---------

Co-authored-by: RitaDias <anarita151@gmail.com>

* fix(@sanity): issue where hidden unicode characters were bloating document in PTE (#6440)

* fix(portable-text-editor): issue shown in tests re stega. use duplicate code

* test(playwright-ct): add test

* chore(sanity): remove prettier linting

* test(sanity): fix missing snapshot

* test(sanity): update test after realising the test would pass always if comparing object number

* chore: test unicode removal

* chore: test unicode removal

* chore(@sanity): remove old solution

* fix(@sanity/block-tools): unicode issue. remove vercel/stega and move to block-tools

* test(@sanity/block-tools): for unicode

* fix(@sanity/block-tools): utf8 characters weren't beign filtered. using the vercel/stega

* chore: update lock file

* (chore): update pnpm lock

* chore: add codeowners to block-tools

* chore(deps): dedupe pnpm-lock.yaml (#6508)

Co-authored-by: github-merge-queue[bot] <118344674+github-merge-queue[bot]@users.noreply.github.com>

* fix(pte): tidying implementation

* fix(@sanity): issue where hidden unicode characters were bloating document in PTE (#6440)

* fix(portable-text-editor): issue shown in tests re stega. use duplicate code

* test(playwright-ct): add test

* chore(sanity): remove prettier linting

* test(sanity): fix missing snapshot

* test(sanity): update test after realising the test would pass always if comparing object number

* chore: test unicode removal

* chore: test unicode removal

* chore(@sanity): remove old solution

* fix(@sanity/block-tools): unicode issue. remove vercel/stega and move to block-tools

* test(@sanity/block-tools): for unicode

* fix(@sanity/block-tools): utf8 characters weren't beign filtered. using the vercel/stega

* chore: update lock file

* (chore): update pnpm lock

* chore(deps): dedupe pnpm-lock.yaml (#6508)

Co-authored-by: github-merge-queue[bot] <118344674+github-merge-queue[bot]@users.noreply.github.com>

* chore(deps): update dependency @sanity/pkg-utils to v6.8.8 (#6509)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: use prefersLatestPublished parameter in DocumentPaneProvider (#6486)

* fix(@sanity): issue where hidden unicode characters were bloating document in PTE (#6440)

* fix(portable-text-editor): issue shown in tests re stega. use duplicate code

* test(playwright-ct): add test

* chore(sanity): remove prettier linting

* test(sanity): fix missing snapshot

* test(sanity): update test after realising the test would pass always if comparing object number

* chore: test unicode removal

* chore: test unicode removal

* chore(@sanity): remove old solution

* fix(@sanity/block-tools): unicode issue. remove vercel/stega and move to block-tools

* test(@sanity/block-tools): for unicode

* fix(@sanity/block-tools): utf8 characters weren't beign filtered. using the vercel/stega

* chore: update lock file

* (chore): update pnpm lock

* chore(deps): dedupe pnpm-lock.yaml (#6508)

Co-authored-by: github-merge-queue[bot] <118344674+github-merge-queue[bot]@users.noreply.github.com>

* chore(deps): update dependency @sanity/pkg-utils to v6.8.8 (#6509)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(pte): simplifying activeAnnotations logic

* fix(pte): new isAnnotationActive static method

* fix(pte): retoring activeAnnotations method in editor

* fix(pte): retoring activeAnnotations method in editor

* fix(pte): fixing issue with multiple annotations in a single block

* fix(pte): fixing issue with multiple annotations in a single block

* fix(pte): fixing typing issue with PortableTextSpan

* fix(pte): fixing failing test since mark toggling has changed

* fix(pte): improving usage of isTextBlock for createWithPortableTextLists

* fix(portable-text-editor): fix issue where decoration would not target correctly (#6532)

* fix(pte): remove unused function in createWithPortableTextMarkModel

* exploration

* fix(pte): reverting incorrect merge

* fix(pte): testing new logic for tools in PTE

* fix(pte): reorg test cases

---------

Co-authored-by: Nina Andal Aarvik <nina@sanity.io>
Co-authored-by: RitaDias <anarita151@gmail.com>
Co-authored-by: RitaDias <rita@sanity.io>
Co-authored-by: Per-Kristian Nordnes <per.kristian.nordnes@gmail.com>
Co-authored-by: ecospark[bot] <128108030+ecospark[bot]@users.noreply.github.com>
Co-authored-by: github-merge-queue[bot] <118344674+github-merge-queue[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: cngonzalez <carolina.nicole.gonzalez@gmail.com>
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

3 participants