diff --git a/.github/compare-assets/index.js b/.github/compare-assets/index.js index 132da4ff6..764c93888 100644 --- a/.github/compare-assets/index.js +++ b/.github/compare-assets/index.js @@ -51,7 +51,45 @@ const runner = async () => { .filter( Boolean ) ); + let reportCommentId; + + { + const currentComments = await octokit.rest.issues.listComments( { + owner, + repo, + issue_number: payload.pull_request.number, + } ); + + if ( + Array.isArray( currentComments.data ) && + currentComments.data.length > 0 + ) { + const comment = currentComments.data.find( + ( comment ) => + comment.body.includes( 'Script Dependencies Report' ) && + comment.user.login === 'github-actions[bot]' + ); + + if ( comment ) { + reportCommentId = comment.id; + } + } + } + if ( Object.keys( changes ).length === 0 ) { + if ( reportCommentId ) { + await octokit.rest.issues.updateComment( { + owner, + repo, + comment_id: reportCommentId, + body: + '# Script Dependencies Report' + + '\n\n' + + 'There is no changed script dependency between this branch and trunk.' + + '\n\n' + + '__This comment was automatically generated by the `./github/compare-assets` action.__', + } ); + } return; } @@ -82,24 +120,35 @@ const runner = async () => { } ); - await octokit.rest.issues.createComment( { - owner, - repo, - issue_number: payload.pull_request.number, - body: - '# Script Dependencies Report' + - '\n\n' + - 'The `compare-assets` action has detected some changed script dependencies between this branch and ' + - 'trunk. Please review and confirm the following are correct before merging.' + - '\n\n' + - '| Script Handle | Added | Removed | |' + - '\n' + - '| ------------- | ------| ------- | -- |' + - '\n' + - reportContent + - '\n\n' + - '__This comment was automatically generated by the `./github/compare-assets` action.__', - } ); + const commentBody = + '# Script Dependencies Report' + + '\n\n' + + 'The `compare-assets` action has detected some changed script dependencies between this branch and ' + + 'trunk. Please review and confirm the following are correct before merging.' + + '\n\n' + + '| Script Handle | Added | Removed | |' + + '\n' + + '| ------------- | ------| ------- | -- |' + + '\n' + + reportContent + + '\n\n' + + '__This comment was automatically generated by the `./github/compare-assets` action.__'; + + if ( reportCommentId ) { + await octokit.rest.issues.updateComment( { + owner, + repo, + comment_id: reportCommentId, + body: commentBody, + } ); + } else { + await octokit.rest.issues.createComment( { + owner, + repo, + issue_number: payload.pull_request.number, + body: commentBody, + } ); + } } catch ( error ) { setFailed( error.message ); } diff --git a/.github/dependabot.yml b/.github/dependabot.yml index acc64ee99..e6d8a18f8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,6 +7,10 @@ updates: schedule: interval: 'monthly' open-pull-requests-limit: 10 + labels: + - "skip-changelog" + - "type: dependencies" + - "github_actions" # Maintain dependencies for npm - package-ecosystem: 'npm' @@ -14,6 +18,10 @@ updates: schedule: interval: 'weekly' open-pull-requests-limit: 10 + labels: + - "skip-changelog" + - "type: dependencies" + - "javascript" # Maintain dependencies for Composer - package-ecosystem: 'composer' @@ -21,3 +29,7 @@ updates: schedule: interval: 'weekly' open-pull-requests-limit: 10 + labels: + - "skip-changelog" + - "type: dependencies" + - "php" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 9d4e2555e..3ce0c5026 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -18,8 +18,8 @@ Fixes # #### Other Checks -- [ ] This PR adds/removes a feature flag & I've updated [this doc](../docs/blocks/feature-flags-and-experimental-interfaces.md) . -- [ ] This PR adds/removes an experimental interfaces and I've updated [this doc](../docs/blocks/feature-flags-and-experimental-interfaces.md) +- [ ] This PR adds/removes a feature flag & I've updated [this doc](https://github.com/woocommerce/woocommerce-blocks/blob/trunk/docs/internal-developers/blocks/feature-flags-and-experimental-interfaces.md). +- [ ] This PR adds/removes an experimental interfaces and I've updated [this doc](https://github.com/woocommerce/woocommerce-blocks/blob/trunk/docs/internal-developers/blocks/feature-flags-and-experimental-interfaces.md). - [ ] I tagged two reviewers because this PR makes queries to the database or I think it might have some security impact. ### Screenshots diff --git a/.github/workflows/automate-team-review-assignment-config.yml b/.github/workflows/automate-team-review-assignment-config.yml index e372fda62..76c242d7e 100644 --- a/.github/workflows/automate-team-review-assignment-config.yml +++ b/.github/workflows/automate-team-review-assignment-config.yml @@ -5,7 +5,7 @@ on: jobs: add-reviews: - if: github.event.pull_request.draft == false + if: github.event.pull_request.draft == false && github.actor != 'dependabot[bot]' runs-on: ubuntu-latest steps: - name: Check config and assign reviews diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c7fa30310..3a28bd571 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -54,7 +54,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 # âšī¸ Command-line programs to run using the OS shell. # đ https://git.io/JvXDl @@ -68,4 +68,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/generate-zip.yml b/.github/workflows/generate-zip.yml index a9add0f59..7105ef1e1 100644 --- a/.github/workflows/generate-zip.yml +++ b/.github/workflows/generate-zip.yml @@ -38,7 +38,7 @@ jobs: run: mv woocommerce-gutenberg-products-block.zip wc-blocks-pr-release__temp/woocommerce-gutenberg-products-block-${{ github.event.pull_request.number }}.zip - name: Transfer ZIP file via SFTP - uses: AbleLincoln/push-to-sftp@v1.0 + uses: AbleLincoln/push-to-sftp@v1.2 with: host: ${{ secrets.FTP_HOST }} port: 22 diff --git a/.github/workflows/js-css-md-linting.yml b/.github/workflows/js-css-md-linting.yml index 05c868843..5285fd1fc 100644 --- a/.github/workflows/js-css-md-linting.yml +++ b/.github/workflows/js-css-md-linting.yml @@ -4,6 +4,10 @@ on: pull_request: push: branches: [trunk] +permissions: + actions: write + checks: write + pull-requests: read jobs: # cache node and modules diff --git a/.github/workflows/project-management-automations.yml b/.github/workflows/project-management-automations.yml index 88a93f6cb..b76c2a96a 100644 --- a/.github/workflows/project-management-automations.yml +++ b/.github/workflows/project-management-automations.yml @@ -5,6 +5,9 @@ on: issues: types: [edited] name: Project management automations +permissions: + pull-requests: write + actions: write jobs: project-management-automation: runs-on: ubuntu-latest diff --git a/assets/js/atomic/blocks/product-elements/button/block.js b/assets/js/atomic/blocks/product-elements/button/block.js index 395024584..4283ae68c 100644 --- a/assets/js/atomic/blocks/product-elements/button/block.js +++ b/assets/js/atomic/blocks/product-elements/button/block.js @@ -8,6 +8,12 @@ import { useStoreEvents, useStoreAddToCart, } from '@woocommerce/base-context/hooks'; +import { + useBorderProps, + useColorProps, + useTypographyProps, + useSpacingProps, +} from '@woocommerce/base-hooks'; import { decodeEntities } from '@wordpress/html-entities'; import { CART_URL } from '@woocommerce/block-settings'; import { getSetting } from '@woocommerce/settings'; @@ -21,12 +27,6 @@ import { withProductDataContext } from '@woocommerce/shared-hocs'; * Internal dependencies */ import './style.scss'; -import { - useBorderProps, - useColorProps, - useTypographyProps, - useSpacingProps, -} from '../../../../hooks/style-attributes'; /** * Product Button Block Component. diff --git a/assets/js/atomic/blocks/product-elements/category-list/block.tsx b/assets/js/atomic/blocks/product-elements/category-list/block.tsx index afbf64c59..01d017d42 100644 --- a/assets/js/atomic/blocks/product-elements/category-list/block.tsx +++ b/assets/js/atomic/blocks/product-elements/category-list/block.tsx @@ -7,6 +7,7 @@ import { useInnerBlockLayoutContext, useProductDataContext, } from '@woocommerce/shared-context'; +import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks'; import { isEmpty } from 'lodash'; import { withProductDataContext } from '@woocommerce/shared-hocs'; import { HTMLAttributes } from 'react'; @@ -16,10 +17,6 @@ import { HTMLAttributes } from 'react'; */ import './style.scss'; import { Attributes } from './types'; -import { - useColorProps, - useTypographyProps, -} from '../../../../hooks/style-attributes'; type Props = Attributes & HTMLAttributes< HTMLDivElement >; diff --git a/assets/js/atomic/blocks/product-elements/image/block.js b/assets/js/atomic/blocks/product-elements/image/block.js index d5c296036..f9554e6e5 100644 --- a/assets/js/atomic/blocks/product-elements/image/block.js +++ b/assets/js/atomic/blocks/product-elements/image/block.js @@ -10,6 +10,11 @@ import { useInnerBlockLayoutContext, useProductDataContext, } from '@woocommerce/shared-context'; +import { + useBorderProps, + useSpacingProps, + useTypographyProps, +} from '@woocommerce/base-hooks'; import { withProductDataContext } from '@woocommerce/shared-hocs'; import { useStoreEvents } from '@woocommerce/base-context/hooks'; @@ -18,11 +23,6 @@ import { useStoreEvents } from '@woocommerce/base-context/hooks'; */ import ProductSaleBadge from './../sale-badge/block'; import './style.scss'; -import { - useBorderProps, - useSpacingProps, - useTypographyProps, -} from '../../../../hooks/style-attributes'; /** * Product Image Block Component. diff --git a/assets/js/atomic/blocks/product-elements/image/test/block.test.js b/assets/js/atomic/blocks/product-elements/image/test/block.test.js index 529fbe2b6..5e989a161 100644 --- a/assets/js/atomic/blocks/product-elements/image/test/block.test.js +++ b/assets/js/atomic/blocks/product-elements/image/test/block.test.js @@ -9,13 +9,7 @@ import { ProductDataContextProvider } from '@woocommerce/shared-context'; */ import { Block } from '../block'; -jest.mock( '@woocommerce/block-settings', () => ( { - ...jest.requireActual( '@woocommerce/block-settings' ), - __esModule: true, - PLACEHOLDER_IMG_SRC: 'placeholder.jpg', -} ) ); - -jest.mock( '../../../../../hooks/style-attributes', () => ( { +jest.mock( '@woocommerce/base-hooks', () => ( { __esModule: true, useBorderProps: jest.fn( () => ( { className: '', diff --git a/assets/js/atomic/blocks/product-elements/price/block.js b/assets/js/atomic/blocks/product-elements/price/block.js index 3831aa10b..b57fc475d 100644 --- a/assets/js/atomic/blocks/product-elements/price/block.js +++ b/assets/js/atomic/blocks/product-elements/price/block.js @@ -9,15 +9,12 @@ import { useInnerBlockLayoutContext, useProductDataContext, } from '@woocommerce/shared-context'; +import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks'; import { withProductDataContext } from '@woocommerce/shared-hocs'; /** * Internal dependencies */ -import { - useColorProps, - useTypographyProps, -} from '../../../../hooks/style-attributes'; /** * Product Price Block Component. diff --git a/assets/js/atomic/blocks/product-elements/rating/block.js b/assets/js/atomic/blocks/product-elements/rating/block.js index de62fec7e..a42c78f1a 100644 --- a/assets/js/atomic/blocks/product-elements/rating/block.js +++ b/assets/js/atomic/blocks/product-elements/rating/block.js @@ -8,17 +8,17 @@ import { useInnerBlockLayoutContext, useProductDataContext, } from '@woocommerce/shared-context'; +import { + useColorProps, + useSpacingProps, + useTypographyProps, +} from '@woocommerce/base-hooks'; import { withProductDataContext } from '@woocommerce/shared-hocs'; /** * Internal dependencies */ import './style.scss'; -import { - useColorProps, - useSpacingProps, - useTypographyProps, -} from '../../../../hooks/style-attributes'; /** * Product Rating Block Component. diff --git a/assets/js/atomic/blocks/product-elements/sale-badge/block.js b/assets/js/atomic/blocks/product-elements/sale-badge/block.js index 6786c818b..d44cab0a7 100644 --- a/assets/js/atomic/blocks/product-elements/sale-badge/block.js +++ b/assets/js/atomic/blocks/product-elements/sale-badge/block.js @@ -9,18 +9,18 @@ import { useInnerBlockLayoutContext, useProductDataContext, } from '@woocommerce/shared-context'; +import { + useBorderProps, + useColorProps, + useSpacingProps, + useTypographyProps, +} from '@woocommerce/base-hooks'; import { withProductDataContext } from '@woocommerce/shared-hocs'; /** * Internal dependencies */ import './style.scss'; -import { - useBorderProps, - useColorProps, - useSpacingProps, - useTypographyProps, -} from '../../../../hooks/style-attributes'; /** * Product Sale Badge Block Component. diff --git a/assets/js/atomic/blocks/product-elements/stock-indicator/block.js b/assets/js/atomic/blocks/product-elements/stock-indicator/block.js index 66b1d56aa..90b487dd7 100644 --- a/assets/js/atomic/blocks/product-elements/stock-indicator/block.js +++ b/assets/js/atomic/blocks/product-elements/stock-indicator/block.js @@ -8,16 +8,13 @@ import { useInnerBlockLayoutContext, useProductDataContext, } from '@woocommerce/shared-context'; +import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks'; import { withProductDataContext } from '@woocommerce/shared-hocs'; /** * Internal dependencies */ import './style.scss'; -import { - useColorProps, - useTypographyProps, -} from '../../../../hooks/style-attributes'; /** * Product Stock Indicator Block Component. diff --git a/assets/js/atomic/blocks/product-elements/summary/block.js b/assets/js/atomic/blocks/product-elements/summary/block.js index aa387969d..6c5003392 100644 --- a/assets/js/atomic/blocks/product-elements/summary/block.js +++ b/assets/js/atomic/blocks/product-elements/summary/block.js @@ -10,16 +10,13 @@ import { useInnerBlockLayoutContext, useProductDataContext, } from '@woocommerce/shared-context'; +import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks'; import { withProductDataContext } from '@woocommerce/shared-hocs'; /** * Internal dependencies */ import './style.scss'; -import { - useColorProps, - useTypographyProps, -} from '../../../../hooks/style-attributes'; /** * Product Summary Block Component. diff --git a/assets/js/atomic/blocks/product-elements/tag-list/block.js b/assets/js/atomic/blocks/product-elements/tag-list/block.js index 39d3aad33..6ec795a27 100644 --- a/assets/js/atomic/blocks/product-elements/tag-list/block.js +++ b/assets/js/atomic/blocks/product-elements/tag-list/block.js @@ -8,6 +8,7 @@ import { useInnerBlockLayoutContext, useProductDataContext, } from '@woocommerce/shared-context'; +import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks'; import { isEmpty } from 'lodash'; import { withProductDataContext } from '@woocommerce/shared-hocs'; @@ -15,10 +16,6 @@ import { withProductDataContext } from '@woocommerce/shared-hocs'; * Internal dependencies */ import './style.scss'; -import { - useColorProps, - useTypographyProps, -} from '../../../../hooks/style-attributes'; /** * Product Tag List Block Component. diff --git a/assets/js/atomic/blocks/product-elements/title/block.tsx b/assets/js/atomic/blocks/product-elements/title/block.tsx index 7070803b9..2d1fdd107 100644 --- a/assets/js/atomic/blocks/product-elements/title/block.tsx +++ b/assets/js/atomic/blocks/product-elements/title/block.tsx @@ -11,17 +11,17 @@ import { isFeaturePluginBuild } from '@woocommerce/block-settings'; import { withProductDataContext } from '@woocommerce/shared-hocs'; import ProductName from '@woocommerce/base-components/product-name'; import { useStoreEvents } from '@woocommerce/base-context/hooks'; +import { + useSpacingProps, + useTypographyProps, + useColorProps, +} from '@woocommerce/base-hooks'; /** * Internal dependencies */ import './style.scss'; import { Attributes } from './types'; -import { - useSpacingProps, - useTypographyProps, - useColorProps, -} from '../../../../hooks/style-attributes'; type Props = Attributes & HTMLAttributes< HTMLDivElement >; diff --git a/assets/js/base/components/cart-checkout/shipping-calculator/index.tsx b/assets/js/base/components/cart-checkout/shipping-calculator/index.tsx index e159a9eec..63e7bc8a3 100644 --- a/assets/js/base/components/cart-checkout/shipping-calculator/index.tsx +++ b/assets/js/base/components/cart-checkout/shipping-calculator/index.tsx @@ -21,7 +21,8 @@ const ShippingCalculator = ( { }, addressFields = [ 'country', 'state', 'city', 'postcode' ], }: ShippingCalculatorProps ): JSX.Element => { - const { shippingAddress, setShippingAddress } = useCustomerData(); + const { shippingAddress, setShippingAddress, setBillingAddress } = + useCustomerData(); return (
This hook fires when an item is added to the cart. This is triggered from the Store API in this context, but WooCommerce core add to cart events trigger the same hook.
Called after rendering the main content for a product.
Called before rendering the main content for a product.
Runs before integrations are initialized allowing new integration to be registered for use. This should be used as the primary hook for integrations to include their scripts, styles, and other code extending the blocks.
Allow 3rd parties to validate cart items. This is a legacy hook from Woo core. This filter will be deprecated because it encourages usage of wc_add_notice. For the API we need to capture notices and convert to wp errors instead.
This hook fires after customer accounts are created and passes the customer data.
This hook fires before customer accounts are created and passes the form data (username, email) and an array of errors.
This could be used to add extra validation logic and append errors to the array.
Functions hooking into this should add custom errors using the provided WP_Error instance.
This hook informs extensions that $order has completed processing and is ready for payment.
This is similar to existing core hook woocommerce_checkout_order_processed. We're using a new action:
This hook gives extensions the chance to update orders based on the data in the request. This can be used in conjunction with the ExtendSchema class to post custom data and then process it.
This hook gives extensions the chance to add or update meta data on the $order. Throwing an exception from a callback attached to this action will make the Checkout Block render in a warning state, effectively preventing checkout.
This is similar to existing core hook woocommerce_checkout_update_order_meta. We're using a new action:
Fire action to validate add to cart. Functions hooking into this should throw an \\Exception to prevent add to cart from happening.
This hook defines which block names should have block name and attribute data- attributes appended on render.
This hook defines which block namespaces should have block name and attribute data- attributes appended on render.
data-
Allow 3rd parties to validate if an item can be added to the cart. This is a legacy hook from Woo core. This filter will be deprecated because it encourages usage of wc_add_notice. For the API we need to capture notices and convert to exceptions instead.
The woocommerce_adjust_non_base_location_prices filter can stop base taxes being taken off when dealing with out of base locations. e.g. If a product costs 10 including tax, all users will pay 10 regardless of location and taxes.
Filters the variation option name for custom option slugs.
This hook filters customer data. It allows user data to be changed, for example, username, password, email, first name, last name, and role.
This hook filters registration errors. This can be used to manipulate the array of errors before they are displayed.
Low level hook for registration of new data late in the cycle. This is deprecated. Instead, use the data api:
Automattic\\WooCommerce\\Blocks\\Package::container()->get( Automattic\\WooCommerce\\Blocks\\Assets\\AssetDataRegistry::class )->add( $key, $value )
This can be used to disable the nonce check when testing API endpoints via a REST API client.
The suffix of the hook will vary depending on the value being filtered. For example, minimum, maximum, multiple_of, editable.