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(structure): navigate to version when document only has versions #8759

Draft
wants to merge 12 commits into
base: next
Choose a base branch
from

Conversation

RitaDias
Copy link
Contributor

@RitaDias RitaDias commented Feb 25, 2025

Description

  • Open the version of a document when that version is the only one (no draft, no published)
  • In instances where multiple versions exist (but no draft and no published), then it will default to the first version
  • Fix issues around the disabling of the draft
  • Fix whitespace in add to release banner
image

Note

We don't want to set the pinned version to match the version because, imo, it makes sense to still have the version open when you press a different pinned version to add them to another release

image

What to review

Does it make sense? Is there a better way to go about it?

Testing

Updated tests, added new test
To test the provider would e a larger task which I think best left outside of the scope of this PR

Notes for release

When a document only has a version of itself, it will open that version instead of the draft

Copy link

vercel bot commented Feb 25, 2025

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

Name Status Preview Comments Updated (UTC)
page-building-studio ❌ Failed (Inspect) Feb 27, 2025 1:54pm
performance-studio ❌ Failed (Inspect) 💬 Add feedback Feb 27, 2025 1:54pm
test-studio ❌ Failed (Inspect) Feb 27, 2025 1:54pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 1:54pm
test-next-studio ⬜️ Ignored (Inspect) Feb 27, 2025 1:54pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Feb 25, 2025

Component Testing Report Updated Feb 25, 2025 2:29 PM (UTC)

❌ Failed Tests (4) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 22s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 17s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 1m 23s 5 0 1
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 57s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 17s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 32s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ❌ Failed (Inspect) 1m 58s 14 0 1
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 51s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ❌ Failed (Inspect) 3m 25s 19 0 2
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 15s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 57s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Contributor

github-actions bot commented Feb 25, 2025

⚡️ Editor Performance Report

Updated Thu, 27 Feb 2025 13:05:15 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 27.0 efps (37ms) 21.3 efps (47ms) +10ms (+27.0%) 🔴
article (body) 67.3 efps (15ms) 72.5 efps (14ms) -1ms (-/-%)
article (string inside object) 27.8 efps (36ms) 23.3 efps (43ms) +7ms (+19.4%)
article (string inside array) 24.4 efps (41ms) 20.8 efps (48ms) +7ms (+17.1%)
recipe (name) 45.5 efps (22ms) 47.6 efps (21ms) -1ms (-4.5%)
recipe (description) 52.6 efps (19ms) 55.6 efps (18ms) -1ms (-5.3%)
recipe (instructions) 99.9+ efps (5ms) 99.9+ efps (6ms) +1ms (-/-%)
synthetic (title) 18.9 efps (53ms) 19.6 efps (51ms) -2ms (-3.8%)
synthetic (string inside object) 18.9 efps (53ms) 19.0 efps (53ms) -1ms (-0.9%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 37ms 41ms 57ms 398ms 634ms 9.8s
article (body) 15ms 18ms 26ms 132ms 197ms 5.8s
article (string inside object) 36ms 38ms 44ms 151ms 391ms 7.1s
article (string inside array) 41ms 44ms 50ms 75ms 350ms 7.0s
recipe (name) 22ms 24ms 27ms 44ms 0ms 7.2s
recipe (description) 19ms 20ms 22ms 53ms 0ms 4.9s
recipe (instructions) 5ms 7ms 7ms 29ms 0ms 3.1s
synthetic (title) 53ms 56ms 58ms 232ms 1006ms 26.8s
synthetic (string inside object) 53ms 57ms 70ms 390ms 1568ms 9.5s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 47ms 54ms 76ms 386ms 1122ms 11.9s
article (body) 14ms 17ms 31ms 184ms 558ms 5.9s
article (string inside object) 43ms 46ms 54ms 237ms 307ms 7.4s
article (string inside array) 48ms 50ms 61ms 170ms 613ms 8.0s
recipe (name) 21ms 22ms 24ms 41ms 0ms 7.0s
recipe (description) 18ms 19ms 20ms 39ms 0ms 4.6s
recipe (instructions) 6ms 7ms 9ms 25ms 0ms 3.2s
synthetic (title) 51ms 56ms 73ms 450ms 966ms 16.9s
synthetic (string inside object) 53ms 56ms 59ms 423ms 1053ms 8.1s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

Copy link
Contributor

github-actions bot commented Feb 25, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.4% 54361 / 128207
🔵 Statements 42.4% 54361 / 128207
🔵 Functions 47.22% 2727 / 5774
🔵 Branches 79.43% 10260 / 12916
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/sanity/src/core/index.ts 100% 100% 100% 100%
packages/sanity/src/core/releases/components/VersionInlineBadge.tsx 31.57% 100% 0% 31.57% 10-19, 25-29, 35-42
packages/sanity/src/core/releases/hooks/index.ts 100% 100% 100% 100%
packages/sanity/src/core/releases/hooks/useDocumentVersionList.ts 24% 100% 0% 24% 30-57
packages/sanity/src/structure/i18n/resources.ts 100% 100% 100% 100%
packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx 2.41% 100% 100% 2.41% 87-986
packages/sanity/src/structure/panes/document/documentPanel/DocumentPanel.tsx 13.63% 100% 0% 13.63% 49-60, 63-285
packages/sanity/src/structure/panes/document/documentPanel/banners/OpenReleaseToEditBanner.tsx 12.06% 100% 0% 12.06% 18-78
packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveList.tsx 84.7% 77.08% 50% 84.7% 38-72, 126-128, 132-135, 148-149, 174-177, 193-194, 294-297
Generated in workflow #31225 for commit 57e2b9e by the Vitest Coverage Report Action

@RitaDias RitaDias changed the title fix(structure): navigate to version when no draft or published document fix(structure): navigate to version when document only has versions Feb 26, 2025
@RitaDias RitaDias marked this pull request as ready for review February 26, 2025 08:29
…a orphan version but no draft)

fix(structre): make sure that you get the first version of the document in case if there are no drafts or published when viewing a different release

fix(structure): fix issue when reading versins when they don't exist / drafts and published exist

fix(structure): fix issue where you couldn't remove the pinned version
@RitaDias
Copy link
Contributor Author

@jordanl17 moved to draft again after some notes from marius 👍

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.

1 participant