Skip to content

Commit

Permalink
Filling in the details :)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed May 16, 2023
1 parent de07188 commit dcabb2e
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
__experimentalText as Text,
ExternalLink,
} from '@wordpress/components';
import { store as coreStore, useEntityRecord } from '@wordpress/core-data';
import {
store as coreStore,
useEntityRecord,
useEntityRecords,
} from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
import { pencil } from '@wordpress/icons';

Expand Down Expand Up @@ -63,7 +67,7 @@ function getPageDetails( page ) {
return [
{
label: 'Template',
value: page?.template ? page?.template : 'Default',
value: page?.templateTitle,
},
{
label: 'Parent',
Expand All @@ -90,6 +94,16 @@ export default function SidebarNavigationScreenPage() {
} = useNavigator();

const { record } = useEntityRecord( 'postType', 'page', postId );
const { records: templates, isResolving: areTemplatesLoading } =
useEntityRecords( 'postType', 'wp_template', {
per_page: -1,
} );

const templateTitle = areTemplatesLoading
? ''
: templates?.find( ( template ) => template?.slug === record?.template )
?.title?.rendered || 'Default';

const parentTitle = useSelect(
( select ) => {
const parent = record?.parent
Expand All @@ -110,6 +124,7 @@ export default function SidebarNavigationScreenPage() {
},
[ record ]
);

return (
<SidebarNavigationScreen
title={ record ? decodeEntities( record?.title?.rendered ) : null }
Expand Down Expand Up @@ -162,6 +177,7 @@ export default function SidebarNavigationScreenPage() {
<SidebarDetails
details={ getPageDetails( {
parentTitle,
templateTitle,
...record,
} ) }
/>
Expand Down

0 comments on commit dcabb2e

Please sign in to comment.