Skip to content

Commit a8fdc57

Browse files
authored
Merge pull request #483 from xwp/fix/480-list-block
Fix/480 list block
2 parents 6deb8d9 + 108520d commit a8fdc57

File tree

83 files changed

+174085
-8711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+174085
-8711
lines changed

.env.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ MYSQL_USER=wordpress
55
MYSQL_PASSWORD=wordpress
66

77
# WordPress
8-
WP_VERSION=5.5.1
8+
WP_VERSION=5.6
99
WP_DB_USER=wordpress
1010
WP_DB_PASSWORD=wordpress

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ jobs:
9494
- echo "Running E2E tests with code coverage ..."
9595
script:
9696
- npm run env:start
97-
- npm run wp -- wp core install --title=WordPress --admin_user=admin --admin_password=password --admin_email=admin@example.com --skip-email --url=http://localhost:8088 --quiet
97+
- docker-compose exec wordpress bash -c "chown -R www-data:www-data /var/www/html/wp-content/" # ensure WP folders have correct permissions
98+
- docker-compose exec mysql bash -c "chown -R mysql:mysql /var/lib/mysql"
99+
- npm run wp -- wp core install --title=WordPress --admin_user=admin --admin_password=password --admin_email=admin@example.com --skip-email --url=http://localhost:8088
98100
- npm run wp -- wp plugin activate material-design
99-
- npm run build:js
101+
- sudo chown -R travis:travis tests # ensure coverage folder can be created
100102
- npm run test:e2e:coveralls
101103

102104
- name: JS unit tests (7.4, WordPress latest, with code coverage)

assets/src/block-editor/blocks/button/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"icon": {
4848
"type": "string",
4949
"default": "",
50-
"source": "html",
50+
"source": "text",
5151
"selector": ".material-icons"
5252
},
5353
"backgroundColor": {

assets/src/block-editor/blocks/button/edit.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,30 @@ const ButtonEdit = ( {
353353
};
354354

355355
export default withSelect( ( select, { clientId } ) => {
356-
const { getBlockParentsByBlockName } = select( 'core/block-editor' );
356+
const { getBlock, getBlockParentsByBlockName, getBlockRootClientId } = select(
357+
'core/block-editor'
358+
);
359+
let isSubmitButton = false;
360+
361+
if ( 'undefined' === typeof getBlockParentsByBlockName ) {
362+
let parentId = getBlockRootClientId( clientId );
363+
364+
while ( parentId ) {
365+
const parentBlock = getBlock( clientId );
366+
367+
if ( parentBlock && parentBlock.name === ContactFormBlockName ) {
368+
isSubmitButton = true;
369+
break;
370+
}
371+
372+
parentId = getBlockRootClientId( parentId );
373+
}
374+
} else {
375+
isSubmitButton =
376+
getBlockParentsByBlockName( clientId, ContactFormBlockName ).length > 0;
377+
}
357378

358379
return {
359-
isSubmitButton:
360-
getBlockParentsByBlockName( clientId, ContactFormBlockName ).length > 0,
380+
isSubmitButton,
361381
};
362382
} )( ButtonEdit );

assets/src/block-editor/blocks/card/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const settings = {
4141
'material-design'
4242
),
4343
keywords: [ __( 'Material Card', 'material-design' ) ],
44-
icon: <i className="material-icons-outlined">chrome_reader_mode</i>,
44+
icon: () => <i className="material-icons-outlined">chrome_reader_mode</i>,
4545
example,
4646
edit,
4747
save,

assets/src/block-editor/blocks/contact-form/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const settings = {
3838
),
3939
category: 'material',
4040
keywords: [ __( 'Material Contact Form', 'material-design' ) ],
41-
icon: <i className="material-icons-outlined">mail</i>,
41+
icon: () => <i className="material-icons-outlined">mail</i>,
4242
example: {
4343
attributes: {
4444
preview: true,

assets/src/block-editor/blocks/contact-form/inner-blocks/common/components/text-input-edit.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ const TextInputEdit = props => {
9090
textFields.forEach( textField => new MDCTextField( textField ) );
9191
}, [ outlined, displayLabel, fullWidth ] );
9292

93-
if ( ! id || id.length === 0 ) {
94-
setAttributes( { id: `material-design-${ inputRole }-${ instanceId }` } );
95-
return null;
96-
}
93+
useEffect( () => {
94+
if ( ! id || id.length === 0 ) {
95+
setAttributes( { id: `material-design-${ inputRole }-${ instanceId }` } );
96+
} // eslint-disable-next-line react-hooks/exhaustive-deps
97+
}, [ id ] );
9798

9899
const setter = genericAttributesSetter( setAttributes );
99100
const textInputProps = {
@@ -188,12 +189,10 @@ const TextInputEdit = props => {
188189
export default compose( [
189190
withInstanceId,
190191
withSelect( ( select, ownProps ) => {
191-
const parents = select( 'core/block-editor' ).getBlockParents(
192+
const parentId = select( 'core/block-editor' ).getBlockRootClientId(
192193
ownProps.clientId
193194
);
194195

195-
const parentId = parents[ parents.length - 1 ];
196-
197196
return {
198197
parentBlock: parentId
199198
? select( 'core/block-editor' ).getBlock( parentId )

assets/src/block-editor/blocks/contact-form/inner-blocks/common/components/textarea-input-edit.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ const TextAreaInputEdit = props => {
7373

7474
const setter = genericAttributesSetter( setAttributes );
7575

76-
if ( ! id || id.length === 0 ) {
77-
setAttributes( { id: `material-design-${ inputRole }-${ instanceId }` } );
78-
}
76+
useEffect( () => {
77+
if ( ! id || id.length === 0 ) {
78+
setAttributes( { id: `material-design-${ inputRole }-${ instanceId }` } );
79+
} // eslint-disable-next-line react-hooks/exhaustive-deps
80+
}, [ id ] );
7981

8082
const textareaInputProps = {
8183
inputValue,
@@ -187,12 +189,10 @@ const TextAreaInputEdit = props => {
187189
export default compose( [
188190
withInstanceId,
189191
withSelect( ( select, ownProps ) => {
190-
const parents = select( 'core/block-editor' ).getBlockParents(
192+
const parentId = select( 'core/block-editor' ).getBlockRootClientId(
191193
ownProps.clientId
192194
);
193195

194-
const parentId = parents[ parents.length - 1 ];
195-
196196
return {
197197
parentBlock: parentId
198198
? select( 'core/block-editor' ).getBlock( parentId )

assets/src/block-editor/blocks/data-table/edit.js

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,11 @@ import {
3535
Placeholder,
3636
TextControl,
3737
ToggleControl,
38-
ToolbarGroup,
3938
} from '@wordpress/components';
4039
import { compose } from '@wordpress/compose';
4140
import { withSelect } from '@wordpress/data';
4241
import { useState } from '@wordpress/element';
4342
import { __ } from '@wordpress/i18n';
44-
import {
45-
alignLeft,
46-
alignRight,
47-
alignCenter,
48-
tableColumnAfter,
49-
tableColumnBefore,
50-
tableColumnDelete,
51-
tableRowAfter,
52-
tableRowBefore,
53-
tableRowDelete,
54-
table,
55-
} from '@wordpress/icons';
5643

5744
/**
5845
* Internal dependencies
@@ -69,20 +56,21 @@ import {
6956
toggleSection,
7057
isEmptyTableSection,
7158
} from './state';
59+
import { ToolbarGroup } from '../../components/polyfills';
7260

7361
const ALIGNMENT_CONTROLS = [
7462
{
75-
icon: alignLeft,
63+
icon: 'editor-alignleft',
7664
title: __( 'Align Column Left', 'material-design' ),
7765
align: 'left',
7866
},
7967
{
80-
icon: alignCenter,
68+
icon: 'editor-aligncenter',
8169
title: __( 'Align Column Center', 'material-design' ),
8270
align: 'center',
8371
},
8472
{
85-
icon: alignRight,
73+
icon: 'editor-alignright',
8674
title: __( 'Align Column Right', 'material-design' ),
8775
align: 'right',
8876
},
@@ -379,37 +367,37 @@ const DataTableEdit = ( { attributes, setAttributes, hasCaption } ) => {
379367
const getTableControls = () => {
380368
return [
381369
{
382-
icon: tableRowBefore,
370+
icon: 'table-row-before',
383371
title: __( 'Add Row Before', 'material-design' ),
384372
isDisabled: ! selectedCell,
385373
onClick: onInsertRowBefore,
386374
},
387375
{
388-
icon: tableRowAfter,
376+
icon: 'table-row-after',
389377
title: __( 'Add Row After', 'material-design' ),
390378
isDisabled: ! selectedCell,
391379
onClick: onInsertRowAfter,
392380
},
393381
{
394-
icon: tableRowDelete,
382+
icon: 'table-row-delete',
395383
title: __( 'Delete Row', 'material-design' ),
396384
isDisabled: ! selectedCell,
397385
onClick: onDeleteRow,
398386
},
399387
{
400-
icon: tableColumnBefore,
388+
icon: 'table-col-before',
401389
title: __( 'Add Column Before', 'material-design' ),
402390
isDisabled: ! selectedCell,
403391
onClick: onInsertColumnBefore,
404392
},
405393
{
406-
icon: tableColumnAfter,
394+
icon: 'table-col-after',
407395
title: __( 'Add Column After', 'material-design' ),
408396
isDisabled: ! selectedCell,
409397
onClick: onInsertColumnAfter,
410398
},
411399
{
412-
icon: tableColumnDelete,
400+
icon: 'table-col-delete',
413401
title: __( 'Delete Column', 'material-design' ),
414402
isDisabled: ! selectedCell,
415403
onClick: onDeleteColumn,
@@ -465,7 +453,7 @@ const DataTableEdit = ( { attributes, setAttributes, hasCaption } ) => {
465453
<ToolbarGroup>
466454
<DropdownMenu
467455
hasArrowIndicator
468-
icon={ table }
456+
icon="editor-table"
469457
label={ __( 'Edit table', 'material-design' ) }
470458
controls={ getTableControls() }
471459
/>

assets/src/block-editor/blocks/data-table/hooks.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ domReady( () => {
120120
);
121121

122122
if (
123-
! stylePreferences[ 'core/table' ] ||
124-
'material' !== stylePreferences[ 'core/table' ]
123+
stylePreferences &&
124+
( ! stylePreferences[ 'core/table' ] ||
125+
'material' !== stylePreferences[ 'core/table' ] )
125126
) {
126127
dispatch( 'core/edit-post' ).updatePreferredStyleVariations(
127128
'core/table',

0 commit comments

Comments
 (0)