From 6c28d98ef2c4375371aa9408a156cb6b0d2d4726 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 4 Dec 2023 23:49:25 +0000 Subject: [PATCH] partial feedback --- .../edit-site/src/components/actions/index.js | 2 +- .../src/components/dataviews/dataviews.js | 4 +-- .../src/components/dataviews/view-table.js | 13 +++++---- .../src/components/page-pages/index.js | 29 ++++++++++--------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/edit-site/src/components/actions/index.js b/packages/edit-site/src/components/actions/index.js index 3c185cfe0661fc..df66fe9957287e 100644 --- a/packages/edit-site/src/components/actions/index.js +++ b/packages/edit-site/src/components/actions/index.js @@ -65,7 +65,7 @@ export const trashPostAction = { variant="primary" onClick={ async () => { try { - await Promise.all( + await Promise.allSettled( posts.map( async ( post ) => { deleteEntityRecord( 'postType', diff --git a/packages/edit-site/src/components/dataviews/dataviews.js b/packages/edit-site/src/components/dataviews/dataviews.js index afe45acdd4e31a..5c968c394130e0 100644 --- a/packages/edit-site/src/components/dataviews/dataviews.js +++ b/packages/edit-site/src/components/dataviews/dataviews.js @@ -31,7 +31,7 @@ export default function DataViews( { supportedLayouts, selection, setSelection, - getSelectionLabel, + labels, } ) { const ViewComponent = VIEW_LAYOUTS.find( ( v ) => v.type === view.type @@ -78,7 +78,7 @@ export default function DataViews( { isLoading={ isLoading } selection={ selection } setSelection={ setSelection } - getSelectionLabel={ getSelectionLabel } + labels={ labels } />
diff --git a/packages/edit-site/src/components/dataviews/view-table.js b/packages/edit-site/src/components/dataviews/view-table.js index 0987967e40016b..ee03e58bd3ca91 100644 --- a/packages/edit-site/src/components/dataviews/view-table.js +++ b/packages/edit-site/src/components/dataviews/view-table.js @@ -249,7 +249,7 @@ function ViewTable( { paginationInfo, selection, setSelection, - getSelectionLabel, + labels, } ) { const areAllSelected = selection && selection.length === data.length; const columns = useMemo( () => { @@ -288,13 +288,14 @@ function ViewTable( { //console.log({ props }); const item = props.row.original; const isSelected = selection.includes( item.id ); - //console.log({ item, isSelected }); let selectionLabel; - if ( getSelectionLabel ) { - selectionLabel = getSelectionLabel( isSelected, item ); + if ( isSelected ) { + selectionLabel = labels?.getDeselectLabel + ? labels?.getDeselectLabel( item ) + : __( 'Deselect item' ); } else { - selectionLabel = isSelected - ? __( 'Deselect item' ) + selectionLabel = labels?.getSelectLabel + ? labels?.getSelectLabel( item ) : __( 'Select a new item' ); } return ( diff --git a/packages/edit-site/src/components/page-pages/index.js b/packages/edit-site/src/components/page-pages/index.js index ad25cd3bf30e0a..c46321eba6e7f0 100644 --- a/packages/edit-site/src/components/page-pages/index.js +++ b/packages/edit-site/src/components/page-pages/index.js @@ -334,19 +334,22 @@ export default function PagePages() { onChangeView={ onChangeView } selection={ selection } setSelection={ setSelection } - getSelectionLabel={ ( isSelected, item ) => - isSelected - ? sprintf( - // translators: %s: The title of the page. - __( 'Deselect page: %s' ), - item.title?.rendered || item.slug - ) - : sprintf( - // translators: %s: The title of the page. - __( 'Select page: %s' ), - item.title?.rendered || item.slug - ) - } + labels={ { + getSelectLabel: ( item ) => { + return sprintf( + // translators: %s: The title of the page. + __( 'Select page: %s' ), + item.title?.rendered || item.slug + ); + }, + getDeselectLabel: ( item ) => { + return sprintf( + // translators: %s: The title of the page. + __( 'Deselect page: %s' ), + item.title?.rendered || item.slug + ); + }, + } } /> { VIEW_LAYOUTS.find( ( v ) => v.type === view.type )?.supports