Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

[WIP] React refactoring of the 'Edit Block' UI #478

Closed
wants to merge 30 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4a583f2
Begin the proof of concept for the refactoring
kienstra Nov 24, 2019
dae00a8
At least for now, delete PHP saving of Block Properties meta box
kienstra Nov 24, 2019
558fdf7
Port PHP rendering to React, mainly copying
kienstra Nov 24, 2019
f85c315
Render basic field rows from the post content
kienstra Nov 24, 2019
8c6212a
Correct DocBlocks in FieldRow
kienstra Nov 24, 2019
52fd0b3
Merge in develop, resolve conflicts
kienstra Dec 17, 2019
32aa1d9
Add a basic JS unit test setup, modeled after AMP plugin
kienstra Dec 17, 2019
a0c8510
Attempt to fix failed Travis build
kienstra Dec 17, 2019
3486c27
Move comment to the relevant file, do npm run lint:js:fix
kienstra Dec 17, 2019
95384cf
Restructure js files into js/src
kienstra Dec 21, 2019
4d667fd
Add the build/ directory to the ignored test paths
kienstra Dec 22, 2019
8bdaf09
Rename function to getBlockLabAttributes, add unit test
kienstra Dec 22, 2019
a947395
Remove .gitkeep, as the directory isn't empty anymore
kienstra Dec 22, 2019
4e7ef28
Add a Jest unit test for getSimplifiedFields()
kienstra Dec 22, 2019
84755bb
Add a unit test for getBlockLabAttributes()
kienstra Dec 26, 2019
ce9c437
Add a unit test for registerBlocks()
kienstra Dec 27, 2019
89b15e0
Add more unit tests for registerBlocks()
kienstra Dec 27, 2019
1648af2
Use the singular for no block
kienstra Dec 27, 2019
422f024
Apply Rob's HTML and CSS for the new UI
kienstra Dec 27, 2019
8350ee6
Add a function to save a new field value
kienstra Dec 30, 2019
5b8a702
Fix an issue with saving fields
kienstra Dec 30, 2019
4099e6f
Address an issue where the rich text editor wasn't disabled
kienstra Dec 30, 2019
9ef2653
Address an issue where the rich text editor wasn't disabled
kienstra Dec 30, 2019
ce65b45
Port the slugify function from the previous JS file
kienstra Dec 30, 2019
6da5177
Add a function to save the block
kienstra Dec 31, 2019
b540f7b
Add a function to get a new field's name
kienstra Dec 31, 2019
5b82bc5
Add a function to remove the slug format
kienstra Dec 31, 2019
34988cd
Add helper functions to an index.js file
kienstra Dec 31, 2019
3f12879
Allow toggling the field editing area open and closed
kienstra Dec 31, 2019
4f36644
Merge in develop, resolve conflicts
kienstra Jan 14, 2020
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
Prev Previous commit
Next Next commit
Rename function to getBlockLabAttributes, add unit test
There's already a getBlockAttributes() function in Gutenberg,
so give this a differernt name.
  • Loading branch information
kienstra committed Dec 22, 2019
commit 8bdaf0987cc3f051fa9d5ce07eb1d45916fada2a
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
* @param {Object} fields The fields to get the attributes from.
* @return {Object} attributes The attributes for the fields.
*/
const getBlockAttributes = ( fields ) => {
const getBlockLabAttributes = ( fields ) => {
const attributes = {};

for ( const fieldName in fields ) {
@@ -28,4 +28,4 @@ const getBlockAttributes = ( fields ) => {
return attributes;
};

export default getBlockAttributes;
export default getBlockLabAttributes;
4 changes: 2 additions & 2 deletions js/src/block-editor/helpers/registerBlocks.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ const { registerBlockType } = wp.blocks;
* Internal dependencies
*/
import icons from '../../../../assets/icons.json';
import getBlockAttributes from './getBlockAttributes';
import getBlockLabAttributes from './getBlockLabAttributes';
import { Edit } from '../components';

const registerBlocks = () => {
@@ -45,7 +45,7 @@ const registerBlocks = () => {
category: 'object' === typeof block.category ? block.category.slug : block.category,
icon,
keywords: block.keywords,
attributes: getBlockAttributes( block.fields ),
attributes: getBlockLabAttributes( block.fields ),
edit: ( props ) => {
return <Edit blockProps={ props } block={ block } />;
},
40 changes: 40 additions & 0 deletions js/src/block-editor/helpers/test/getBlockLabAttributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Internal dependencies
*/
import getBlockLabAttributes from '../getBlockLabAttributes';

describe( 'getBlockFromContent', () => {
const mockFields = {
example_text: {
type: 'text',
default: 'Here is some text',
help: 'This is the help text',
location: 'editor',
},
example_url: {
type: 'url',
default: 'https://example.com/go-here',
help: 'Here is the help text',
location: 'inspector',
},
};

const expectedAttributes = {
example_text: {
type: 'text',
default: 'Here is some text',
},
example_url: {
type: 'url',
default: 'https://example.com/go-here',
},
};

it( 'should return an empty object if passed an empty object', () => {
expect( getBlockLabAttributes( {} ) ).toStrictEqual( {} );
} );

it( 'should return only the attributes of the fields', () => {
expect( getBlockLabAttributes( mockFields ) ).toStrictEqual( expectedAttributes );
} );
} );