Skip to content

Commit

Permalink
add selection label functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta authored and oandregal committed Dec 1, 2023
1 parent 3c48c68 commit 0a3723a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/dataviews/dataviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function DataViews( {
supportedLayouts,
selection,
setSelection,
getSelectionLabel,
} ) {
const ViewComponent = VIEW_LAYOUTS.find(
( v ) => v.type === view.type
Expand Down Expand Up @@ -77,6 +78,7 @@ export default function DataViews( {
isLoading={ isLoading }
selection={ selection }
setSelection={ setSelection }
getSelectionLabel={ getSelectionLabel }
/>

<div>
Expand Down
15 changes: 14 additions & 1 deletion packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
__experimentalHeading as Heading,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import { useEntityRecords, store as coreStore } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
import { useState, useMemo, useCallback, useEffect } from '@wordpress/element';
Expand Down Expand Up @@ -334,6 +334,19 @@ 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
)
}
/>
</Page>
{ VIEW_LAYOUTS.find( ( v ) => v.type === view.type )?.supports
Expand Down

0 comments on commit 0a3723a

Please sign in to comment.