import {sprintf, __, _n} from '@wordpress/i18n'; import Button from '../../design/components/Button'; import './scss/components/BulkActionBar.scss'; import PremiumBadge from '../../design/partials/premium-badge'; const BulkActionBar = ( {selectedCount, onBulkAction, actions} ) => { if ( selectedCount === 0 ) { return null; } // Convert the { 'trash': { label: ... } } object to an array const actionList = Object.keys( actions ).map( key => ({ key: key, ...actions[key] }) ); return (
{/* Dynamically renders all bulk actions from the PHP configuration */} {actionList.map( action => { const variant = action.premium ? 'premium' : action.variant; const isDisabled = action.disabled || false; const label = action.label; const title = isDisabled ? __( 'Upgrade to Pro to unlock this feature', 'adpresso' ) : ''; const button = ; return action.premium ? (
{button} {action.premium && }
) : ( button ); } )}
{sprintf( _n( '%d item selected', '%d items selected', selectedCount, 'adpresso' ), selectedCount )}
); }; export default BulkActionBar;