Skip to content

Commit

Permalink
Merge branch 'trunk' of github.com:woocommerce/woocommerce into 45593…
Browse files Browse the repository at this point in the history
…-cys-on-core-product-rating-block-not-rendering
  • Loading branch information
gigitux committed Mar 15, 2024
2 parents bcadab4 + 6016aad commit 3026b12
Show file tree
Hide file tree
Showing 56 changed files with 2,531 additions and 362 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/release-code-freeze.yml
Expand Up @@ -232,6 +232,32 @@ jobs:
name: double-zipped-woocommerce.${{ needs.code-freeze-prep.outputs.acceleratedVersion }}
path: plugins/woocommerce/woocommerce.zip
retention-days: 2

r2-upload-monthly:
name: Upload Beta to R2
runs-on: ubuntu-20.04
needs: [ code-freeze-prep, build-monthly ]
if: ${{ needs.code-freeze-prep.outputs.isTodayMonthlyFreeze == 'yes' }}
steps:
- id: download
uses: actions/download-artifact@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: double-zipped-woocommerce.${{ needs.code-freeze-prep.outputs.monthlyVersion }}-beta.1
path: download

- run: ls -lah ${{steps.download.outputs.download-path}}

- name: Upload release zip to Cloudflare R2 bucket
uses: ryand56/r2-upload-action@de3eabc2e3137ce07bc3805af441df55f535c64b
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: ${{ steps.download.outputs.download-path }}
destination-dir: ./monthly/

slack-upload-monthly:
name: Upload Beta to Slack
Expand Down Expand Up @@ -278,6 +304,32 @@ jobs:
run : |
pnpm utils slack file "${{ secrets.CODE_FREEZE_BOT_TOKEN }}" "Here's the generated release build for ${{ needs.code-freeze-prep.outputs.monthlyVersion }}-beta.1" "${{ steps.download.outputs.download-path }}/woocommerce.zip" "${{ inputs.slackChannelOverride || secrets.WOO_RELEASE_SLACK_CHANNEL }}" --reply-ts ${{ needs.notify-slack.outputs.ts }} --filename "woocommerce.${{ needs.code-freeze-prep.outputs.monthlyVersion }}-beta.1.zip"
r2-upload-accelerated:
name: Upload Accelerated to R2
runs-on: ubuntu-20.04
needs: [ code-freeze-prep, build-a ]
if: ${{ needs.code-freeze-prep.outputs.isTodayAcceleratedFreeze == 'yes' }}
steps:
- id: download
uses: actions/download-artifact@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: double-zipped-woocommerce.${{ needs.code-freeze-prep.outputs.acceleratedVersion }}
path: download

- run: ls -lah ${{steps.download.outputs.download-path}}

- name: Upload release zip to Cloudflare R2 bucket
uses: ryand56/r2-upload-action@de3eabc2e3137ce07bc3805af441df55f535c64b
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: ${{ steps.download.outputs.download-path }}
destination-dir: ./accelerated/

slack-upload-accelerated:
name: Upload Accelerated to Slack
runs-on: ubuntu-20.04
Expand Down
6 changes: 3 additions & 3 deletions packages/js/explat/CHANGELOG.md
@@ -1,13 +1,13 @@
# Changelog
# Changelog

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.0](https://www.npmjs.com/package/@woocommerce/packages/js/explat/v/2.3.0) - 2022-07-08
## [2.3.0](https://www.npmjs.com/package/@woocommerce/packages/js/explat/v/2.3.0) - 2022-07-08

- Patch - Fix fetchExperimentAssignment response
- Minor - Remove PHP and Composer dependencies for packaged JS packages

## [2.2.0](https://www.npmjs.com/package/@woocommerce/packages/js/explat/v/2.2.0) - 2022-06-15
## [2.2.0](https://www.npmjs.com/package/@woocommerce/packages/js/explat/v/2.2.0) - 2022-06-15

- Patch - Added useExperiment example
- Patch - Standardize lint scripts: add lint:fix
Expand Down
2 changes: 1 addition & 1 deletion packages/js/explat/README.md
@@ -1,6 +1,6 @@
# ExPlat

This packages includes a component and utility functions that can be used to run A/B Tests in WooCommerce dashboard and reports pages.
This packages includes a component and utility functions that can be used to run A/B Tests in WooCommerce dashboard, report pages, and frontend pages.

## Installation

Expand Down
4 changes: 4 additions & 0 deletions packages/js/explat/changelog/45131-add-wca-support-to-explat
@@ -0,0 +1,4 @@
Significance: patch
Type: add

Add support for WooCommerce Analytics.
4 changes: 4 additions & 0 deletions packages/js/explat/changelog/add-wca-support-to-explat
@@ -0,0 +1,4 @@
Significance: patch
Type: add

Support running A/B testing in WooCommerce frontend
7 changes: 6 additions & 1 deletion packages/js/explat/src/anon.ts
Expand Up @@ -3,6 +3,11 @@
*/
import cookie from 'cookie';

/**
* Internal dependencies
*/
import { canTrack } from './assignment';

let initializeAnonIdPromise: null | Promise< string | null > = null;
const anonIdPollingIntervalMilliseconds = 50;
const anonIdPollingIntervalMaxAttempts = 100; // 50 * 100 = 5000 = 5 seconds
Expand Down Expand Up @@ -53,7 +58,7 @@ export const initializeAnonId = async (): Promise< string | null > => {
};

export const getAnonId = async (): Promise< string | null > => {
if ( ! window.wcTracks?.isEnabled ) {
if ( ! canTrack ) {
return null;
}

Expand Down
7 changes: 5 additions & 2 deletions packages/js/explat/src/assignment.ts
Expand Up @@ -5,6 +5,9 @@ import { stringify } from 'qs';
import { applyFilters } from '@wordpress/hooks';
import apiFetch from '@wordpress/api-fetch';

export const canTrack =
window.wcTracks?.isEnabled || window?._wca?.push !== undefined;

const EXPLAT_VERSION = '0.1.0';

type QueryParams = {
Expand Down Expand Up @@ -83,7 +86,7 @@ export const fetchExperimentAssignment = async ( {
experimentName: string;
anonId: string | null;
} ): Promise< unknown > => {
if ( ! window.wcTracks?.isEnabled ) {
if ( ! canTrack ) {
throw new Error(
`Tracking is disabled, can't fetch experimentAssignment`
);
Expand Down Expand Up @@ -111,7 +114,7 @@ export const fetchExperimentAssignmentWithAuth = async ( {
experimentName: string;
anonId: string | null;
} ): Promise< unknown > => {
if ( ! window.wcTracks?.isEnabled ) {
if ( ! canTrack ) {
throw new Error(
`Tracking is disabled, can't fetch experimentAssignment`
);
Expand Down
2 changes: 1 addition & 1 deletion packages/js/explat/src/error.ts
Expand Up @@ -26,7 +26,7 @@ export const logError = (
if ( isDevelopmentMode ) {
console.error( '[ExPlat] ', error.message, error ); // eslint-disable-line no-console
} else {
if ( ! window.wcTracks?.isEnabled ) {
if ( ! window.wcTracks?.isEnabled && ! window?._wca?.push ) {
throw new Error(
`Tracking is disabled, can't send error to the server`
);
Expand Down
6 changes: 5 additions & 1 deletion packages/js/explat/src/index.ts
Expand Up @@ -12,6 +12,7 @@ import { logError } from './error';
import {
fetchExperimentAssignment,
fetchExperimentAssignmentWithAuth,
canTrack,
} from './assignment';
import { getAnonId, initializeAnonId } from './anon';
declare global {
Expand All @@ -20,11 +21,14 @@ declare global {
isEnabled: boolean;
enable?: ( cb: () => void ) => void;
};
_wca: {
push?: ( cb: () => void ) => void;
};
}
}

export const initializeExPlat = (): void => {
if ( window.wcTracks?.isEnabled ) {
if ( canTrack ) {
initializeAnonId().catch( ( e ) => logError( { message: e.message } ) );
}
};
Expand Down
5 changes: 4 additions & 1 deletion packages/js/explat/src/test/assignment-test.js
@@ -1,3 +1,7 @@
// Define that tracking is enabled before import
// so that assignments can get the correct value.
global.wcTracks.isEnabled = true;

/**
* External dependencies
*/
Expand All @@ -16,7 +20,6 @@ global.fetch = jest.fn().mockImplementation( () =>
status: 200,
} )
);
global.wcTracks.isEnabled = true;

const fetchMock = jest.spyOn( global, 'fetch' );

Expand Down
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Product Editor: Workaround a Gutenberg bug that resulted in a crash when clicking in the margin of the editor when the summary or description fields were focused, by reverting the changes that were made in #44166.
13 changes: 0 additions & 13 deletions packages/js/product-editor/src/blocks/generic/tab/editor.scss
Expand Up @@ -4,19 +4,6 @@
}
}

.wp-block-woocommerce-product-tab {
padding-left: calc( 2 * $gap );
padding-right: calc( 2 * $gap );

@include breakpoint(">782px") {
padding-left: 0;
padding-right: 0;
max-width: 650px;
margin-left: auto;
margin-right: auto;
}
}

.woocommerce-product-tabs {
.wp-block-woocommerce-product-tab__button:focus:not( :disabled ) {
box-shadow: none;
Expand Down
Expand Up @@ -18,6 +18,7 @@ import type {
TextAreaBlockEditProps,
} from './types';
import AligmentToolbarButton from './toolbar/toolbar-button-alignment';
import { useClearSelectedBlockOnBlur } from '../../../hooks/use-clear-selected-block-on-blur';
import useProductEntityProp from '../../../hooks/use-product-entity-prop';
import { Label } from '../../../components/label/label';

Expand Down Expand Up @@ -61,6 +62,11 @@ export function TextAreaBlockEdit( {
postType,
} );

// This is a workaround to hide the toolbar when the block is blurred.
// This is a temporary solution until using Gutenberg 18 with the
// fix from https://github.com/WordPress/gutenberg/pull/59800
const { handleBlur: hideToolbar } = useClearSelectedBlockOnBlur();

function setAlignment( value: TextAreaBlockEditAttributes[ 'align' ] ) {
setAttributes( { align: value } );
}
Expand Down Expand Up @@ -120,6 +126,7 @@ export function TextAreaBlockEdit( {
placeholder={ placeholder }
required={ required }
disabled={ disabled }
onBlur={ hideToolbar }
/>
) }

Expand All @@ -130,6 +137,7 @@ export function TextAreaBlockEdit( {
placeholder={ placeholder }
required={ required }
disabled={ disabled }
onBlur={ hideToolbar }
/>
) }
</BaseControl>
Expand Down
Expand Up @@ -23,6 +23,7 @@ import { ParagraphRTLControl } from './paragraph-rtl-control';
import { SummaryAttributes } from './types';
import { ALIGNMENT_CONTROLS } from './constants';
import { ProductEditorBlockEditProps } from '../../../types';
import { useClearSelectedBlockOnBlur } from '../../../hooks/use-clear-selected-block-on-blur';

export function SummaryBlockEdit( {
attributes,
Expand All @@ -44,6 +45,11 @@ export function SummaryBlockEdit( {
attributes.property
);

// This is a workaround to hide the toolbar when the block is blurred.
// This is a temporary solution until using Gutenberg 18 with the
// fix from https://github.com/WordPress/gutenberg/pull/59800
const { handleBlur: hideToolbar } = useClearSelectedBlockOnBlur();

function handleAlignmentChange( value: SummaryAttributes[ 'align' ] ) {
setAttributes( { align: value } );
}
Expand Down Expand Up @@ -114,6 +120,7 @@ export function SummaryBlockEdit( {
} ) }
dir={ direction }
allowedFormats={ allowedFormats }
onBlur={ hideToolbar }
/>
</div>
</BaseControl>
Expand Down
10 changes: 10 additions & 0 deletions packages/js/product-editor/src/components/block-editor/style.scss
Expand Up @@ -147,7 +147,17 @@

.block-editor-block-list__layout {
&.is-root-container {
padding-left: 0;
padding-right: 0;
padding-bottom: 128px;
margin-left: calc(2 * $gap);
margin-right: calc(2 * $gap);

@include breakpoint(">782px") {
max-width: 650px;
margin-left: auto;
margin-right: auto;
}
}

.block-editor-block-list__block {
Expand Down
1 change: 1 addition & 0 deletions packages/js/product-editor/src/hooks/index.ts
Expand Up @@ -10,3 +10,4 @@ export { useProductTemplate as __experimentalUseProductTemplate } from './use-pr
export { useProductScheduled as __experimentalUseProductScheduled } from './use-product-scheduled';
export { useProductManager as __experimentalUseProductManager } from './use-product-manager';
export { useMetaboxHiddenProduct as __experimentalUseMetaboxHiddenProduct } from './use-metabox-hidden-product';
export { useClearSelectedBlockOnBlur as __experimentalClearSelectedBlockOnBlur } from './use-clear-selected-block-on-blur';
@@ -0,0 +1 @@
export * from './use-clear-selected-block-on-blur';
@@ -0,0 +1,30 @@
/**
* External dependencies
*/
import { useDispatch } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';

// This is a workaround to hide the toolbar when the block is blurred.
// This is a temporary solution until using Gutenberg 18 with the
// fix from https://github.com/WordPress/gutenberg/pull/59800
export const useClearSelectedBlockOnBlur = () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore No types for this exist yet.
const { clearSelectedBlock } = useDispatch( blockEditorStore );

function handleBlur( event: {
relatedTarget: ( EventTarget & Element ) | null;
} ) {
const isToolbar = event?.relatedTarget?.closest(
'.block-editor-block-contextual-toolbar'
);

if ( ! isToolbar ) {
clearSelectedBlock();
}
}

return {
handleBlur,
};
};
Expand Up @@ -128,7 +128,6 @@ export const Layout = () => {
>
<Transitional
sendEvent={ sendEvent }
editor={ editor }
isWooExpress={ isWooExpress() }
isSurveyOpen={ isSurveyOpen }
setSurveyOpen={ setSurveyOpen }
Expand Down
@@ -0,0 +1,27 @@
/**
* External dependencies
*/
import { SVG, Path } from '@wordpress/primitives';

const lessonPLan = (
<SVG
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="none"
viewBox="0 0 24 24"
>
<Path
fill="#1E1E1E"
d="m8.85 4.821-1.203-.895-2.083 2.802-1.114-.83L3.553 7.1 5.87 8.829l2.98-4.008ZM20 7.75h-8.889v-1.5H20v1.5Zm0 5h-8.889v-1.5H20v1.5Z"
/>
<Path
fill="#1E1E1E"
fillRule="evenodd"
d="M6 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm0-1a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm2 4a2 2 0 1 1-4 0 2 2 0 0 1 4 0Zm-1 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"
clipRule="evenodd"
/>
<Path fill="#1E1E1E" d="M11.111 17.75H20v-1.5h-8.889v1.5Z" />
</SVG>
);
export default lessonPLan;

0 comments on commit 3026b12

Please sign in to comment.