-
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.
- Loading branch information
1 parent
ea74a30
commit 0433f44
Showing
6 changed files
with
108 additions
and
60 deletions.
There are no files selected for viewing
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
52 changes: 52 additions & 0 deletions
52
packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/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,52 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { Button } from '@wordpress/components'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import SidebarNavigationScreen from '../sidebar-navigation-screen'; | ||
import { unlock } from '../../private-apis'; | ||
import { store as editSiteStore } from '../../store'; | ||
|
||
export default function SidebarNavigationScreenNavigationItem() { | ||
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); | ||
|
||
const { post } = useSelect( ( select ) => { | ||
const { getEditedPostContext } = select( editSiteStore ); | ||
const { getEntityRecord } = select( coreStore ); | ||
const { postType, postId } = getEditedPostContext() ?? {}; | ||
|
||
// The currently selected entity to display. | ||
// Typically template or template part in the site editor. | ||
return { | ||
post: | ||
postId && postType | ||
? getEntityRecord( 'postType', postType, postId ) | ||
: null, | ||
}; | ||
}, [] ); | ||
|
||
return ( | ||
<SidebarNavigationScreen | ||
path="/navigation/single" | ||
title={ post ? decodeEntities( post?.title?.rendered ) : null } | ||
actions={ | ||
<Button | ||
variant="primary" | ||
onClick={ () => setCanvasMode( 'edit' ) } | ||
> | ||
{ __( 'Edit' ) } | ||
</Button> | ||
} | ||
content={ | ||
post ? decodeEntities( post?.description?.rendered ) : 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
0433f44
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 in 0433f44.
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/4164488096
📝 Reported issues:
specs/editor/various/multi-block-selection.test.js
specs/editor/various/inserting-blocks.test.js
specs/editor/various/autosave.test.js