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

Patterns: Allow the override id to be changed #58531

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
36 changes: 32 additions & 4 deletions packages/patterns/src/components/partial-syncing-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import { nanoid } from 'nanoid';
* WordPress dependencies
*/
import { InspectorControls } from '@wordpress/block-editor';
import { BaseControl, CheckboxControl } from '@wordpress/components';
import {
BaseControl,
CheckboxControl,
TextControl,
PanelBody,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
Expand Down Expand Up @@ -83,6 +88,9 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) {
},
} );
}
const hasOverrides = attributeSources.some(
( source ) => source === 'core/pattern-overrides'
);

return (
<InspectorControls group="advanced">
Expand All @@ -93,13 +101,33 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) {
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Allow instance overrides' ) }
checked={ attributeSources.some(
( source ) => source === 'core/pattern-overrides'
) }
checked={ hasOverrides }
onChange={ ( isChecked ) => {
updateBindings( isChecked );
} }
/>
{ hasOverrides && (
<PanelBody
className="block-editor-block-inspector__advanced"
title={ __( 'Override settings' ) }
initialOpen={ false }
>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Override id' ) }
value={ attributes.metadata?.id || '' }
onChange={ ( newId ) => {
setAttributes( {
metadata: {
...attributes.metadata,
id: newId,
},
} );
} }
/>
</PanelBody>
) }
</BaseControl>
</InspectorControls>
);
Expand Down
Loading