From 94bdc5db28675dd9a774319c65793cf89dfb4eb3 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+cbravobernal@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:43:31 +0100 Subject: [PATCH] Allow all sources with getfieldslist --- .../block-editor/src/hooks/block-bindings.js | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/packages/block-editor/src/hooks/block-bindings.js b/packages/block-editor/src/hooks/block-bindings.js index 4c25f1b65aa87a..eaf7a1477d4367 100644 --- a/packages/block-editor/src/hooks/block-bindings.js +++ b/packages/block-editor/src/hooks/block-bindings.js @@ -99,31 +99,39 @@ function EditableBlockBindingsPanelItems( { } ) { const { updateBlockBindings } = useBlockBindingsUtils(); const [ isOuterModalOpen, setOuterModalOpen ] = useState( false ); - const dataSet = Object.entries( fieldsList[ 'core/post-meta' ] ).map( - ( [ key, field ] ) => { - const value = - field.value === undefined - ? `${ field.label } value` - : field.value; + const dataSet = Object.entries( fieldsList ).flatMap( + ( [ sourceName, fields ] ) => + Object.entries( fields ).map( ( [ key, field ] ) => { + const value = + field.value === undefined + ? `${ field.label } value` + : field.value; - return { - id: key, - label: field.label || key, - value: value !== '' ? value : `Add a new ${ field.label } `, - }; - } + return { + id: key, + label: field.label || key, + value: value !== '' ? value : `Add a new ${ field.label }`, + source: sourceName, + }; + } ) ); const fields = [ { id: 'label', - label: 'Label', + label: __( 'Label' ), type: 'text', enableGlobalSearch: true, }, { id: 'value', - label: 'Value', + label: __( 'Value' ), + type: 'text', + enableGlobalSearch: true, + }, + { + id: 'source', + label: __( 'Source' ), type: 'text', enableGlobalSearch: true, }, @@ -149,9 +157,9 @@ function EditableBlockBindingsPanelItems( { search: '', filters: [], page: 1, - perPage: 5, + perPage: 15, sort: {}, - fields: [ 'label', 'value' ], + fields: [ 'label', 'value', 'source' ], layout: defaultLayouts.table.layout, } );