Core Data: Move EntitiesSavedState component out of editor (rebase of #71948) - #80485
Conversation
The move commit added @wordpress/global-styles-engine to core-data's package.json but package-lock.json was not updated to match, causing the build's dependency-sync check to fail. Add the missing lock entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youknowriad
left a comment
There was a problem hiding this comment.
For me this is a one of the two good paths forward, so I'm approving.
There was a problem hiding this comment.
Pull request overview
Moves the “entities saved states” UI and related save/template helpers out of @wordpress/editor into @wordpress/core-data, exposing them via core-data private APIs while keeping editor re-exports for backwards compatibility.
Changes:
- Relocates
EntitiesSavedStates(and hook) plus related styles intocore-data, and wiressaveDirtyEntitiesas acorestore private action. - Switches editor/edit-site consumers to read
getTemplateInfo/getTemplatePartIcon(and EntitiesSavedStates) fromcore-dataprivate APIs. - Updates core-data build deps/TS refs and adjusts private API documentation.
Reviewed changes
Copilot reviewed 27 out of 32 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/editor/src/utils/index.js | Stops re-exporting getTemplatePartIcon from editor utils. |
| packages/editor/src/style.scss | Removes entities-saved-states styles from editor bundle. |
| packages/editor/src/store/selectors.js | Switches template helpers to core-data private APIs. |
| packages/editor/src/store/private-selectors.js | Switches template icon helper to core-data private APIs; removes meta-change selector. |
| packages/editor/src/store/private-actions.js | Removes saveDirtyEntities from editor private actions (moved to core-data). |
| packages/editor/src/private-apis.js | Removes EntitiesSavedStatesExtensible and template helper from editor private APIs. |
| packages/editor/src/components/save-publish-panels/index.js | Uses core-data private EntitiesSavedStates instead of editor component import. |
| packages/editor/src/components/post-excerpt/panel.js | Uses core-data private getTemplateInfo instead of editor util. |
| packages/editor/src/components/post-card-panel/index.js | Uses core-data private getTemplateInfo instead of editor util. |
| packages/editor/src/components/index.js | Re-exports EntitiesSavedStates + hook from core-data private APIs for back-compat. |
| packages/editor/src/components/document-bar/index.js | Uses core-data private getTemplateInfo instead of editor util. |
| packages/editor/README.md | Regenerates API docs; EntitiesSavedStates + hook now show “Undocumented declaration.” |
| packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js | Switches template-part icon helper to core-data private APIs. |
| packages/edit-site/src/components/save-panel/index.js | Switches entities-saved-states imports/unlocks from editor to core-data. |
| packages/edit-site/src/components/save-button/index.js | Dispatches saveDirtyEntities from core store; reads dirty-state hook from core-data private APIs. |
| packages/edit-site/src/components/editor/use-editor-title.js | Switches template helper unlock from editor to core-data private APIs. |
| packages/core-data/tsconfig.json | Adds TS project references needed by moved component/utilities. |
| packages/core-data/src/utils/test/get-template-info.js | Adds unit tests for the moved getTemplateInfo helper. |
| packages/core-data/src/utils/get-template-part-icon.js | Adds moved getTemplatePartIcon helper. |
| packages/core-data/src/utils/get-template-info.js | Adds moved getTemplateInfo helper (currently needs a guard/defaults fix). |
| packages/core-data/src/style.scss | Adds core-data stylesheet entry for entities-saved-states styles. |
| packages/core-data/src/private-apis.ts | Exposes moved component/hook/utils via core-data private APIs. |
| packages/core-data/src/private-actions.js | Adds saveDirtyEntities to core-data private actions. |
| packages/core-data/src/components/entities-saved-states/test/use-is-dirty.js | Updates tests after moving hook into core-data. |
| packages/core-data/src/components/entities-saved-states/style.scss | Adds entities-saved-states styles under core-data. |
| packages/core-data/src/components/entities-saved-states/index.js | Moves EntitiesSavedStates + extensible variant into core-data. |
| packages/core-data/src/components/entities-saved-states/hooks/use-is-dirty.js | Updates hook to select from STORE_NAME instead of importing core-data store object. |
| packages/core-data/src/components/entities-saved-states/entity-type-list.js | Updates entity list to select from STORE_NAME. |
| packages/core-data/src/components/entities-saved-states/entity-record-item.js | Updates template-title lookup to use moved getTemplateInfo and core store selectors. |
| packages/core-data/package.json | Adds dependencies required by the moved component/utilities (components/icons/notices/etc, clsx). |
| package-lock.json | Lockfile update for the core-data dependency additions. |
| docs/private-apis.md | Documents new core-data private exports (needs follow-up doc accuracy fixes). |
| Private exports: | ||
| - `EntitiesSavedStates` | ||
| - `EntitiesSavedStatesExtensible` | ||
| - `getTemplateInfo` | ||
| - `getTemplatePartIcon` | ||
| - `useEntityRecordsWithPermissions` |
| ### EntitiesSavedStates | ||
|
|
||
| Renders the component for managing saved states of entities. | ||
|
|
||
| _Parameters_ | ||
|
|
||
| - _props_ `Object`: The component props. | ||
| - _props.close_ `Function`: The function to close the dialog. | ||
| - _props.renderDialog_ `boolean=`: Whether to render the component with modal dialog behavior. | ||
| - _props.variant_ `string`: Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start. | ||
|
|
||
| _Returns_ | ||
|
|
||
| - `React.ReactNode`: The rendered component. | ||
| Undocumented declaration. | ||
|
|
|
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. |
There was a problem hiding this comment.
This file was moved but not all of its dependencies were moved. @wordpress/base-styles needs to be declared.
What / Why
This is a rebase of #71948 ("Core Data: Move
EntitiesSavedStatecomponent out of editor" by @youknowriad) onto currenttrunk. The original PR was ~4,400 commits behind and conflicting; this branch reapplies it on top of the latesttrunk.Rebase of #71948
What the PR does
Moves the
EntitiesSavedStatescomponent, its hooks/utils, and thesaveDirtyEntitiesaction from@wordpress/editorinto@wordpress/core-data:entities-saved-states/*component →core-data/src/components/entities-saved-states/get-template-info.js,get-template-part-icon.jsutils →core-data/src/utils/saveDirtyEntitiesaction →core-data/src/private-actions.jscore-dataprivate APIs (EntitiesSavedStates,EntitiesSavedStatesExtensible,getTemplateInfo,getTemplatePartIcon,useEntitiesSavedStatesIsDirty)editorre-exportsEntitiesSavedStates/useEntitiesSavedStatesIsDirtyfor back-compat; consumers updated to readgetTemplateInfo/getTemplatePartIconfromcore-data.Notable rebase decisions (please verify)
saveDirtyEntitieskept trunk's newer logic. The moved action uses trunk's current implementation (await onSave()from Editor: saveDirtyEntities: don't allow onSave to filter records #79850,successNoticeContentparam) rather than the older version in the original PR.__unstableMarkLastChangeAsPersistent()kept functional. Original PR commit 2 ("Remove useless code") deleted thisblockEditorStorecall. I instead kept it active in the core-data version to preserve trunk's exact save behavior (core-data already depends onblock-editorhere). Commit 2 was therefore skipped. This is the main thing to confirm.post-excerpt/panel.jsandsidebar-navigation-screen-patternsnow pullgetTemplateInfo/getTemplatePartIconfromcore-data; restored ablockEditorStoreimport ineditor/store/private-actions.jsthat the move had dropped.wp-core-datastyle registration inclient-assets.php, so that part is already present.Testing done
core-dataunit tests: 217 pass (incl. moveduse-is-dirty,private-actions,private-selectors)editorstore selector tests: 145 passtrunkwarnings remain (verified 1:1 against trunk)docs:api-ref)Full editor/site-editor e2e (save flows, global styles save panel) still worth a manual pass.