From 8350ee6c04a1e02f0156b2147f966b3d8a6b26f8 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sun, 29 Dec 2019 19:21:56 -0600 Subject: [PATCH] Add a function to save a new field value Also, add a unit test for that. @todo: test the 'happy path' of that function. --- js/src/block-lab-editor/components/editor.js | 2 +- .../block-lab-editor/components/field-edit.js | 33 +++++--- js/src/block-lab-editor/components/field.js | 4 +- .../helpers/saveFieldValue.js | 40 ++++++++++ .../helpers/test/saveFieldValue.js | 21 +++++ package.json | 2 +- php/blocks/class-loader.php | 6 ++ tests/js/setup-globals.js | 16 +++- webpack.config.js | 78 ++++++++----------- 9 files changed, 139 insertions(+), 63 deletions(-) create mode 100644 js/src/block-lab-editor/helpers/saveFieldValue.js create mode 100644 js/src/block-lab-editor/helpers/test/saveFieldValue.js diff --git a/js/src/block-lab-editor/components/editor.js b/js/src/block-lab-editor/components/editor.js index 7add21c54..5929c239f 100644 --- a/js/src/block-lab-editor/components/editor.js +++ b/js/src/block-lab-editor/components/editor.js @@ -40,7 +40,7 @@ class Editor extends Component {
{ !! fields && Object.values( fields ).map( ( field, index ) => { - return ; + return ; } ) }
diff --git a/js/src/block-lab-editor/components/field-edit.js b/js/src/block-lab-editor/components/field-edit.js index 0cea090f4..7cfc7e79d 100644 --- a/js/src/block-lab-editor/components/field-edit.js +++ b/js/src/block-lab-editor/components/field-edit.js @@ -6,16 +6,21 @@ const { Button, TextControl } = wp.components; const { Component } = wp.element; /** - * A field row. + * Internal dependencies + */ +import saveFieldValue from '../helpers/saveFieldValue'; + +/** + * A field's editing section. */ class FieldEdit extends Component { /** - * Renders the field row. + * Renders the field's editing section. * * @return {Function} The rendered component. */ render() { - const { field, uid } = this.props; + const { field, uiud } = this.props; const isFieldDisabled = false; return ( @@ -24,7 +29,7 @@ class FieldEdit extends Component { -