Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Convert to Regular Blocks button to ellipsis Dropdown #32310

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' ) }
thisissandip marked this conversation as resolved.
Show resolved Hide resolved
</MenuItem>
</BlockSettingsMenuControls>
);
}
Expand Down