From d3f0c8ecbf465f1536d4ac30da03deef24032f79 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Fri, 14 Jul 2023 15:43:46 +0200 Subject: [PATCH] Change Delete page menu item to Move to trash. --- .../src/components/page-actions/index.js | 4 +-- ...e-menu-item.js => trash-page-menu-item.js} | 31 ++++++------------- 2 files changed, 11 insertions(+), 24 deletions(-) rename packages/edit-site/src/components/page-actions/{delete-page-menu-item.js => trash-page-menu-item.js} (59%) diff --git a/packages/edit-site/src/components/page-actions/index.js b/packages/edit-site/src/components/page-actions/index.js index 6aaf9cadc211d..f6f0119a16454 100644 --- a/packages/edit-site/src/components/page-actions/index.js +++ b/packages/edit-site/src/components/page-actions/index.js @@ -8,7 +8,7 @@ import { moreVertical } from '@wordpress/icons'; /** * Internal dependencies */ -import DeletePageMenuItem from './delete-page-menu-item'; +import TrashPageMenuItem from './trash-page-menu-item'; export default function PageActions( { postId, @@ -25,7 +25,7 @@ export default function PageActions( { > { () => ( - diff --git a/packages/edit-site/src/components/page-actions/delete-page-menu-item.js b/packages/edit-site/src/components/page-actions/trash-page-menu-item.js similarity index 59% rename from packages/edit-site/src/components/page-actions/delete-page-menu-item.js rename to packages/edit-site/src/components/page-actions/trash-page-menu-item.js index 4bbebbe818252..cc36af311d58a 100644 --- a/packages/edit-site/src/components/page-actions/delete-page-menu-item.js +++ b/packages/edit-site/src/components/page-actions/trash-page-menu-item.js @@ -3,17 +3,12 @@ */ import { useDispatch, useSelect } from '@wordpress/data'; import { decodeEntities } from '@wordpress/html-entities'; -import { useState } from '@wordpress/element'; import { store as coreStore } from '@wordpress/core-data'; import { __, sprintf } from '@wordpress/i18n'; -import { - MenuItem, - __experimentalConfirmDialog as ConfirmDialog, -} from '@wordpress/components'; +import { MenuItem } from '@wordpress/components'; import { store as noticesStore } from '@wordpress/notices'; -export default function DeletePageMenuItem( { postId, onRemove } ) { - const [ isModalOpen, setIsModalOpen ] = useState( false ); +export default function TrashPageMenuItem( { postId, onRemove } ) { const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); const { deleteEntityRecord } = useDispatch( coreStore ); @@ -34,12 +29,12 @@ export default function DeletePageMenuItem( { postId, onRemove } ) { createSuccessNotice( sprintf( /* translators: The page's title. */ - __( '"%s" deleted.' ), + __( '"%s" moved to the Trash.' ), decodeEntities( page.title.rendered ) ), { type: 'snackbar', - id: 'edit-site-page-removed', + id: 'edit-site-page-trashed', } ); onRemove?.(); @@ -47,26 +42,18 @@ export default function DeletePageMenuItem( { postId, onRemove } ) { const errorMessage = error.message && error.code !== 'unknown_error' ? error.message - : __( 'An error occurred while deleting the page.' ); + : __( + 'An error occurred while moving the page to the trash.' + ); createErrorNotice( errorMessage, { type: 'snackbar' } ); - } finally { - setIsModalOpen( false ); } } return ( <> - setIsModalOpen( true ) } isDestructive> - { __( 'Delete' ) } + removePage() } isDestructive> + { __( 'Move to Trash' ) } - setIsModalOpen( false ) } - confirmButtonText={ __( 'Delete' ) } - > - { __( 'Are you sure you want to delete this page?' ) } - ); }