Skip to content

Commit

Permalink
Move UI under experimental flag
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Jul 30, 2024
1 parent 2dff252 commit 50f6f1e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function gutenberg_enable_experiments() {
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-quick-edit-dataviews', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalQuickEditDataViews = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-block-bindings-ui', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalBlockBindingsUI = true', 'before' );
}
}

add_action( 'admin_init', 'gutenberg_enable_experiments' );
Expand Down
12 changes: 12 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ function gutenberg_initialize_experiments_settings() {
)
);

add_settings_field(
'gutenberg-block-bindings-ui',
__( 'UI to create block bindings', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Add UI to create and update block bindings in block inspector controls.', 'gutenberg' ),
'id' => 'gutenberg-block-bindings-ui',
)
);

register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down
6 changes: 4 additions & 2 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ export const BlockBindingsPanel = ( { name, metadata } ) => {
}
} );

// At this moment, the UI can be locked when there are no fields to connect to.
const readOnly = ! Object.keys( fieldsList ).length;
// Lock the UI when the experiment is not enabled or there are no fields to connect to.
const readOnly =
! window.__experimentalBlockBindingsUI ||
! Object.keys( fieldsList ).length;

if ( readOnly && Object.keys( filteredBindings ).length === 0 ) {
return null;
Expand Down

0 comments on commit 50f6f1e

Please sign in to comment.