Skip to content

Commit

Permalink
Add template details to template parts
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Oct 8, 2021
1 parent 1264b12 commit 2863123
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
37 changes: 16 additions & 21 deletions packages/edit-site/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,22 @@ export default function Header( {
</div>

<div className="edit-site-header_center">
{ 'wp_template' === templateType && (
<DocumentActions
entityTitle={ entityTitle }
entityLabel="template"
isLoaded={ isLoaded }
>
{ ( { onClose } ) => (
<TemplateDetails
template={ template }
onClose={ onClose }
/>
) }
</DocumentActions>
) }
{ 'wp_template_part' === templateType && (
<DocumentActions
entityTitle={ entityTitle }
entityLabel="template part"
isLoaded={ isLoaded }
/>
) }
<DocumentActions
entityTitle={ entityTitle }
entityLabel={
templateType === 'wp_template_part'
? 'template part'
: 'template'
}
isLoaded={ isLoaded }
>
{ ( { onClose } ) => (
<TemplateDetails
template={ template }
onClose={ onClose }
/>
) }
</DocumentActions>
</div>

<div className="edit-site-header_end">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export default function TemplateAreas() {
[]
);

if ( ! Object.keys( templateAreaBlocks ).length ) {
return null;
}

return (
<section className="edit-site-template-card__template-areas">
<Heading
Expand Down
8 changes: 4 additions & 4 deletions packages/edit-site/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export function* revertTemplate( template ) {
coreStore,
'getEditedEntityRecord',
'postType',
'wp_template',
template.type,
template.id
);
// We are fixing up the undo level here to make sure we can undo
Expand All @@ -400,7 +400,7 @@ export function* revertTemplate( template ) {
coreStore,
'editEntityRecord',
'postType',
'wp_template',
template.type,
template.id,
{
content: serializeBlocks, // required to make the `undo` behave correctly
Expand All @@ -417,7 +417,7 @@ export function* revertTemplate( template ) {
coreStore,
'editEntityRecord',
'postType',
'wp_template',
template.type,
fileTemplate.id,
{
content: serializeBlocks,
Expand All @@ -429,7 +429,7 @@ export function* revertTemplate( template ) {
const undoRevert = async () => {
await dispatch( coreStore ).editEntityRecord(
'postType',
'wp_template',
template.type,
edited.id,
{
content: serializeBlocks,
Expand Down

0 comments on commit 2863123

Please sign in to comment.