diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js index 03cc7ecbec75b..4ee8d7d3449cb 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js @@ -74,7 +74,7 @@ function useTemplateTitleAndDescription( postType, postId ) { ); - return { title, description }; + return { title, description, template: record }; } export default function SidebarNavigationScreenTemplate() { diff --git a/packages/edit-site/src/components/template-actions/index.js b/packages/edit-site/src/components/template-actions/index.js index 0b54d6ef3ea71..5613213bfaa3c 100644 --- a/packages/edit-site/src/components/template-actions/index.js +++ b/packages/edit-site/src/components/template-actions/index.js @@ -4,8 +4,8 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; import { __, sprintf } from '@wordpress/i18n'; -import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components'; -import { moreVertical } from '@wordpress/icons'; +import { privateApis as componentsPrivateApis } from '@wordpress/components'; +// import { Icon, moreVertical } from '@wordpress/icons'; import { store as noticesStore } from '@wordpress/notices'; /** @@ -16,6 +16,21 @@ import isTemplateRemovable from '../../utils/is-template-removable'; import isTemplateRevertable from '../../utils/is-template-revertable'; import RenameMenuItem from './rename-menu-item'; +import { unlock } from '../../private-apis'; + +const { + DropdownMenuV2, + // DropdownMenuCheckboxItemV2, + DropdownMenuGroupV2, + DropdownMenuItemV2, + // DropdownMenuLabelV2, + // DropdownMenuRadioGroupV2, + // DropdownMenuRadioItemV2, + // DropdownMenuSeparatorV2, + // DropdownSubMenuV2, + // DropdownSubMenuTriggerV2, +} = unlock( componentsPrivateApis ); + export default function TemplateActions( { postType, postId, @@ -70,48 +85,44 @@ export default function TemplateActions( { } return ( - } + trigger={ } > - { ( { onClose } ) => ( - - { isRemovable && ( - <> - - { - removeTemplate( template ); - onRemove?.(); - onClose(); - } } - > - { __( 'Delete' ) } - - - ) } - { isRevertable && ( - + { isRemovable && ( + <> + + { - revertAndSaveTemplate(); - onClose(); + removeTemplate( template ); + onRemove?.(); } } > - { __( 'Clear customizations' ) } - - ) } - - ) } - + { __( 'Delete' ) } + + + ) } + { isRevertable && ( + { + revertAndSaveTemplate(); + // onClose(); + } } + > + { __( 'Clear customizations' ) } + + ) } + + ); } diff --git a/packages/edit-site/src/components/template-actions/rename-menu-item.js b/packages/edit-site/src/components/template-actions/rename-menu-item.js index dec7f0bc8bf7d..c857480623437 100644 --- a/packages/edit-site/src/components/template-actions/rename-menu-item.js +++ b/packages/edit-site/src/components/template-actions/rename-menu-item.js @@ -15,7 +15,11 @@ import { import { store as coreStore } from '@wordpress/core-data'; import { store as noticesStore } from '@wordpress/notices'; -export default function RenameMenuItem( { template, onClose } ) { +export default function RenameMenuItem( { + template, + onClose, + as: UsedComponent = MenuItem, +} ) { const [ title, setTitle ] = useState( () => template.title.rendered ); const [ isModalOpen, setIsModalOpen ] = useState( false ); @@ -64,14 +68,14 @@ export default function RenameMenuItem( { template, onClose } ) { return ( <> - { setIsModalOpen( true ); setTitle( template.title.rendered ); } } > { __( 'Rename' ) } - + { isModalOpen && (