Skip to content

Commit

Permalink
Refactor PluginSidebarMoreMenuItem to use PluginMoreMenuItem
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Nov 28, 2018
1 parent 8a624e5 commit f568fba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import { withPluginContext } from '@wordpress/plugins';
*/
import PluginsMoreMenuGroup from '../plugins-more-menu-group';

const PluginMoreMenuItem = ( { children, icon, url, onClick = noop } ) => (
const PluginMoreMenuItem = ( { children, url, onClick = noop, ...props } ) => (
<PluginsMoreMenuGroup>
{ ( fillProps ) => (
<MenuItem
{ ...props }
href={ url }
icon={ icon }
onClick={ compose( onClick, fillProps.onClose ) }
>
{ children }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@
*/
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { MenuItem } from '@wordpress/components';
import { withPluginContext } from '@wordpress/plugins';

/**
* Internal dependencies
*/
import PluginsMoreMenuGroup from '../plugins-more-menu-group';
import PluginMoreMenuItem from '../plugin-more-menu-item';

const PluginSidebarMoreMenuItem = ( { children, icon, isSelected, onClick } ) => (
<PluginsMoreMenuGroup>
{ ( fillProps ) => (
<MenuItem
icon={ isSelected ? 'yes' : icon }
isSelected={ isSelected }
role="menuitemcheckbox"
onClick={ compose( onClick, fillProps.onClose ) }
>
{ children }
</MenuItem>
) }
</PluginsMoreMenuGroup>
<PluginMoreMenuItem
icon={ isSelected ? 'yes' : icon }
isSelected={ isSelected }
role="menuitemcheckbox"
onClick={ onClick }
>
{ children }
</PluginMoreMenuItem>
);

export default compose(
Expand Down

0 comments on commit f568fba

Please sign in to comment.