Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 8cffd0a

Browse files
Aljullumikejolley
authored andcommitted
Minor code style fixes in All Products blocks
1 parent 8458410 commit 8cffd0a

File tree

3 files changed

+64
-79
lines changed

3 files changed

+64
-79
lines changed

assets/js/blocks/products/all-products/edit.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ class Editor extends Component {
160160
const onDone = () => {
161161
const { block, setAttributes } = this.props;
162162
setAttributes( {
163-
layoutConfig: getProductLayoutConfig(
164-
this.blockMap,
165-
block.innerBlocks
166-
),
163+
layoutConfig: getProductLayoutConfig( block.innerBlocks ),
167164
} );
168165
this.setState( { innerBlocks: block.innerBlocks } );
169166
this.togglePreview();

assets/js/blocks/products/base-utils.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ export const DEFAULT_PRODUCT_LIST_LAYOUT = [
4242
/**
4343
* Converts innerblocks to a list of layout configs.
4444
*
45-
* @param {Object} blockMap Map of blocks as returned by `getBlockMap`.
4645
* @param {Object[]} innerBlocks Inner block components.
4746
*/
48-
export const getProductLayoutConfig = ( blockMap, innerBlocks ) => {
47+
export const getProductLayoutConfig = ( innerBlocks ) => {
4948
if ( ! innerBlocks || innerBlocks.length === 0 ) {
5049
return [];
5150
}
@@ -58,7 +57,7 @@ export const getProductLayoutConfig = ( blockMap, innerBlocks ) => {
5857
product: undefined,
5958
children:
6059
block.innerBlocks.length > 0
61-
? getProductLayoutConfig( blockMap, block.innerBlocks )
60+
? getProductLayoutConfig( block.innerBlocks )
6261
: [],
6362
},
6463
];

assets/js/blocks/products/edit.js

Lines changed: 61 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* External dependencies
33
*/
44
import { __ } from '@wordpress/i18n';
5-
import { Fragment } from '@wordpress/element';
65
import { ToggleControl, SelectControl } from '@wordpress/components';
76

87
/**
@@ -13,81 +12,71 @@ import './editor.scss';
1312
export const getSharedContentControls = ( attributes, setAttributes ) => {
1413
const { contentVisibility } = attributes;
1514
return (
16-
<Fragment>
17-
<ToggleControl
18-
label={ __(
19-
'Show Sorting Dropdown',
20-
'woo-gutenberg-products-block'
21-
) }
22-
checked={ contentVisibility.orderBy }
23-
onChange={ () =>
24-
setAttributes( {
25-
contentVisibility: {
26-
...contentVisibility,
27-
orderBy: ! contentVisibility.orderBy,
28-
},
29-
} )
30-
}
31-
/>
32-
</Fragment>
15+
<ToggleControl
16+
label={ __(
17+
'Show Sorting Dropdown',
18+
'woo-gutenberg-products-block'
19+
) }
20+
checked={ contentVisibility.orderBy }
21+
onChange={ () =>
22+
setAttributes( {
23+
contentVisibility: {
24+
...contentVisibility,
25+
orderBy: ! contentVisibility.orderBy,
26+
},
27+
} )
28+
}
29+
/>
3330
);
3431
};
3532

3633
export const getSharedListControls = ( attributes, setAttributes ) => {
3734
return (
38-
<Fragment>
39-
<SelectControl
40-
label={ __(
41-
'Order Products By',
42-
'woo-gutenberg-products-block'
43-
) }
44-
value={ attributes.orderby }
45-
options={ [
46-
{
47-
label: __(
48-
'Newness - newest first',
49-
'woo-gutenberg-products-block'
50-
),
51-
value: 'date',
52-
},
53-
{
54-
label: __(
55-
'Price - low to high',
56-
'woo-gutenberg-products-block'
57-
),
58-
value: 'price',
59-
},
60-
{
61-
label: __(
62-
'Price - high to low',
63-
'woo-gutenberg-products-block'
64-
),
65-
value: 'price-desc',
66-
},
67-
{
68-
label: __(
69-
'Rating - highest first',
70-
'woo-gutenberg-products-block'
71-
),
72-
value: 'rating',
73-
},
74-
{
75-
label: __(
76-
'Sales - most first',
77-
'woo-gutenberg-products-block'
78-
),
79-
value: 'popularity',
80-
},
81-
{
82-
label: __(
83-
'Menu Order',
84-
'woo-gutenberg-products-block'
85-
),
86-
value: 'menu_order',
87-
},
88-
] }
89-
onChange={ ( orderby ) => setAttributes( { orderby } ) }
90-
/>
91-
</Fragment>
35+
<SelectControl
36+
label={ __( 'Order Products By', 'woo-gutenberg-products-block' ) }
37+
value={ attributes.orderby }
38+
options={ [
39+
{
40+
label: __(
41+
'Newness - newest first',
42+
'woo-gutenberg-products-block'
43+
),
44+
value: 'date',
45+
},
46+
{
47+
label: __(
48+
'Price - low to high',
49+
'woo-gutenberg-products-block'
50+
),
51+
value: 'price',
52+
},
53+
{
54+
label: __(
55+
'Price - high to low',
56+
'woo-gutenberg-products-block'
57+
),
58+
value: 'price-desc',
59+
},
60+
{
61+
label: __(
62+
'Rating - highest first',
63+
'woo-gutenberg-products-block'
64+
),
65+
value: 'rating',
66+
},
67+
{
68+
label: __(
69+
'Sales - most first',
70+
'woo-gutenberg-products-block'
71+
),
72+
value: 'popularity',
73+
},
74+
{
75+
label: __( 'Menu Order', 'woo-gutenberg-products-block' ),
76+
value: 'menu_order',
77+
},
78+
] }
79+
onChange={ ( orderby ) => setAttributes( { orderby } ) }
80+
/>
9281
);
9382
};

0 commit comments

Comments
 (0)