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( () => { /> ) ) }
+