-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the template title and type to the site hub
- Loading branch information
1 parent
be0def0
commit cc9f480
Showing
7 changed files
with
225 additions
and
125 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
packages/edit-site/src/components/edited-entity-title/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { store as editorStore } from '@wordpress/editor'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editSiteStore } from '../../store'; | ||
|
||
export default function useEditedEntityRecord() { | ||
const { record, title, isLoaded } = useSelect( ( select ) => { | ||
const { getEditedPostType, getEditedPostId } = select( editSiteStore ); | ||
const { getEditedEntityRecord } = select( coreStore ); | ||
const { __experimentalGetTemplateInfo: getTemplateInfo } = | ||
select( editorStore ); | ||
const postType = getEditedPostType(); | ||
const postId = getEditedPostId(); | ||
const _record = getEditedEntityRecord( 'postType', postType, postId ); | ||
const _isLoaded = !! postId; | ||
|
||
return { | ||
record: _record, | ||
title: getTemplateInfo( _record ).title, | ||
isLoaded: _isLoaded, | ||
}; | ||
}, [] ); | ||
|
||
return { | ||
isLoaded, | ||
record, | ||
getTitle: () => ( title ? decodeEntities( title ) : null ), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
cc9f480
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.
Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3757045293
📝 Reported issues:
specs/editor/plugins/meta-boxes.test.js
Browse all
#45332 inspecs/editor/various/inserting-blocks.test.js
specs/editor/various/block-deletion.test.js
specs/editor/various/multi-block-selection.test.js
specs/editor/various/multi-block-selection.test.js