diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/replace-template-button.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/replace-template-button.js deleted file mode 100644 index 658aacd331deb..0000000000000 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/replace-template-button.js +++ /dev/null @@ -1,89 +0,0 @@ -/** - * WordPress dependencies - */ -import { useSelect, useDispatch } from '@wordpress/data'; -import { useState } from '@wordpress/element'; -import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor'; -import { MenuItem, Modal } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; -import { store as coreStore } from '@wordpress/core-data'; -import { useAsyncList } from '@wordpress/compose'; -import { serialize } from '@wordpress/blocks'; - -/** - * Internal dependencies - */ -import { store as editSiteStore } from '../../../store'; - -export default function ReplaceTemplateButton( { - onClick, - availableTemplates, -} ) { - const { editEntityRecord } = useDispatch( coreStore ); - const [ showModal, setShowModal ] = useState( false ); - const onClose = () => { - setShowModal( false ); - }; - - const { postId, postType } = useSelect( ( select ) => { - return { - postId: select( editSiteStore ).getEditedPostId(), - postType: select( editSiteStore ).getEditedPostType(), - }; - }, [] ); - - const onTemplateSelect = async ( selectedTemplate ) => { - onClose(); // Close the template suggestions modal first. - onClick(); - await editEntityRecord( 'postType', postType, postId, { - blocks: selectedTemplate.blocks, - content: serialize( selectedTemplate.blocks ), - } ); - }; - - if ( ! availableTemplates.length || availableTemplates.length < 1 ) { - return null; - } - - return ( - <> - setShowModal( true ) } - > - { __( 'Replace template' ) } - - - { showModal && ( - -
- -
-
- ) } - - ); -} - -function TemplatesList( { availableTemplates, onSelect } ) { - const shownTemplates = useAsyncList( availableTemplates ); - - return ( - - ); -}