diff --git a/packages/dataviews/src/bulk-actions-toolbar.js b/packages/dataviews/src/bulk-actions-toolbar.js
index 6b13e8b4aa8244..10783c055d7126 100644
--- a/packages/dataviews/src/bulk-actions-toolbar.js
+++ b/packages/dataviews/src/bulk-actions-toolbar.js
@@ -37,26 +37,66 @@ const SNACKBAR_VARIANTS = {
},
};
-function ActionTrigger( { action, onClick, items, isBusy } ) {
- const isDisabled = useMemo( () => {
- return isBusy || items.every( ( item ) => ! action.isEligible( item ) );
- }, [ action, items, isBusy ] );
+function ActionTrigger( { action, onClick, isBusy } ) {
return (
);
}
const EMPTY_ARRAY = [];
+function ActionButton( {
+ action,
+ selectedItems,
+ actionInProgress,
+ setActionInProgress,
+} ) {
+ const selectedEligibleItems = useMemo( () => {
+ return selectedItems.filter( ( item ) => {
+ return action.isEligible( item );
+ } );
+ }, [ action, selectedItems ] );
+ if ( !! action.RenderModal ) {
+ return (
+ {
+ setActionInProgress( action.id );
+ } }
+ onActionPerformed={ () => {
+ setActionInProgress( null );
+ } }
+ />
+ );
+ }
+ return (
+ {
+ setActionInProgress( action.id );
+ action.callback( selectedItems, () => {
+ setActionInProgress( action.id );
+ } );
+ } }
+ isBusy={ actionInProgress === action.id }
+ />
+ );
+}
+
function renderToolbarContent(
selection,
actionsToShow,
@@ -84,34 +124,13 @@ function renderToolbarContent(
{ actionsToShow.map( ( action ) => {
- if ( !! action.RenderModal ) {
- return (
- {
- setActionInProgress( action.id );
- } }
- onActionPerformed={ () => {
- setActionInProgress( null );
- } }
- />
- );
- }
return (
- {
- setActionInProgress( action.id );
- action.callback( selectedItems, () => {
- setActionInProgress( action.id );
- } );
- } }
- isBusy={ actionInProgress === action.id }
+ selectedItems={ selectedItems }
+ actionInProgress={ actionInProgress }
+ setActionInProgress={ setActionInProgress }
/>
);
} ) }