-
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
1e749f0
commit 6191e20
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