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

Commit 7da0883

Browse files
authored
Merge branch 'trunk' into upkeep/9524
2 parents 40c5340 + 70fd52a commit 7da0883

File tree

16 files changed

+258
-284
lines changed

16 files changed

+258
-284
lines changed

.github/workflows/unit-tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,38 @@ jobs:
8080
##
8181
- name: Set up PHP
8282
uses: shivammathur/setup-php@v2
83+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
84+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
8385
with:
8486
php-version: '${{ matrix.php }}'
8587
ini-file: development
8688
coverage: none
8789

8890
# Ensure that Composer installs the correct versions of packages.
8991
- name: Override PHP version in composer.json
92+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
93+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
9094
run: |
9195
composer config platform.php ${{ matrix.php }}
9296
composer update
9397
9498
- name: Install npm dependencies
99+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
100+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
95101
run: |
96102
npm ci
97103
npm run build
98104
99105
- name: Docker debug information
106+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
107+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
100108
run: |
101109
docker -v
102110
docker-compose -v
103111
104112
- name: General debug information
113+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
114+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
105115
run: |
106116
npm --version
107117
node --version
@@ -111,12 +121,18 @@ jobs:
111121
locale -a
112122
113123
- name: Start Docker environment
124+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
125+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
114126
run: npm run wp-env start --update
115127

116128
- name: Log running Docker containers
129+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
130+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
117131
run: docker ps -a
118132

119133
- name: Docker container debug information
134+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
135+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
120136
run: |
121137
npm run wp-env run tests-mysql mysql -- --version
122138
npm run wp-env run tests-wordpress "php --version"
@@ -125,4 +141,6 @@ jobs:
125141
npm run wp-env run tests-wordpress "locale -a"
126142
127143
- name: Run PHPUnit tests
144+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
145+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
128146
run: npm run test:php

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[![View](https://img.shields.io/badge/Project%20Components-brightgreen.svg?style=flat)](https://woocommerce.github.io/woocommerce-blocks/)
55
![JavaScript and CSS Linting](https://github.com/woocommerce/woocommerce-gutenberg-products-block/workflows/JavaScript%20and%20CSS%20Linting/badge.svg?branch=trunk)
66
![PHP Coding Standards](https://github.com/woocommerce/woocommerce-gutenberg-products-block/workflows/PHP%20Coding%20Standards/badge.svg?branch=trunk)
7-
![Automated tests](https://github.com/woocommerce/woocommerce-gutenberg-products-block/workflows/Automated%20tests/badge.svg?branch=trunk)
7+
![Unit Tests](https://github.com/woocommerce/woocommerce-blocks/workflows/E2E%20tests/badge.svg?branch=trunk)
8+
![E2E Tests](https://github.com/woocommerce/woocommerce-blocks/workflows/Unit%20Tests/badge.svg?branch=trunk)
89

910
This is the feature plugin for WooCommerce + Gutenberg. This plugin serves as a space to iterate and explore new Blocks and updates to existing blocks for WooCommerce, and how WooCommerce might work with the block editor.
1011

assets/js/base/components/cart-checkout/totals/shipping/shipping-address.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const ShippingAddress = ( {
4848
) : (
4949
<ShippingLocation formattedLocation={ formattedLocation } />
5050
) }
51-
{ showCalculator && ! prefersCollection ? (
51+
{ showCalculator && (
5252
<CalculatorButton
5353
label={ __(
5454
'Change address',
@@ -57,7 +57,7 @@ export const ShippingAddress = ( {
5757
isShippingCalculatorOpen={ isShippingCalculatorOpen }
5858
setIsShippingCalculatorOpen={ setIsShippingCalculatorOpen }
5959
/>
60-
) : null }
60+
) }
6161
</>
6262
);
6363
};

assets/js/blocks/active-filters/block.tsx

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { useQueryStateByKey } from '@woocommerce/base-context/hooks';
66
import { getSetting, getSettingWithCoercion } from '@woocommerce/settings';
77
import { useMemo, useEffect, useState } from '@wordpress/element';
88
import classnames from 'classnames';
9-
import PropTypes from 'prop-types';
109
import Label from '@woocommerce/base-components/label';
1110
import {
1211
isAttributeQueryCollection,
@@ -18,6 +17,7 @@ import {
1817
import { getUrlParameter } from '@woocommerce/utils';
1918
import FilterTitlePlaceholder from '@woocommerce/base-components/filter-placeholder';
2019
import { useIsMounted } from '@woocommerce/base-hooks';
20+
import type { BlockAttributes } from '@wordpress/blocks';
2121

2222
/**
2323
* Internal dependencies
@@ -34,23 +34,26 @@ import {
3434
} from './utils';
3535
import ActiveAttributeFilters from './active-attribute-filters';
3636
import FilterPlaceholders from './filter-placeholders';
37-
import { Attributes } from './types';
3837
import { useSetWraperVisibility } from '../filter-wrapper/context';
3938

39+
interface ActiveFiltersBlockProps {
40+
/**
41+
* The attributes for this block.
42+
*/
43+
attributes: BlockAttributes;
44+
/**
45+
* Whether it's in the editor or frontend display.
46+
*/
47+
isEditor: boolean;
48+
}
49+
4050
/**
4151
* Component displaying active filters.
42-
*
43-
* @param {Object} props Incoming props for the component.
44-
* @param {Object} props.attributes Incoming attributes for the block.
45-
* @param {boolean} props.isEditor Whether or not in the editor context.
4652
*/
4753
const ActiveFiltersBlock = ( {
4854
attributes: blockAttributes,
4955
isEditor = false,
50-
}: {
51-
attributes: Attributes;
52-
isEditor?: boolean;
53-
} ) => {
56+
}: ActiveFiltersBlockProps ) => {
5457
const setWrapperVisibility = useSetWraperVisibility();
5558
const isMounted = useIsMounted();
5659
const componentHasMounted = isMounted();
@@ -413,15 +416,4 @@ const ActiveFiltersBlock = ( {
413416
);
414417
};
415418

416-
ActiveFiltersBlock.propTypes = {
417-
/**
418-
* The attributes for this block.
419-
*/
420-
attributes: PropTypes.object.isRequired,
421-
/**
422-
* Whether it's in the editor or frontend display.
423-
*/
424-
isEditor: PropTypes.bool,
425-
};
426-
427419
export default ActiveFiltersBlock;

assets/js/blocks/reviews/reviews-by-product/edit.js renamed to assets/js/blocks/reviews/reviews-by-product/edit.tsx

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import {
1010
withSpokenMessages,
1111
} from '@wordpress/components';
1212
import { SearchListItem } from '@woocommerce/editor-components/search-list-control';
13-
import PropTypes from 'prop-types';
1413
import ProductControl from '@woocommerce/editor-components/product-control';
15-
import { Icon, commentContent } from '@wordpress/icons';
14+
import { commentContent, Icon } from '@wordpress/icons';
1615

1716
/**
1817
* Internal dependencies
@@ -24,20 +23,13 @@ import {
2423
getSharedReviewContentControls,
2524
getSharedReviewListControls,
2625
} from '../edit-utils.js';
26+
import { ReviewsByProductEditorProps } from './types';
2727

28-
/**
29-
* Component to handle edit mode of "Reviews by Product".
30-
*
31-
* @param {Object} props Incoming props for the component.
32-
* @param {Object} props.attributes Incoming block attributes.
33-
* @param {function(any):any} props.debouncedSpeak
34-
* @param {function(any):any} props.setAttributes Setter for block attributes.
35-
*/
3628
const ReviewsByProductEditor = ( {
3729
attributes,
3830
debouncedSpeak,
3931
setAttributes,
40-
} ) => {
32+
}: ReviewsByProductEditorProps ) => {
4133
const { editMode, productId } = attributes;
4234

4335
const renderProductControlItem = ( args ) => {
@@ -189,21 +181,4 @@ const ReviewsByProductEditor = ( {
189181
);
190182
};
191183

192-
ReviewsByProductEditor.propTypes = {
193-
/**
194-
* The attributes for this block.
195-
*/
196-
attributes: PropTypes.object.isRequired,
197-
/**
198-
* The register block name.
199-
*/
200-
name: PropTypes.string.isRequired,
201-
/**
202-
* A callback to update attributes.
203-
*/
204-
setAttributes: PropTypes.func.isRequired,
205-
// from withSpokenMessages
206-
debouncedSpeak: PropTypes.func.isRequired,
207-
};
208-
209184
export default withSpokenMessages( ReviewsByProductEditor );
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { BlockEditProps } from '@wordpress/blocks';
5+
6+
interface ReviewByProductAttributes {
7+
editMode: boolean;
8+
productId: number;
9+
}
10+
11+
export interface ReviewsByProductEditorProps
12+
extends BlockEditProps< ReviewByProductAttributes > {
13+
attributes: ReviewByProductAttributes;
14+
debouncedSpeak: ( message: string ) => void;
15+
}

assets/js/editor-components/grid-layout-control/index.js renamed to assets/js/editor-components/grid-layout-control/index.tsx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
* External dependencies
33
*/
44
import { __ } from '@wordpress/i18n';
5-
import PropTypes from 'prop-types';
65
import { RangeControl, ToggleControl } from '@wordpress/components';
76

8-
const clamp = ( number, boundOne, boundTwo ) => {
7+
interface ClampProps {
8+
( number: number, boundOne: number, boundTwo?: number ): number;
9+
}
10+
11+
const clamp: ClampProps = ( number, boundOne, boundTwo ) => {
912
if ( ! boundTwo ) {
1013
return Math.max( number, boundOne ) === boundOne ? number : boundOne;
1114
} else if ( Math.min( number, boundOne ) === number ) {
@@ -16,6 +19,17 @@ const clamp = ( number, boundOne, boundTwo ) => {
1619
return number;
1720
};
1821

22+
interface GridLayoutControlProps {
23+
columns: number;
24+
rows: number;
25+
setAttributes: ( attributes: Record< string, unknown > ) => void;
26+
alignButtons: boolean;
27+
minColumns?: number;
28+
maxColumns?: number;
29+
minRows?: number;
30+
maxRows?: number;
31+
}
32+
1933
/**
2034
* A combination of range controls for product grid layout settings.
2135
*
@@ -38,13 +52,13 @@ const GridLayoutControl = ( {
3852
maxColumns = 6,
3953
minRows = 1,
4054
maxRows = 6,
41-
} ) => {
55+
}: GridLayoutControlProps ) => {
4256
return (
4357
<>
4458
<RangeControl
4559
label={ __( 'Columns', 'woo-gutenberg-products-block' ) }
4660
value={ columns }
47-
onChange={ ( value ) => {
61+
onChange={ ( value: number ) => {
4862
const newValue = clamp( value, minColumns, maxColumns );
4963
setAttributes( {
5064
columns: Number.isNaN( newValue ) ? '' : newValue,
@@ -56,7 +70,7 @@ const GridLayoutControl = ( {
5670
<RangeControl
5771
label={ __( 'Rows', 'woo-gutenberg-products-block' ) }
5872
value={ rows }
59-
onChange={ ( value ) => {
73+
onChange={ ( value: number ) => {
6074
const newValue = clamp( value, minRows, maxRows );
6175
setAttributes( {
6276
rows: Number.isNaN( newValue ) ? '' : newValue,
@@ -90,22 +104,4 @@ const GridLayoutControl = ( {
90104
);
91105
};
92106

93-
GridLayoutControl.propTypes = {
94-
// The current columns count.
95-
columns: PropTypes.oneOfType( [ PropTypes.number, PropTypes.string ] )
96-
.isRequired,
97-
// The current rows count.
98-
rows: PropTypes.oneOfType( [ PropTypes.number, PropTypes.string ] )
99-
.isRequired,
100-
// Whether or not buttons are aligned horizontally across items.
101-
alignButtons: PropTypes.bool.isRequired,
102-
// Callback to update the layout settings.
103-
setAttributes: PropTypes.func.isRequired,
104-
// Min and max constraints.
105-
minColumns: PropTypes.number,
106-
maxColumns: PropTypes.number,
107-
minRows: PropTypes.number,
108-
maxRows: PropTypes.number,
109-
};
110-
111107
export default GridLayoutControl;

assets/js/icons/library/mini-cart-alt.tsx

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,17 @@
44
import { SVG } from '@wordpress/primitives';
55

66
const miniCartAlt = (
7-
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
8-
<defs>
9-
<mask
10-
id="mask"
11-
x="0"
12-
y="0"
13-
width="24.01"
14-
height="24"
15-
maskUnits="userSpaceOnUse"
16-
>
17-
<g
18-
id="path-1-inside-1_928_1005"
19-
data-name="path-1-inside-1 928 1005"
20-
>
21-
<path
22-
d="M2,2V4H4l3.6,7.6L6.3,14A2,2,0,0,0,8,17H20V15H8l1.1-2h7.5a1.9,1.9,0,0,0,1.7-1l3.6-6.5A1,1,0,0,0,21,4H6.2L5.3,2ZM8,18a2,2,0,1,0,2,2A2,2,0,0,0,8,18Zm8,2a2,2,0,1,1,2,2A2,2,0,0,1,16,20Z"
23-
fill="#fff"
24-
fillRule="evenodd"
25-
/>
26-
</g>
27-
</mask>
28-
</defs>
29-
<g mask="url(#mask)">
30-
<path d="M2,4H0V6H2ZM2,2V0H0V2ZM4,4l1.8-.9L5.3,2H4Zm3.6,7.6,1.7,1,.5-.9-.4-1ZM6.3,14l-1.8-.9h0ZM20,17v2h2V17Zm0-2h2V13H20ZM8,15,6.2,14,4.6,17H8Zm1.1-2V11H7.9l-.6,1Zm9.2-1-1.8-1h0Zm3.6-6.5-1.8-1h0ZM6.2,4l-1.8.9L4.9,6H6.2ZM5.3,2l1.8-.9L6.5,0H5.3ZM4,4V2H0V4ZM4,2H2V6H4Zm5.4,8.7L5.8,3.1,2.2,4.9l3.6,7.5ZM8,15l1.3-2.4-3.5-2L4.5,13.1Zm0,0H8L4.5,13.1A4,4,0,0,0,8,19Zm12,0H8v4H20Zm-2,0v2h4V15ZM8,17H20V13H8Zm-.7-5L6.2,14l3.6,2,1.1-2Zm9.3-1H9.1v4h7.5Zm-.1,0h.1v4a4,4,0,0,0,3.5-2.1Zm3.6-6.5L16.5,11l3.6,1.9,3.5-6.5ZM21,6a1,1,0,0,1-.9-1.5l3.5,2A3,3,0,0,0,21,2ZM6.2,6H21V2H6.2ZM3.5,2.9l.9,2L8,3.1l-.9-2ZM2,4H5.3V0H2ZM8,20H8V16a4,4,0,0,0-4,4Zm0,0H4a4,4,0,0,0,4,4Zm0,0v4a4,4,0,0,0,4-4Zm0,0h4a4,4,0,0,0-4-4Zm10-4a4,4,0,0,0-4,4h4Zm4,4a4,4,0,0,0-4-4v4Zm-4,4a4,4,0,0,0,4-4H18Zm-4-4a4,4,0,0,0,4,4V20H14Z" />
31-
</g>
32-
<circle cx="20.2" cy="4.7" r="3.8" />
7+
<SVG
8+
viewBox="0 0 24 24"
9+
version="1.1"
10+
id="svg713"
11+
xmlns="http://www.w3.org/2000/svg"
12+
>
13+
<defs id="defs705" />
14+
<path
15+
id="path882"
16+
d="m 19.199219,1.4501954 a 3.8,3.8 0 0 0 -3.72461,3.0996093 H 5.1992188 l -0.8984376,-2 H 1 v 2 h 2 l 3.5996094,7.5996093 -1.2988282,2.400391 a 2,2 0 0 0 1.6992188,3 h 12 v -2 H 7 l 1.0996094,-2 h 7.4999996 a 1.9,1.9 0 0 0 1.701172,-1 L 19.240234,9.0458985 A 3.8,3.8 0 0 0 23,5.2490235 3.8,3.8 0 0 0 19.199219,1.4501954 Z M 6.1757812,6.5087891 h 9.4433598 c 0.02007,0.055814 0.0433,0.1034655 0.06445,0.15625 a 3.8,3.8 0 0 0 0.08398,0.2050781 c 0.07333,0.1598062 0.153258,0.3011377 0.236328,0.4335937 0.194879,0.3107365 0.413084,0.5552137 0.646485,0.7578126 a 3.8,3.8 0 0 0 0.324218,0.2558593 3.8,3.8 0 0 0 0.228516,0.1601563 l -1.71093,3.0722659 H 8.5175781 Z M 7,18.549805 a 2,2 0 1 0 2,2 2,2 0 0 0 -2,-2 z m 10,0 a 2,2 0 0 0 -2,2 2,2 0 0 0 2,2 2,2 0 0 0 0.617188,-3.902344 A 2,2 0 0 0 17,18.549805 Z"
17+
/>
3318
</SVG>
3419
);
3520

0 commit comments

Comments
 (0)