diff --git a/packages/dataviews/src/item-actions.js b/packages/dataviews/src/item-actions.js index 1b0bd5f213ca8e..09187b2788fd03 100644 --- a/packages/dataviews/src/item-actions.js +++ b/packages/dataviews/src/item-actions.js @@ -101,6 +101,54 @@ function ActionsDropdownMenuGroup( { actions, item } ) { ); } +function PrimaryActions( { primaryActions, item } ) { + return primaryActions.map( ( action ) => { + if ( !! action.RenderModal ) { + return ( + + ); + } + return ( + action.callback( item ) } + /> + ); + } ); +} + +function SecondaryActions( { secondaryActions, item } ) { + // If there is only one secondary action, it should be rendered as a primary action avoid an unnecessary dropdown. + if ( secondaryActions.length === 1 ) { + return ( + + ); + } + return ( + + } + placement="bottom-end" + > + + + ); +} + export default function ItemActions( { item, actions, isCompact } ) { const { primaryActions, secondaryActions } = useMemo( () => { return actions.reduce( @@ -141,42 +189,17 @@ export default function ItemActions( { item, actions, isCompact } ) { width: 'auto', } } > - { !! primaryActions.length && - primaryActions.map( ( action ) => { - if ( !! action.RenderModal ) { - return ( - - ); - } - return ( - action.callback( item ) } - /> - ); - } ) } + { !! primaryActions.length && ( + + ) } { !! secondaryActions.length && ( - - } - placement="bottom-end" - > - - + ) } ); diff --git a/packages/edit-site/src/components/actions/index.js b/packages/edit-site/src/components/actions/index.js index ca673e3867bdaf..1829496238fa63 100644 --- a/packages/edit-site/src/components/actions/index.js +++ b/packages/edit-site/src/components/actions/index.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { external, trash, backup } from '@wordpress/icons'; +import { external, trash, backup, edit } from '@wordpress/icons'; import { addQueryArgs } from '@wordpress/url'; import { useDispatch } from '@wordpress/data'; import { decodeEntities } from '@wordpress/html-entities'; @@ -225,6 +225,7 @@ export function useEditPostAction() { isEligible( { status } ) { return status !== 'trash'; }, + icon: edit, callback( post ) { history.push( { postId: post.id,