Skip to content

Commit

Permalink
Upsell nudge: fix click Safari, disable block (#40902)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Herve <[email protected]>
  • Loading branch information
ellatrix and jeherve authored Jan 15, 2025
1 parent 6d43035 commit c1371cc
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: fixed

Upsell nudge: fix click in Safari
1 change: 0 additions & 1 deletion projects/js-packages/shared-extension-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export { default as getSiteFragment } from './src/get-site-fragment';
export * from './src/site-type-utils';
export { default as getJetpackExtensionAvailability } from './src/get-jetpack-extension-availability';
export { default as registerJetpackPlugin } from './src/register-jetpack-plugin';
export { default as withHasWarningIsInteractiveClassNames } from './src/with-has-warning-is-interactive-class-names';
export {
getUpgradeUrl,
isUpgradable,
Expand Down

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions projects/packages/forms/changelog/fix-upsell-nudge-safari
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Upsell nudge: fix click in Safari
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
getJetpackExtensionAvailability,
withHasWarningIsInteractiveClassNames,
requiresPaidPlan,
} from '@automattic/jetpack-shared-extension-utils';
import { registerBlockType } from '@wordpress/blocks';
import { addFilter } from '@wordpress/hooks';

/**
* Registers a gutenberg block if the availability requirements are met.
Expand Down Expand Up @@ -34,14 +32,6 @@ export default function registerJetpackBlock( name, settings, childBlocks = [],

const result = registerBlockType( jpPrefix + name, settings );

if ( requiredPlan ) {
addFilter(
'editor.BlockListBlock',
`${ jpPrefix + name }-with-has-warning-is-interactive-class-names`,
withHasWarningIsInteractiveClassNames( jpPrefix + name )
);
}

// Register child blocks. Using `registerBlockType()` directly avoids availability checks -- if
// their parent is available, we register them all, without checking for their individual availability.
childBlocks.forEach( childBlock =>
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/fix-upsell-nudge-safari
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Block nudges: ensure clicking on a banner button leads to Plans page in Safari.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
isAtomicSite,
isSimpleSite,
getJetpackExtensionAvailability,
withHasWarningIsInteractiveClassNames,
} from '@automattic/jetpack-shared-extension-utils';
import { createBlobURL } from '@wordpress/blob';
import { useBlockEditContext, store as blockEditorStore } from '@wordpress/block-editor';
Expand Down Expand Up @@ -186,11 +185,6 @@ const addVideoPressSupport = ( settings, name ) => {
// Check if VideoPress is unavailable and filter the mediaplaceholder to limit options
if ( isNotAvailable ) {
addFilter( 'editor.MediaPlaceholder', 'jetpack/videopress', videoPressNoPlanMediaPlaceholder );
addFilter(
'editor.BlockListBlock',
`jetpack/videopress-with-has-warning-is-interactive-class-names`,
withHasWarningIsInteractiveClassNames( `core/video` )
);
} else if ( available ) {
if ( resumableUploadEnabled ) {
addFilter( 'editor.MediaPlaceholder', 'jetpack/videopress', videoPressMediaPlaceholder );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useBlockProps } from '@wordpress/block-editor';
import { createHigherOrderComponent } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
import { useState, useEffect, useMemo, useContext } from '@wordpress/element';
import clsx from 'clsx';
import { PaidBlockContext, PaidBlockProvider } from './components';
import UpgradePlanBanner from './upgrade-plan-banner';
import { trackUpgradeBannerImpression, trackUpgradeClickEvent } from './utils';
Expand Down Expand Up @@ -80,14 +81,14 @@ const withUpgradeBanner = createHigherOrderComponent(

const blockProps = useBlockProps();
// Fix for width of cover block because otherwise the div defaults to content-size as max width
const cssFixForCoverBlock = { 'max-width': 'unset' };
const cssFixForCoverBlock = { maxwidth: 'unset' };

return (
<PaidBlockProvider
onBannerVisibilityChange={ setIsVisible }
hasParentBanner={ isBannerVisible }
>
<div ref={ blockProps.ref } style={ cssFixForCoverBlock }>
<div { ...blockProps } style={ { ...cssFixForCoverBlock, ...blockProps.style } }>
<UpgradePlanBanner
className={ `is-${ name.replace( /\//, '-' ) }-paid-block` }
title={ null }
Expand All @@ -98,7 +99,7 @@ const withUpgradeBanner = createHigherOrderComponent(
context={ bannerContext }
onRedirect={ () => trackUpgradeClickEvent( trackEventData ) }
/>
<BlockEdit { ...props } />
<BlockEdit { ...props } className={ clsx( blockProps.className, 'has-warning' ) } />
</div>
</PaidBlockProvider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {
getJetpackExtensionAvailability,
withHasWarningIsInteractiveClassNames,
requiresPaidPlan,
getBlockIconProp,
} from '@automattic/jetpack-shared-extension-utils';
import { registerBlockType } from '@wordpress/blocks';
import { addFilter } from '@wordpress/hooks';

const JETPACK_PREFIX = 'jetpack/';

Expand Down Expand Up @@ -52,14 +50,6 @@ export default function registerJetpackBlock(
settings
);

if ( requiredPlan ) {
addFilter(
'editor.BlockListBlock',
`${ prefixedName }-with-has-warning-is-interactive-class-names`,
withHasWarningIsInteractiveClassNames( prefixedName )
);
}

// Register child blocks. Using `registerBlockType()` directly avoids availability checks -- if
// their parent is available, we register them all, without checking for their individual availability.
childBlocks.forEach( childBlock =>
Expand Down

0 comments on commit c1371cc

Please sign in to comment.