Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { TextControl } from '@wordpress/components';
import { useEntityProp } from '@wordpress/core-data';

export default function EditTemplateTitle( { template } ) {
const [ title, setTitle ] = useEntityProp(
'postType',
template.type,
'title',
template.id
);

return (
<TextControl
label={ __( 'Title' ) }
value={ title }
help={ __(
'Give the template a title that indicates its purpose, e.g. "Full Width".'
) }
onChange={ ( newTitle ) => {
setTitle( newTitle || template.slug );
} }
/>
);
}
19 changes: 12 additions & 7 deletions packages/edit-site/src/components/template-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from '../navigation-sidebar/navigation-panel/constants';
import { store as editSiteStore } from '../../store';
import TemplateAreas from './template-areas';
import EditTemplateTitle from './edit-template-title';

export default function TemplateDetails( { template, onClose } ) {
const { title, description } = useSelect(
Expand Down Expand Up @@ -55,13 +56,17 @@ export default function TemplateDetails( { template, onClose } ) {
return (
<div className="edit-site-template-details">
<div className="edit-site-template-details__group">
<Heading
level={ 4 }
weight={ 600 }
className="edit-site-template-details__title"
>
{ title }
</Heading>
{ template.is_custom ? (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I extract this into the custom util method, similar to isTemplateRevertable and isTemplateRemovable?

<EditTemplateTitle template={ template } />
) : (
<Heading
level={ 4 }
weight={ 600 }
className="edit-site-template-details__title"
>
{ title }
</Heading>
) }

{ description && (
<Text
Expand Down