-
Notifications
You must be signed in to change notification settings - Fork 442
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
refactor: migrate @sanity/presentation
codebase
#8312
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@sanity/[email protected] |
2ca06a3
to
9078d45
Compare
9078d45
to
d8923d4
Compare
No changes to documentation |
Component Testing Report Updated Jan 17, 2025 6:29 PM (UTC) ❌ Failed Tests (1) -- expand for details
|
⚡️ Editor Performance ReportUpdated Fri, 17 Jan 2025 18:31:28 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
d8923d4
to
4f05526
Compare
4f05526
to
e1e42ba
Compare
e1e42ba
to
1120ad8
Compare
1120ad8
to
884967a
Compare
6cb220a
to
1aaf5c4
Compare
1aaf5c4
to
697e9a4
Compare
} | ||
` | ||
|
||
export const Resizer: FunctionComponent<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT, We have a Resizer that we could replace this one with as a next step. packages/sanity/src/core/components/resizer/Resizer.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do that in a follow up PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sure! Added some small suggestions for follow up, nothing is blocking.
white-space: pre-wrap; | ||
` | ||
|
||
export function DocumentListPane(props: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT - follow up, could be good to rename this file to something else to avoid confusions with the structure/documentListPane
white-space: pre-wrap; | ||
` | ||
|
||
export function DocumentPane(props: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT - follow up, could be good to rename this file to something else to avoid confusions with the structure/DocumentPane
@@ -0,0 +1,12 @@ | |||
export function debounce<F extends (...args: Parameters<F>) => ReturnType<F>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT, follow up, could be replaced for debounce from lodash
const value = props.value as SanityDocument | ||
const documentId = value?._id ? getPublishedId(value?._id) : undefined | ||
|
||
if (isDocumentSchemaType(props.schemaType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT , follow up this seems to be added only once for the document.
I think you could benefit from using unstable_layout
instead of checking in each input if it's a document schema type.
import {API_VERSION} from './constants' | ||
import {type PreviewUrlOption} from './types' | ||
|
||
export function usePreviewUrl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up. - we have a usePreviewURL
function in structure
would be nice to see if we can join the two https://github.com/sanity-io/sanity/blob/corel-references/packages/sanity/src/structure/panes/document/usePreviewUrl.ts#L11-L12
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks for moving this @stipsan !
Added some small suggestions but nothing is blocking, more of some future iterations we can do.
697e9a4
to
7c490c6
Compare
Description
This PR copies over the codebase for
@sanity/presentation
on itsmain
branch. I've then refactored the code to pass our linter checks for things like:React.createContext
only being allowed insanity/_singletons
.ui-components
like<Button />
,<Tooltip>
and such should be used instead of importing directly from@sanity/ui
The codebase is otherwise the same. It's tempting to refactor and start cleaning things up, but it's important to note that after this PR is merged, I'll have to:
corel
branchcorel
branch, on top of Presentation.packages/presentation
from thevisual-editing
monorepo, and start adding over tests for more advanced presentation features that aren't enabled in the current test studio.It's more important that we reach the step where we can delete the code from
visual-editing
ASAP, so we avoid new work being done there, for example by external contributors.What to review
Is the new code following conventions ok?
It does pull in a bunch of new dependencies, and I want to work through them and get rid of unnecessary ones (we only use
suspend-react
in one instance, and it doesn't really need to). But they are lazy loaded, and isn't much different from how we re-export@sanity/presentation
as-is today.Testing
Tests are lacking, once this is merged in we can start working on playwright component tests for Presentation, as well as better vitest coverage for utils and parsers.
For now the PR build seems to work like it did before the migration: https://test-studio-git-migrate-presentation.sanity.dev/presentation/presentation/simpleBlock/716e2c8a-a168-4852-87e2-0c2b4d42c94b/body%5B_key==%22161e19ce1c6b%22%5D.children%5B_key==%22af5299cd594b%22%5D.text
Notes for release
The
@sanity/presentation
codebase has been migrated into thesanity
codebase. We've always recommended using Presentation Tool by importing it fromsanity/presentation
like so:If you've been following this pattern then this change won't impact you in any way.
If you've been installing
@sanity/presentation
and are using it directly (we've sometimes done this to let folks try out bugfixes before they ship in the next release ofsanity
):Then you need to search/replace all
from '@sanity/presentation'
statements in your codebase withfrom 'sanity/presentation'
, and uninstall@sanity/presentation
as it'll no longer receive updates.