Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Delete page menu item to Move to trash. #52641

Merged
merged 1 commit into from
Jul 18, 2023
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
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/page-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,7 +25,7 @@ export default function PageActions( {
>
{ () => (
<MenuGroup>
<DeletePageMenuItem
<TrashPageMenuItem
postId={ postId }
onRemove={ onRemove }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -34,39 +29,31 @@ 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?.();
} catch ( error ) {
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.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'An error occurred while moving the page to the trash.'
'An error occurred while moving the page to the Trash.'

WordPress core seems to capitalize when there is an article (the), what do you think?

restored
moved

);

createErrorNotice( errorMessage, { type: 'snackbar' } );
} finally {
setIsModalOpen( false );
}
}
return (
<>
<MenuItem onClick={ () => setIsModalOpen( true ) } isDestructive>
{ __( 'Delete' ) }
<MenuItem onClick={ () => removePage() } isDestructive>
{ __( 'Move to Trash' ) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ __( 'Move to Trash' ) }
{ __( 'Move to trash' ) }

To be consistent with the trash button in the post editor

post-editor-trash

</MenuItem>
<ConfirmDialog
isOpen={ isModalOpen }
onConfirm={ removePage }
onCancel={ () => setIsModalOpen( false ) }
confirmButtonText={ __( 'Delete' ) }
>
{ __( 'Are you sure you want to delete this page?' ) }
</ConfirmDialog>
</>
);
}
Loading