From 2bda3f1e1f56db2ad4d654fd746334b94087d86e Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Fri, 12 Jan 2024 18:36:57 +0000 Subject: [PATCH 1/2] Add: bulk actions to pages. --- .../edit-site/src/components/actions/index.js | 307 +++++++++++++----- 1 file changed, 223 insertions(+), 84 deletions(-) diff --git a/packages/edit-site/src/components/actions/index.js b/packages/edit-site/src/components/actions/index.js index efe6762095c73..1043e0711c791 100644 --- a/packages/edit-site/src/components/actions/index.js +++ b/packages/edit-site/src/components/actions/index.js @@ -32,21 +32,28 @@ export const trashPostAction = { isEligible( { status } ) { return status !== 'trash'; }, + supportsBulk: true, hideModalHeader: true, RenderModal: ( { items: posts, closeModal } ) => { - // Todo - handle multiple posts - const post = posts[ 0 ]; const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); const { deleteEntityRecord } = useDispatch( coreStore ); return ( - { sprintf( - // translators: %s: The page's title. - __( 'Are you sure you want to delete "%s"?' ), - decodeEntities( post.title.rendered ) - ) } + { posts.length === 1 + ? sprintf( + // translators: %s: The page's title. + __( 'Are you sure you want to delete "%s"?' ), + decodeEntities( posts[ 0 ].title.rendered ) + ) + : sprintf( + // translators: %d: The number of pages (2 or more). + __( + 'Are you sure you want to delete "%d" pages?' + ), + posts.length + ) }