-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Patterns: check for edited entity content property when exporting #63227
Conversation
…ecord or getEditedEntityRecord check for content?.raw and content. The reason being getEditedEntityRecord calls getRawEntityRecord. getRawEntityRecord maps properties to their raw values.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Flaky tests detected in d5cb57e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9849374854
|
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.
Thank you!
Thanks for the quick review 🙇🏻 |
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.
Thanks for the quick fix!
However, the format of the item
object, which is an argument to the getJsonFromItem()
function, is different in the wp/6.6
branch, so automatic cherry-pick may not work.
I did a quick test, and the following changes may be necessary in the wp/6.6
branch.
{
//...
content: item?.patternPost?.content?.raw || item.content,
syncStatus:
item?.patternPost?.wp_pattern_sync_status ||
item.wp_pattern_sync_status,
},
Thanks @t-hamano It looks like I'll need to make it reflect the state before 69a416f#diff-004f063061a2d1f93bea46f595d9d2ee876e371debd30c8027280957d47cdf2bL26 since #63042 doesn't appear to have been merged into |
@@ -22,7 +22,10 @@ function getJsonFromItem( item: Pattern ) { | |||
{ | |||
__file: item.type, | |||
title: getItemTitle( item ), | |||
content: item.content.raw, | |||
content: | |||
typeof item.content === 'string' |
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.
I ended up have to do a type check anyway because "Typescript"
There was a conflict while trying to cherry-pick the commit to the wp/6.6 branch. Please resolve the conflict manually and create a PR to the wp/6.6 branch. PRs to wp/6.6 are similar to PRs to trunk, but you should base your PR on the wp/6.6 branch instead of trunk.
|
…rdPress#63227) * Because an item can either be an entity record fetched via getEntityRecord or getEditedEntityRecord check for content?.raw and content. The reason being getEditedEntityRecord calls getRawEntityRecord. getRawEntityRecord maps properties to their raw values. * Update type and add type check to keep the type linter happy Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
…rdPress#63227) * Because an item can either be an entity record fetched via getEntityRecord or getEditedEntityRecord check for content?.raw and content. The reason being getEditedEntityRecord calls getRawEntityRecord. getRawEntityRecord maps properties to their raw values. * Update type and add type check to keep the type linter happy Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
What? How?
(Maybe) fixes #63217
Ensures that content is exported when exporting custom patterns from the editor pattern side bar.
Check for
item.content.raw
anditem.content
when exporting item JSON, e.g., for a custom pattern.This bug was reported in WordPress slack by @jeflopodev. Thank you!
Why?
The "item" passed to getJsonFromItem is fetched using getEditedEntityRecord.
getEditedEntityRecord
calls getRawEntityRecord.getRawEntityRecord
maps properties to their raw values, socontent.raw
will be mapped tocontent
.Because an item can either be an entity record fetched via
getEntityRecord
orgetEditedEntityRecord
, I think we should support both formats.Testing Instructions
Example:
Kapture.2024-07-08.at.17.25.20.mp4