Skip to content

Commit

Permalink
Add Convert to Regular Blocks button to ellipsis Dropdown (#32310)
Browse files Browse the repository at this point in the history
* Add Convert to Regular Blocks button to ellipsis Dropdown

* Update title to "Convert to regular blocks"

Co-authored-by: Nik Tsekouras <[email protected]>

Co-authored-by: Nik Tsekouras <[email protected]>
  • Loading branch information
thisissandip and ntsekouras authored Jun 1, 2021
1 parent e6ff80f commit 636d479
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
import { MenuItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { isReusableBlock } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
import { useSelect, useDispatch } from '@wordpress/data';
import {
BlockSettingsMenuControls,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { addQueryArgs } from '@wordpress/url';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
*/
import { store as reusableBlocksStore } from '../../store';

function ReusableBlocksManageButton( { clientId } ) {
const { isVisible } = useSelect(
( select ) => {
Expand All @@ -33,6 +38,10 @@ function ReusableBlocksManageButton( { clientId } ) {
[ clientId ]
);

const {
__experimentalConvertBlockToStatic: convertBlockToStatic,
} = useDispatch( reusableBlocksStore );

if ( ! isVisible ) {
return null;
}
Expand All @@ -44,6 +53,9 @@ function ReusableBlocksManageButton( { clientId } ) {
>
{ __( 'Manage Reusable blocks' ) }
</MenuItem>
<MenuItem onClick={ () => convertBlockToStatic( clientId ) }>
{ __( 'Convert to regular blocks' ) }
</MenuItem>
</BlockSettingsMenuControls>
);
}
Expand Down

0 comments on commit 636d479

Please sign in to comment.