Skip to content

Commit

Permalink
Add ability to sync and unsync
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed May 2, 2023
1 parent 7e0b617 commit 6ab1c71
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/block-library/src/pattern/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import {
BlockControls,
} from '@wordpress/block-editor';
import { ToolbarButton } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

const PatternEdit = ( { attributes, clientId, setAttributes } ) => {
const { forcedAlignment, slug } = attributes;
const { forcedAlignment, slug, syncStatus } = attributes;
const { selectedPattern, innerBlocks } = useSelect(
( select ) => {
return {
Expand Down Expand Up @@ -70,10 +71,17 @@ const PatternEdit = ( { attributes, clientId, setAttributes } ) => {
<BlockControls group="other">
<ToolbarButton
onClick={ () =>
setAttributes( { syncStatus: 'unsynced' } )
setAttributes( {
syncStatus:
syncStatus === 'unsynced'
? 'synced'
: 'unsynced',
} )
}
>
Unsync
{ syncStatus === 'unsynced'
? __( 'Sync' )
: __( 'Unsync' ) }
</ToolbarButton>
</BlockControls>
</>
Expand Down

0 comments on commit 6ab1c71

Please sign in to comment.