From 2f0fa92aa279e1803ca2ec0dfaf3b9f19a1400c2 Mon Sep 17 00:00:00 2001 From: Adam Cassis Date: Wed, 15 May 2024 23:39:24 +0200 Subject: [PATCH] Release May 15 (#3103) * chore(deps-dev): bump @wordpress/browserslist-config Bumps [@wordpress/browserslist-config](https://github.com/WordPress/gutenberg/tree/HEAD/packages/browserslist-config) from 5.37.0 to 5.38.0. - [Release notes](https://github.com/WordPress/gutenberg/releases) - [Changelog](https://github.com/WordPress/gutenberg/blob/trunk/packages/browserslist-config/CHANGELOG.md) - [Commits](https://github.com/WordPress/gutenberg/commits/@wordpress/browserslist-config@5.38.0/packages/browserslist-config) --- updated-dependencies: - dependency-name: "@wordpress/browserslist-config" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * chore(deps-dev): bump @rushstack/eslint-patch from 1.10.1 to 1.10.2 Bumps [@rushstack/eslint-patch](https://github.com/microsoft/rushstack/tree/HEAD/eslint/eslint-patch) from 1.10.1 to 1.10.2. - [Changelog](https://github.com/microsoft/rushstack/blob/main/eslint/eslint-patch/CHANGELOG.md) - [Commits](https://github.com/microsoft/rushstack/commits/@rushstack/eslint-patch_v1.10.2/eslint/eslint-patch) --- updated-dependencies: - dependency-name: "@rushstack/eslint-patch" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore(deps-dev): bump @types/wordpress__blocks from 12.5.13 to 12.5.14 Bumps [@types/wordpress__blocks](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/wordpress__blocks) from 12.5.13 to 12.5.14. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/wordpress__blocks) --- updated-dependencies: - dependency-name: "@types/wordpress__blocks" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * refactor(data-events): add abstract Connector class for shared methods (#3015) * refactor: add abstract Connector class for shared methods * chore: remove unused imports * chore(deps-dev): bump @wordpress/browserslist-config Bumps [@wordpress/browserslist-config](https://github.com/WordPress/gutenberg/tree/HEAD/packages/browserslist-config) from 5.38.0 to 5.39.0. - [Release notes](https://github.com/WordPress/gutenberg/releases) - [Changelog](https://github.com/WordPress/gutenberg/blob/trunk/packages/browserslist-config/CHANGELOG.md) - [Commits](https://github.com/WordPress/gutenberg/commits/@wordpress/browserslist-config@5.39.0/packages/browserslist-config) --- updated-dependencies: - dependency-name: "@wordpress/browserslist-config" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * chore(deps): bump qs and @types/qs Bumps [qs](https://github.com/ljharb/qs) and [@types/qs](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/qs). These dependencies needed to be updated together. Updates `qs` from 6.12.0 to 6.12.1 - [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md) - [Commits](https://github.com/ljharb/qs/compare/v6.12.0...v6.12.1) Updates `@types/qs` from 6.9.14 to 6.9.15 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/qs) --- updated-dependencies: - dependency-name: qs dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: "@types/qs" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * fix: ensure only admins can reset starter content and newspack options (#3081) * feat: add product option to autocomplete orders (#3072) BREAKING CHANGE: Changes order autocompletion behavior for existing products! * feat: add product option to autocomplete orders * chore: update outdated docblock description * feat(ras): skip campaign setup (#3051) * feat(ras): skip campaign setup boilerplate added new route, added fe logic * feat(ras): added `is_skipped` to prerequisite status endpoint * refactor: moved callback to named function added ui to indicate async skipping flow * feat: added skip logic to prerequisite component combined "skipped" and "active" into single `isValid` const * feat: `is_skipped` property to prerequisite type added skip logic to RAS wizard * fix: circle ci / typescript * fix: ci / eslint * refactor: remove redirect after skip added allow continue when skipped. * refactor: allow parametrized skip * refactor: revert any type cast * feat: pr feedback - added redirect, activation skip and remove `activationStep[0]` * feat: pr feedback, appended `[skipped]` to select items * chore(release): 4.0.0-alpha.1 [skip ci] # [4.0.0-alpha.1](https://github.com/Automattic/newspack-plugin/compare/v3.8.0...v4.0.0-alpha.1) (2024-04-25) ### Bug Fixes * ensure only admins can reset starter content and newspack options ([#3081](https://github.com/Automattic/newspack-plugin/issues/3081)) ([4606721](https://github.com/Automattic/newspack-plugin/commit/46067217985f904286ddb2c952ba0e1deb954e56)) ### Features * add product option to autocomplete orders ([#3072](https://github.com/Automattic/newspack-plugin/issues/3072)) ([4a2859b](https://github.com/Automattic/newspack-plugin/commit/4a2859b894eab499e194102b0636dc20466e0c22)) * **ras:** skip campaign setup ([#3051](https://github.com/Automattic/newspack-plugin/issues/3051)) ([9ef0e6d](https://github.com/Automattic/newspack-plugin/commit/9ef0e6d1de8d4dafda4d2af1304206d0f8190b15)) ### BREAKING CHANGES * Changes order autocompletion behavior for existing products! * feat: add product option to autocomplete orders * chore: update outdated docblock description * chore(release): 4.0.0-alpha.2 [skip ci] # [4.0.0-alpha.2](https://github.com/Automattic/newspack-plugin/compare/v4.0.0-alpha.1...v4.0.0-alpha.2) (2024-04-25) ### Bug Fixes * remove deprecated filter callback ([#3090](https://github.com/Automattic/newspack-plugin/issues/3090)) ([5d7d0bf](https://github.com/Automattic/newspack-plugin/commit/5d7d0bf71d16907d3aa98def372a7d9ede8949c6)) * chore(release): 4.0.0-alpha.3 [skip ci] # [4.0.0-alpha.3](https://github.com/Automattic/newspack-plugin/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2024-04-26) ### Bug Fixes * enable Memberships fix cron job only when environment constant is defined ([#3087](https://github.com/Automattic/newspack-plugin/issues/3087)) ([5d40297](https://github.com/Automattic/newspack-plugin/commit/5d40297252a9022bb9b63b72cf805a08c37eb553)) * OAuth: use a custom table for transients (#3106) * feat: start new custom table for oauth transients data * fix: copy/paste error * fix(google-oauth): use custom table for transients * feat: cleanup old transients * fix: clean up on the fly too, and limit to deleting 1000 at a time max --------- Co-authored-by: Adam Cassis * fix: autocomplete orders only for virtual products (#3111) * fix: autocomplete orders only for virtual products * chore: remove console.log --------- Signed-off-by: dependabot[bot] Co-authored-by: matticbot Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Derrick Koo Co-authored-by: Jared Rethman Co-authored-by: matticbot Co-authored-by: dkoo --- CHANGELOG.md | 30 +- .../custom-product-options/index.js | 19 + .../engagement/components/prerequisite.tsx | 19 +- assets/wizards/engagement/components/types.ts | 1 + .../views/reader-activation/campaign.js | 65 +- .../views/reader-activation/complete.js | 63 +- .../views/reader-activation/index.js | 4 +- .../views/reader-activation/style.scss | 4 + includes/class-newspack.php | 4 + .../connectors/class-activecampaign.php | 107 +--- .../connectors/class-connector.php | 122 ++++ .../connectors/class-mailchimp.php | 110 +--- .../class-reader-activation.php | 3 +- .../class-woocommerce-connection.php | 5 +- .../class-woocommerce-products.php | 208 ++++++ includes/wizards/class-engagement-wizard.php | 33 +- includes/wizards/class-wizard.php | 4 +- newspack.php | 4 +- package-lock.json | 604 +++++++++++++++--- package.json | 14 +- 20 files changed, 1050 insertions(+), 373 deletions(-) create mode 100644 assets/other-scripts/custom-product-options/index.js create mode 100644 includes/data-events/connectors/class-connector.php create mode 100644 includes/reader-revenue/woocommerce/class-woocommerce-products.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7439315da2..111649f465 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,44 +1,46 @@ -## [3.8.6](https://github.com/Automattic/newspack-plugin/compare/v3.8.5...v3.8.6) (2024-05-15) +# [4.0.0-alpha.3](https://github.com/Automattic/newspack-plugin/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2024-04-26) ### Bug Fixes -* **google-login:** get the email from the /tokeninfo endpoint ([#3117](https://github.com/Automattic/newspack-plugin/issues/3117)) ([3296f1a](https://github.com/Automattic/newspack-plugin/commit/3296f1a0b36c7992749d6209bce3ed3ef2ea5ec5)) +* enable Memberships fix cron job only when environment constant is defined ([#3087](https://github.com/Automattic/newspack-plugin/issues/3087)) ([5d40297](https://github.com/Automattic/newspack-plugin/commit/5d40297252a9022bb9b63b72cf805a08c37eb553)) -## [3.8.5](https://github.com/Automattic/newspack-plugin/compare/v3.8.4...v3.8.5) (2024-05-14) +# [4.0.0-alpha.2](https://github.com/Automattic/newspack-plugin/compare/v4.0.0-alpha.1...v4.0.0-alpha.2) (2024-04-25) ### Bug Fixes -* **oauth-transients:** remove redundant cleanup ([#3112](https://github.com/Automattic/newspack-plugin/issues/3112)) ([c123c02](https://github.com/Automattic/newspack-plugin/commit/c123c0248ecf9aab8f16e5ab63e84f9900b3d6f5)) +* remove deprecated filter callback ([#3090](https://github.com/Automattic/newspack-plugin/issues/3090)) ([5d7d0bf](https://github.com/Automattic/newspack-plugin/commit/5d7d0bf71d16907d3aa98def372a7d9ede8949c6)) -## [3.8.4](https://github.com/Automattic/newspack-plugin/compare/v3.8.3...v3.8.4) (2024-05-14) +## [3.8.1](https://github.com/Automattic/newspack-plugin/compare/v3.8.0...v3.8.1) (2024-04-25) ### Bug Fixes -* **google-oauth:** use a custom table for transients ([#3106](https://github.com/Automattic/newspack-plugin/issues/3106)) ([d4a2f5c](https://github.com/Automattic/newspack-plugin/commit/d4a2f5ce8ff6931b98593dafe759eab8b59d7ab2)) +* remove deprecated filter callback ([#3090](https://github.com/Automattic/newspack-plugin/issues/3090)) ([5d7d0bf](https://github.com/Automattic/newspack-plugin/commit/5d7d0bf71d16907d3aa98def372a7d9ede8949c6)) + -## [3.8.3](https://github.com/Automattic/newspack-plugin/compare/v3.8.2...v3.8.3) (2024-05-13) +# [4.0.0-alpha.1](https://github.com/Automattic/newspack-plugin/compare/v3.8.0...v4.0.0-alpha.1) (2024-04-25) ### Bug Fixes -* **ras:** sync purchase data only for most recent order/subscription ([#3086](https://github.com/Automattic/newspack-plugin/issues/3086)) ([2c7763a](https://github.com/Automattic/newspack-plugin/commit/2c7763a53894e5c350d6ce76e0f4ab3b1e768bc5)) +* ensure only admins can reset starter content and newspack options ([#3081](https://github.com/Automattic/newspack-plugin/issues/3081)) ([4606721](https://github.com/Automattic/newspack-plugin/commit/46067217985f904286ddb2c952ba0e1deb954e56)) -## [3.8.2](https://github.com/Automattic/newspack-plugin/compare/v3.8.1...v3.8.2) (2024-04-26) +### Features -### Bug Fixes +* add product option to autocomplete orders ([#3072](https://github.com/Automattic/newspack-plugin/issues/3072)) ([4a2859b](https://github.com/Automattic/newspack-plugin/commit/4a2859b894eab499e194102b0636dc20466e0c22)) +* **ras:** skip campaign setup ([#3051](https://github.com/Automattic/newspack-plugin/issues/3051)) ([9ef0e6d](https://github.com/Automattic/newspack-plugin/commit/9ef0e6d1de8d4dafda4d2af1304206d0f8190b15)) -* enable Memberships fix cron job only when environment constant is defined ([#3087](https://github.com/Automattic/newspack-plugin/issues/3087)) ([5d40297](https://github.com/Automattic/newspack-plugin/commit/5d40297252a9022bb9b63b72cf805a08c37eb553)) -## [3.8.1](https://github.com/Automattic/newspack-plugin/compare/v3.8.0...v3.8.1) (2024-04-25) +### BREAKING CHANGES +* Changes order autocompletion behavior for existing products! -### Bug Fixes +* feat: add product option to autocomplete orders -* remove deprecated filter callback ([#3090](https://github.com/Automattic/newspack-plugin/issues/3090)) ([5d7d0bf](https://github.com/Automattic/newspack-plugin/commit/5d7d0bf71d16907d3aa98def372a7d9ede8949c6)) +* chore: update outdated docblock description # [3.8.0](https://github.com/Automattic/newspack-plugin/compare/v3.7.0...v3.8.0) (2024-04-25) diff --git a/assets/other-scripts/custom-product-options/index.js b/assets/other-scripts/custom-product-options/index.js new file mode 100644 index 0000000000..4394355b70 --- /dev/null +++ b/assets/other-scripts/custom-product-options/index.js @@ -0,0 +1,19 @@ +/* globals jQuery */ +( function ( $ ) { + if ( ! $ ) { + return; + } + $( '#variable_product_options' ).on( 'change', 'input.variable_is_virtual', function ( e ) { + $( e.currentTarget ) + .closest( '.woocommerce_variation' ) + .find( '.show_if_variation_virtual' ) + .hide(); + + if ( $( e.currentTarget ).is( ':checked' ) ) { + $( e.currentTarget ) + .closest( '.woocommerce_variation' ) + .find( '.show_if_variation_virtual' ) + .show(); + } + } ); +} )( jQuery ); diff --git a/assets/wizards/engagement/components/prerequisite.tsx b/assets/wizards/engagement/components/prerequisite.tsx index 0c8b9aa825..16ae5b86fd 100644 --- a/assets/wizards/engagement/components/prerequisite.tsx +++ b/assets/wizards/engagement/components/prerequisite.tsx @@ -23,10 +23,11 @@ export default function Prerequisite( { saveConfig, }: PrequisiteProps ) { const { href } = prerequisite; + const isValid = Boolean( prerequisite.active || prerequisite.is_skipped ); // If the prerequisite is active but has empty fields, show a warning. const hasEmptyFields = () => { - if ( prerequisite.active && prerequisite.fields && prerequisite.warning ) { + if ( isValid && prerequisite.fields && prerequisite.warning ) { const emptyValues = Object.keys( prerequisite.fields ).filter( fieldName => '' === config[ fieldName as keyof Config ] ); @@ -93,9 +94,7 @@ export default function Prerequisite( { : sprintf( // Translators: Save or Update settings. __( '%s settings', 'newspack-plugin' ), - prerequisite.active - ? __( 'Update', 'newspack-plugin' ) - : __( 'Save', 'newspack-plugin' ) + isValid ? __( 'Update', 'newspack-plugin' ) : __( 'Save', 'newspack-plugin' ) ) } @@ -138,7 +137,7 @@ export default function Prerequisite( { } } > { /* eslint-disable no-nested-ternary */ } - { ( prerequisite.active + { ( isValid ? __( 'Update ', 'newspack-plugin' ) : prerequisite.fields ? __( 'Save ', 'newspack-plugin' ) @@ -158,8 +157,10 @@ export default function Prerequisite( { ); let status = __( 'Pending', 'newspack-plugin' ); - if ( prerequisite.active ) { - status = __( 'Ready', 'newspack-plugin' ); + if ( isValid ) { + status = `${ __( 'Ready', 'newspack-plugin' ) } ${ + prerequisite.is_skipped ? `(${ __( 'Skipped', 'newspack-plugin' ) })` : '' + }`; } if ( prerequisite.is_unavailable ) { status = __( 'Unavailable', 'newspack-plugin' ); @@ -170,14 +171,14 @@ export default function Prerequisite( { className="newspack-ras-wizard__prerequisite" isMedium expandable={ ! prerequisite.is_unavailable } - collapse={ prerequisite.active } + collapse={ isValid } title={ prerequisite.label } description={ sprintf( /* translators: %s: Prerequisite status */ __( 'Status: %s', 'newspack-plugin' ), status ) } - checkbox={ prerequisite.active ? 'checked' : 'unchecked' } + checkbox={ isValid ? 'checked' : 'unchecked' } notificationLevel="info" notification={ hasEmptyFields() } > diff --git a/assets/wizards/engagement/components/types.ts b/assets/wizards/engagement/components/types.ts index e1e947d277..dc577e72e3 100644 --- a/assets/wizards/engagement/components/types.ts +++ b/assets/wizards/engagement/components/types.ts @@ -127,6 +127,7 @@ export type PrequisiteProps = { action_enabled?: boolean; disabled_text?: string; is_unavailable?: boolean; + is_skipped?: boolean; }; }; diff --git a/assets/wizards/engagement/views/reader-activation/campaign.js b/assets/wizards/engagement/views/reader-activation/campaign.js index 66bca1d63e..b9e216ab05 100644 --- a/assets/wizards/engagement/views/reader-activation/campaign.js +++ b/assets/wizards/engagement/views/reader-activation/campaign.js @@ -16,16 +16,26 @@ import { SectionHeader, Waiting, withWizardScreen, + utils, } from '../../../../components/src'; import Prompt from '../../components/prompt'; +import Router from '../../../../components/src/proxied-imports/router'; import './style.scss'; +const { useHistory } = Router; + export default withWizardScreen( () => { + const { is_skipped_campaign_setup, reader_activation_url } = newspack_engagement_wizard; + const [ inFlight, setInFlight ] = useState( false ); const [ error, setError ] = useState( false ); const [ prompts, setPrompts ] = useState( null ); const [ allReady, setAllReady ] = useState( false ); - const { reader_activation_url } = newspack_engagement_wizard; + const [ skipped, setSkipped ] = useState( { + status: '', + isSkipped: is_skipped_campaign_setup === '1', + } ); + const history = useHistory(); const fetchPrompts = () => { setError( false ); @@ -40,6 +50,45 @@ export default withWizardScreen( () => { .finally( () => setInFlight( false ) ); }; + /** + * Display prompt requiring editors to confirm skipping, on confirmation send request to + * server to store skipped option in options table and redirect back to RAS + * + * @return {void} + */ + async function onSkipCampaignSetup() { + if ( + ! utils.confirmAction( + __( + 'Are you sure you want to skip setting up a reader activation campaign?', + 'newspack-plugin' + ) + ) + ) { + return; + } + setError( false ); + setSkipped( { ...skipped, status: 'pending' } ); + try { + const request = await apiFetch( { + path: '/newspack/v1/wizard/newspack-engagement-wizard/reader-activation/skip-campaign-setup', + method: 'POST', + data: { skip: ! skipped.isSkipped }, + } ); + if ( ! request.updated ) { + setError( { message: __( 'Server not updated', 'newspack-plugin' ) } ); + setSkipped( { isSkipped: false, status: '' } ); + return; + } + setSkipped( { isSkipped: Boolean( request.skipped ), status: '' } ); + newspack_engagement_wizard.is_skipped_campaign_setup = request.skipped ? '1' : ''; + history.push( '/reader-activation/complete' ); + } catch ( err ) { + setError( err ); + setSkipped( { isSkipped: false, status: '' } ); + } + } + useEffect( () => { window.scrollTo( 0, 0 ); fetchPrompts(); @@ -83,9 +132,21 @@ export default withWizardScreen( () => { /> ) ) }
+