From a20e801baa42cc1a351aae20b05a9c58b55f7181 Mon Sep 17 00:00:00 2001 From: Paulo Cruz Date: Thu, 8 Aug 2024 10:06:04 -0300 Subject: [PATCH 1/7] Load Scheduled_Updates for non-wpcom users (#38772) * Load Scheduled_Updates for non wpcom users * changelog * Update version to 5.54.1-alpha --- .../changelog/fix-load-scheduled-updates | 4 ++++ projects/packages/jetpack-mu-wpcom/package.json | 2 +- .../jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php | 11 ++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/fix-load-scheduled-updates diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-load-scheduled-updates b/projects/packages/jetpack-mu-wpcom/changelog/fix-load-scheduled-updates new file mode 100644 index 0000000000000..21a0f6ed5cb27 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/fix-load-scheduled-updates @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Load Scheduled_Updates for non-wpcom users diff --git a/projects/packages/jetpack-mu-wpcom/package.json b/projects/packages/jetpack-mu-wpcom/package.json index 487ac43ea90ce..2d55a2e51017a 100644 --- a/projects/packages/jetpack-mu-wpcom/package.json +++ b/projects/packages/jetpack-mu-wpcom/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-mu-wpcom", - "version": "5.54.0", + "version": "5.54.1-alpha", "description": "Enhances your site with features powered by WordPress.com", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme", "bugs": { diff --git a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php index dcf9ad119bc81..424b3f3710f8d 100644 --- a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php +++ b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php @@ -13,7 +13,7 @@ * Jetpack_Mu_Wpcom main class. */ class Jetpack_Mu_Wpcom { - const PACKAGE_VERSION = '5.54.0'; + const PACKAGE_VERSION = '5.54.1-alpha'; const PKG_DIR = __DIR__ . '/../'; const BASE_DIR = __DIR__ . '/'; const BASE_FILE = __FILE__; @@ -113,6 +113,11 @@ public static function load_features() { \Marketplace_Products_Updater::init(); \Automattic\Jetpack\Classic_Theme_Helper\Main::init(); \Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::setup(); + + // Gets autoloaded from the Scheduled_Updates package. + if ( class_exists( 'Automattic\Jetpack\Scheduled_Updates' ) ) { + Scheduled_Updates::init(); + } } /** @@ -145,10 +150,6 @@ public static function load_wpcom_user_features() { // This is temporary. After we cleanup Masterbar on WPCOM we should load Masterbar for Simple sites too. \Automattic\Jetpack\Masterbar\Main::init(); } - // Gets autoloaded from the Scheduled_Updates package. - if ( class_exists( 'Automattic\Jetpack\Scheduled_Updates' ) ) { - Scheduled_Updates::init(); - } } /** From d9bbadc2984920e7c87bfb1ec6707ae70d93a198 Mon Sep 17 00:00:00 2001 From: Dylan Munson <65001528+CodeyGuyDylan@users.noreply.github.com> Date: Thu, 8 Aug 2024 09:06:12 -0600 Subject: [PATCH 2/7] Update/use connection to use my jetpack connection hook (#38721) * Replace usage of useConnection with useMyJetpackConnection * changelog * Improve ternary * Improve type name for install hook * Update type name for install callback * Fix changelogger --- .../_inc/components/add-license-screen/index.jsx | 4 ++-- .../components/connected-product-card/index.tsx | 10 +++++----- .../components/connection-status-card/index.tsx | 14 +++----------- .../_inc/components/product-card/index.tsx | 16 +++++++++------- .../_inc/components/product-card/status.tsx | 4 ++-- .../components/product-interstitial/index.jsx | 6 +++--- .../product-interstitial/jetpack-ai/index.jsx | 4 ++-- .../jetpack-ai/product-page.jsx | 4 ++-- .../components/redeem-token-screen/index.jsx | 5 ++--- .../_inc/components/welcome-banner/index.jsx | 4 ++-- .../products/use-install-standalone-plugin.ts | 16 +++++++++++++++- .../my-jetpack/_inc/data/use-simple-mutation.ts | 2 +- ...-connection-to-use-my-jetpack-connection-hook | 4 ++++ projects/packages/my-jetpack/global.d.ts | 16 +++++++++++++++- projects/packages/my-jetpack/package.json | 2 +- .../my-jetpack/src/class-initializer.php | 2 +- 16 files changed, 69 insertions(+), 44 deletions(-) create mode 100644 projects/packages/my-jetpack/changelog/update-use-connection-to-use-my-jetpack-connection-hook diff --git a/projects/packages/my-jetpack/_inc/components/add-license-screen/index.jsx b/projects/packages/my-jetpack/_inc/components/add-license-screen/index.jsx index f646d29e6dc04..380b8974da44c 100644 --- a/projects/packages/my-jetpack/_inc/components/add-license-screen/index.jsx +++ b/projects/packages/my-jetpack/_inc/components/add-license-screen/index.jsx @@ -2,7 +2,6 @@ * External dependencies */ import { AdminPage, Container, Col } from '@automattic/jetpack-components'; -import { useConnection } from '@automattic/jetpack-connection'; import { ActivationScreen } from '@automattic/jetpack-licensing'; import React, { useCallback, useState, useMemo } from 'react'; /* @@ -12,6 +11,7 @@ import { QUERY_LICENSES_KEY } from '../../data/constants'; import useJetpackApiQuery from '../../data/use-jetpack-api-query'; import { getMyJetpackWindowInitialState } from '../../data/utils/get-my-jetpack-window-state'; import useAnalytics from '../../hooks/use-analytics'; +import useMyJetpackConnection from '../../hooks/use-my-jetpack-connection'; import GoBackLink from '../go-back-link'; /** @@ -25,7 +25,7 @@ export default function AddLicenseScreen() { name: QUERY_LICENSES_KEY, queryFn: async api => ( await api.getUserLicenses() )?.items, } ); - const { userConnectionData } = useConnection(); + const { userConnectionData } = useMyJetpackConnection(); const [ hasActivatedLicense, setHasActivatedLicense ] = useState( false ); // They might not have a display name set in wpcom, so fall back to wpcom login or local username. diff --git a/projects/packages/my-jetpack/_inc/components/connected-product-card/index.tsx b/projects/packages/my-jetpack/_inc/components/connected-product-card/index.tsx index 606823ecba2e4..f146ebebf4f55 100644 --- a/projects/packages/my-jetpack/_inc/components/connected-product-card/index.tsx +++ b/projects/packages/my-jetpack/_inc/components/connected-product-card/index.tsx @@ -2,7 +2,6 @@ * External dependencies */ import { Text } from '@automattic/jetpack-components'; -import { useConnection } from '@automattic/jetpack-connection'; import { __ } from '@wordpress/i18n'; import { useCallback, useEffect } from 'react'; /** @@ -14,6 +13,7 @@ import useActivate from '../../data/products/use-activate'; import useInstallStandalonePlugin from '../../data/products/use-install-standalone-plugin'; import useProduct from '../../data/products/use-product'; import useAnalytics from '../../hooks/use-analytics'; +import useMyJetpackConnection from '../../hooks/use-my-jetpack-connection'; import useMyJetpackNavigate from '../../hooks/use-my-jetpack-navigate'; import ProductCard from '../product-card'; import type { AdditionalAction, SecondaryAction } from '../product-card/types'; @@ -22,10 +22,10 @@ import type { FC, ReactNode } from 'react'; interface ConnectedProductCardProps { admin: boolean; recommendation: boolean; - slug: string; + slug: JetpackModule; children: ReactNode; isDataLoading?: boolean; - Description?: React.JSX.Element | ( () => null ); + Description?: FC; additionalActions?: AdditionalAction[]; secondaryAction?: SecondaryAction; upgradeInInterstitial?: boolean; @@ -48,7 +48,7 @@ const ConnectedProductCard: FC< ConnectedProductCardProps > = ( { onMouseEnter, onMouseLeave, } ) => { - const { isRegistered, isUserConnected } = useConnection(); + const { isRegistered, isUserConnected } = useMyJetpackConnection(); const { recordEvent } = useAnalytics(); const { install: installStandalonePlugin, isPending: isInstalling } = @@ -74,7 +74,7 @@ const ConnectedProductCard: FC< ConnectedProductCardProps > = ( { return; } - activate(); + activate( {} ); }, [ activate, isRegistered, diff --git a/projects/packages/my-jetpack/_inc/components/connection-status-card/index.tsx b/projects/packages/my-jetpack/_inc/components/connection-status-card/index.tsx index 6cd088eb24bf5..7365d10c7a6a2 100644 --- a/projects/packages/my-jetpack/_inc/components/connection-status-card/index.tsx +++ b/projects/packages/my-jetpack/_inc/components/connection-status-card/index.tsx @@ -1,9 +1,5 @@ import { Button, getRedirectUrl, H3, Text } from '@automattic/jetpack-components'; -import { - ManageConnectionDialog, - useConnection, - CONNECTION_STORE_ID, -} from '@automattic/jetpack-connection'; +import { ManageConnectionDialog, CONNECTION_STORE_ID } from '@automattic/jetpack-connection'; import { useDispatch } from '@wordpress/data'; import { __, sprintf } from '@wordpress/i18n'; import { Icon, info, check, lockOutline } from '@wordpress/icons'; @@ -13,6 +9,7 @@ import { useAllProducts } from '../../data/products/use-product'; import { getMyJetpackWindowInitialState } from '../../data/utils/get-my-jetpack-window-state'; import getProductSlugsThatRequireUserConnection from '../../data/utils/get-product-slugs-that-require-user-connection'; import useAnalytics from '../../hooks/use-analytics'; +import useMyJetpackConnection from '../../hooks/use-my-jetpack-connection'; import cloud from './cloud.svg'; import emptyAvatar from './empty-avatar.svg'; import jetpackGray from './jetpack-gray.svg'; @@ -173,13 +170,8 @@ const ConnectionStatusCard: ConnectionStatusCardType = ( { context, onConnectUser = null, } ) => { - const { isRegistered, isUserConnected, userConnectionData } = useConnection( { - apiRoot, - apiNonce, + const { isRegistered, isUserConnected, userConnectionData } = useMyJetpackConnection( { redirectUri, - skipUserConnection: false, - autoTrigger: false, - from: 'my-jetpack', } ); const { recordEvent } = useAnalytics(); diff --git a/projects/packages/my-jetpack/_inc/components/product-card/index.tsx b/projects/packages/my-jetpack/_inc/components/product-card/index.tsx index ec3e97e9b1009..1f1cd6dfe0c2f 100644 --- a/projects/packages/my-jetpack/_inc/components/product-card/index.tsx +++ b/projects/packages/my-jetpack/_inc/components/product-card/index.tsx @@ -8,9 +8,11 @@ import Card from '../card'; import ActionButton from './action-button'; import PriceComponent from './pricing-component'; import RecommendationActions from './recommendation-actions'; -import SecondaryButton, { type SecondaryButtonProps } from './secondary-button'; +import SecondaryButton from './secondary-button'; import Status from './status'; import styles from './style.module.scss'; +import type { AdditionalAction, SecondaryAction } from './types'; +import type { InstallCallback } from '../../data/products/use-install-standalone-plugin'; import type { FC, MouseEventHandler, ReactNode } from 'react'; export type ProductCardProps = { @@ -25,13 +27,13 @@ export type ProductCardProps = { isManageDisabled?: boolean; onActivate?: () => void; slug: JetpackModule; - additionalActions?: SecondaryButtonProps[]; + additionalActions?: AdditionalAction[]; upgradeInInterstitial?: boolean; - primaryActionOverride?: Record< string, { href?: string; label?: string } >; - secondaryAction?: Record< string, SecondaryButtonProps & { positionFirst?: boolean } >; - onInstallStandalone?: () => void; + primaryActionOverride?: AdditionalAction; + secondaryAction?: SecondaryAction; + onInstallStandalone?: InstallCallback; onActivateStandalone?: () => void; - status: keyof typeof PRODUCT_STATUSES; + status: ProductStatus; onMouseEnter?: MouseEventHandler< HTMLButtonElement >; onMouseLeave?: MouseEventHandler< HTMLButtonElement >; }; @@ -135,7 +137,7 @@ const ProductCard: FC< ProductCardProps > = props => { recordEvent( 'jetpack_myjetpack_product_card_install_standalone_plugin_click', { product: slug, } ); - onInstallStandalone(); + onInstallStandalone( {} ); }, [ slug, onInstallStandalone, recordEvent ] ); /** diff --git a/projects/packages/my-jetpack/_inc/components/product-card/status.tsx b/projects/packages/my-jetpack/_inc/components/product-card/status.tsx index 9277cb3867a31..e52fd2c9ae2ac 100644 --- a/projects/packages/my-jetpack/_inc/components/product-card/status.tsx +++ b/projects/packages/my-jetpack/_inc/components/product-card/status.tsx @@ -6,13 +6,13 @@ import styles from './style.module.scss'; import type { FC } from 'react'; interface StatusProps { - status: keyof typeof PRODUCT_STATUSES; + status: ProductStatus; isFetching: boolean; isInstallingStandalone: boolean; isOwned: boolean; } -type StatusStateFunction = ( status: keyof typeof PRODUCT_STATUSES, isOwned: boolean ) => string; +type StatusStateFunction = ( status: ProductStatus, isOwned: boolean ) => string; const getStatusLabel: StatusStateFunction = ( status, isOwned ) => { switch ( status ) { diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial/index.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial/index.jsx index 0cd2cb2cafe58..3b11e52e1ee41 100644 --- a/projects/packages/my-jetpack/_inc/components/product-interstitial/index.jsx +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial/index.jsx @@ -9,7 +9,6 @@ import { Text, TermsOfService, } from '@automattic/jetpack-components'; -import { useConnection } from '@automattic/jetpack-connection'; import { createInterpolateElement } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import clsx from 'clsx'; @@ -23,6 +22,7 @@ import useProduct from '../../data/products/use-product'; import { getMyJetpackWindowInitialState } from '../../data/utils/get-my-jetpack-window-state'; import useAnalytics from '../../hooks/use-analytics'; import { useGoBack } from '../../hooks/use-go-back'; +import useMyJetpackConnection from '../../hooks/use-my-jetpack-connection'; import useMyJetpackNavigate from '../../hooks/use-my-jetpack-navigate'; import GoBackLink from '../go-back-link'; import ProductDetailCard from '../product-detail-card'; @@ -80,9 +80,9 @@ export default function ProductInterstitial( { const { recordEvent } = useAnalytics(); const { onClickGoBack } = useGoBack( { slug } ); const { myJetpackCheckoutUri = '' } = getMyJetpackWindowInitialState(); - const { siteIsRegistering, handleRegisterSite } = useConnection( { + const { siteIsRegistering, handleRegisterSite } = useMyJetpackConnection( { skipUserConnection: true, - redirectUri: detail.postActivationUrl ? detail.postActivationUrl : null, + redirectUri: detail.postActivationUrl ?? null, } ); const showBundledTOS = ! hideTOS && !! bundle; const productName = detail?.title; diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/index.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/index.jsx index 63a6c35794b38..2e0f1520e9a7b 100644 --- a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/index.jsx +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/index.jsx @@ -1,7 +1,6 @@ /** * External dependencies */ -import { useConnection } from '@automattic/jetpack-connection'; import debugFactory from 'debug'; import { useCallback } from 'react'; /** @@ -9,6 +8,7 @@ import { useCallback } from 'react'; */ import ProductInterstitial from '../'; import useProduct from '../../../data/products/use-product'; +import useMyJetpackConnection from '../../../hooks/use-my-jetpack-connection'; import jetpackAiImage from '../jetpack-ai.png'; import styles from './style.module.scss'; @@ -23,7 +23,7 @@ export default function JetpackAiInterstitial() { const { detail } = useProduct( slug ); debug( detail ); - const { userConnectionData } = useConnection(); + const { userConnectionData } = useMyJetpackConnection(); const { currentUser } = userConnectionData; const { wpcomUser } = currentUser; const userId = currentUser?.id || 0; diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx index a1c9ecb3c5d38..62c0a1a724f9f 100644 --- a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx @@ -10,7 +10,6 @@ import { getRedirectUrl, Notice, } from '@automattic/jetpack-components'; -import { useConnection } from '@automattic/jetpack-connection'; import { Button, Card, ExternalLink } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; import { Icon, plus, help, check } from '@wordpress/icons'; @@ -23,6 +22,7 @@ import { useCallback, useState, useEffect } from 'react'; import useProduct from '../../../data/products/use-product'; import useAnalytics from '../../../hooks/use-analytics'; import { useGoBack } from '../../../hooks/use-go-back'; +import useMyJetpackConnection from '../../../hooks/use-my-jetpack-connection'; import useMyJetpackNavigate from '../../../hooks/use-my-jetpack-navigate'; import GoBackLink from '../../go-back-link'; import styles from './style.module.scss'; @@ -38,7 +38,7 @@ export default function () { const { detail } = useProduct( 'jetpack-ai' ); const { description, aiAssistantFeature } = detail; const [ showNotice, setShowNotice ] = useState( false ); - const { isRegistered } = useConnection(); + const { isRegistered } = useMyJetpackConnection(); const videoTitleContentGeneration = __( 'Generate and edit content faster with Jetpack AI Assistant', diff --git a/projects/packages/my-jetpack/_inc/components/redeem-token-screen/index.jsx b/projects/packages/my-jetpack/_inc/components/redeem-token-screen/index.jsx index f7a982206f278..8e56fd964dfd8 100644 --- a/projects/packages/my-jetpack/_inc/components/redeem-token-screen/index.jsx +++ b/projects/packages/my-jetpack/_inc/components/redeem-token-screen/index.jsx @@ -1,9 +1,8 @@ -import { useConnection } from '@automattic/jetpack-connection'; import { GoldenTokenModal } from '@automattic/jetpack-licensing'; import { __ } from '@wordpress/i18n'; -import React from 'react'; import { QUERY_PURCHASES_KEY, REST_API_SITE_PURCHASES_ENDPOINT } from '../../data/constants'; import useSimpleQuery from '../../data/use-simple-query'; +import useMyJetpackConnection from '../../hooks/use-my-jetpack-connection'; import { includesLifetimePurchase } from '../../utils/is-lifetime-purchase'; /** @@ -12,7 +11,7 @@ import { includesLifetimePurchase } from '../../utils/is-lifetime-purchase'; * @returns {object} The RedeemTokenScreen component. */ export default function RedeemTokenScreen() { - const { userConnectionData } = useConnection(); + const { userConnectionData } = useMyJetpackConnection(); // They might not have a display name set in wpcom, so fall back to wpcom login or local username. const displayName = userConnectionData?.currentUser?.wpcomUser?.display_name || diff --git a/projects/packages/my-jetpack/_inc/components/welcome-banner/index.jsx b/projects/packages/my-jetpack/_inc/components/welcome-banner/index.jsx index 51248bf0b6dab..fe64c838cfb78 100644 --- a/projects/packages/my-jetpack/_inc/components/welcome-banner/index.jsx +++ b/projects/packages/my-jetpack/_inc/components/welcome-banner/index.jsx @@ -1,11 +1,11 @@ import { Container, Col, Button, Text } from '@automattic/jetpack-components'; -import { useConnection } from '@automattic/jetpack-connection'; import { __ } from '@wordpress/i18n'; import { close } from '@wordpress/icons'; import { useEffect, useCallback, useState } from 'react'; import { MyJetpackRoutes } from '../../constants'; import useWelcomeBanner from '../../data/welcome-banner/use-welcome-banner'; import useAnalytics from '../../hooks/use-analytics'; +import useMyJetpackConnection from '../../hooks/use-my-jetpack-connection'; import useMyJetpackNavigate from '../../hooks/use-my-jetpack-navigate'; import { CardWrapper } from '../card'; import styles from './style.module.scss'; @@ -18,7 +18,7 @@ import styles from './style.module.scss'; const WelcomeBanner = () => { const { recordEvent } = useAnalytics(); const { isWelcomeBannerVisible, dismissWelcomeBanner } = useWelcomeBanner(); - const { isRegistered, isUserConnected } = useConnection(); + const { isRegistered, isUserConnected } = useMyJetpackConnection(); const navigateToConnectionPage = useMyJetpackNavigate( MyJetpackRoutes.Connection ); const [ bannerVisible, setBannerVisible ] = useState( isWelcomeBannerVisible ); const shouldDisplayConnectionButton = ! isRegistered || ! isUserConnected; diff --git a/projects/packages/my-jetpack/_inc/data/products/use-install-standalone-plugin.ts b/projects/packages/my-jetpack/_inc/data/products/use-install-standalone-plugin.ts index f7d6702b6de1e..ad77a9053c7c4 100644 --- a/projects/packages/my-jetpack/_inc/data/products/use-install-standalone-plugin.ts +++ b/projects/packages/my-jetpack/_inc/data/products/use-install-standalone-plugin.ts @@ -3,8 +3,22 @@ import { REST_API_SITE_PRODUCTS_ENDPOINT } from '../constants'; import { QUERY_INSTALL_PRODUCT_KEY } from '../constants'; import useSimpleMutation from '../use-simple-mutation'; import useProduct from './use-product'; +import type { APIFetchOptionsWithQueryParams } from '../use-simple-mutation'; +import type { UseMutateFunction } from '@tanstack/react-query'; -const useInstallStandalonePlugin = ( productId: string ) => { +export type InstallCallback = UseMutateFunction< + void, + Error, + APIFetchOptionsWithQueryParams, + unknown +>; + +type UseInstallStandalonePluginFunction = ( productId: string ) => { + install: InstallCallback; + isPending: boolean; +}; + +const useInstallStandalonePlugin: UseInstallStandalonePluginFunction = productId => { const { detail, refetch } = useProduct( productId ); const { mutate: install, isPending } = useSimpleMutation( { diff --git a/projects/packages/my-jetpack/_inc/data/use-simple-mutation.ts b/projects/packages/my-jetpack/_inc/data/use-simple-mutation.ts index 5d7b7c3d59396..c0694c3d7f21b 100644 --- a/projects/packages/my-jetpack/_inc/data/use-simple-mutation.ts +++ b/projects/packages/my-jetpack/_inc/data/use-simple-mutation.ts @@ -5,7 +5,7 @@ import { useFetchingErrorNotice } from './notices/use-fetching-error-notice'; import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-query'; import type { APIFetchOptions } from '@wordpress/api-fetch'; -type APIFetchOptionsWithQueryParams = APIFetchOptions & { +export type APIFetchOptionsWithQueryParams = APIFetchOptions & { queryParams?: Record< string, string | Array< string > | object >; }; diff --git a/projects/packages/my-jetpack/changelog/update-use-connection-to-use-my-jetpack-connection-hook b/projects/packages/my-jetpack/changelog/update-use-connection-to-use-my-jetpack-connection-hook new file mode 100644 index 0000000000000..9282e9d8c09dd --- /dev/null +++ b/projects/packages/my-jetpack/changelog/update-use-connection-to-use-my-jetpack-connection-hook @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Update uses of useConnection to useMyJetpackConnection and improve typing in a few places diff --git a/projects/packages/my-jetpack/global.d.ts b/projects/packages/my-jetpack/global.d.ts index 09ec575ad911f..9a60ed9c37af4 100644 --- a/projects/packages/my-jetpack/global.d.ts +++ b/projects/packages/my-jetpack/global.d.ts @@ -9,6 +9,20 @@ declare module '@wordpress/components'; declare module '@wordpress/compose'; declare module '@wordpress/icons'; declare module '@automattic/jetpack-connection'; +declare module '@wordpress/url'; + +type ProductStatus = + | 'active' + | 'inactive' + | 'module_disabled' + | 'site_connection_error' + | 'plugin_absent' + | 'plugin_absent_with_plan' + | 'needs_plan' + | 'needs_activation' + | 'needs_first_site_connection' + | 'user_connection_error' + | 'can_upgrade'; type JetpackModule = | 'anti-spam' @@ -186,7 +200,7 @@ interface Window { is_standalone_installed: boolean; is_standalone_active: boolean; }; - status: string; + status: ProductStatus; supported_products: string[]; tiers: string[]; title: string; diff --git a/projects/packages/my-jetpack/package.json b/projects/packages/my-jetpack/package.json index 26174b4405ee4..4621861bff6d7 100644 --- a/projects/packages/my-jetpack/package.json +++ b/projects/packages/my-jetpack/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-my-jetpack", - "version": "4.32.0", + "version": "4.32.1-alpha", "description": "WP Admin page with information and configuration shared among all Jetpack stand-alone plugins", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/my-jetpack/#readme", "bugs": { diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index ca752c3750124..909700a440354 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -41,7 +41,7 @@ class Initializer { * * @var string */ - const PACKAGE_VERSION = '4.32.0'; + const PACKAGE_VERSION = '4.32.1-alpha'; /** * HTML container ID for the IDC screen on My Jetpack page. From 6eba2100bac7fb400230e4dfdf4b662b81b891ed Mon Sep 17 00:00:00 2001 From: Omar Alshaker Date: Thu, 8 Aug 2024 17:16:03 +0200 Subject: [PATCH 3/7] Warnings: Handle missing odie-last-chat-id (#38785) --- .../jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id | 4 ++++ .../features/help-center/class-wp-rest-help-center-odie.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id b/projects/packages/jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id new file mode 100644 index 0000000000000..d95a7ef42d8cf --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + + diff --git a/projects/packages/jetpack-mu-wpcom/src/features/help-center/class-wp-rest-help-center-odie.php b/projects/packages/jetpack-mu-wpcom/src/features/help-center/class-wp-rest-help-center-odie.php index 71ccf619061f3..77ab16f6c032b 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/help-center/class-wp-rest-help-center-odie.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/help-center/class-wp-rest-help-center-odie.php @@ -204,7 +204,7 @@ public function get_last_chat_id() { $projected_response = array( 'odie_chat_id' => $response->odie_chat_id, - 'odie_last_chat_id' => $response->odie_last_chat_id, + 'odie_last_chat_id' => $response->odie_last_chat_id ?? null, ); return rest_ensure_response( $projected_response ); From 95c0333650c5001cd48ff5466d8118a81cd715e2 Mon Sep 17 00:00:00 2001 From: Miguel Lezama Date: Thu, 8 Aug 2024 15:09:24 -0300 Subject: [PATCH 4/7] Newsletter: Email Preview: Improve styles (#38791) --- .../changelog/update-email-preview-styles | 4 + .../blocks/subscriptions/email-preview.js | 112 +++++++++++++----- .../blocks/subscriptions/email-preview.scss | 6 +- 3 files changed, 91 insertions(+), 31 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/update-email-preview-styles diff --git a/projects/plugins/jetpack/changelog/update-email-preview-styles b/projects/plugins/jetpack/changelog/update-email-preview-styles new file mode 100644 index 0000000000000..f0791d44441e4 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-email-preview-styles @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +feature flag feature, not yet released diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js index 55139b89d5daf..34313510ad5f2 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js @@ -20,7 +20,7 @@ import { useSelect, useDispatch } from '@wordpress/data'; import { store as editorStore } from '@wordpress/editor'; import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { desktop, mobile, tablet, check } from '@wordpress/icons'; +import { desktop, mobile, tablet, check, people, currencyDollar } from '@wordpress/icons'; import './email-preview.scss'; import { useCallback, useEffect } from 'react'; import { accessOptions } from '../../shared/memberships/constants'; @@ -123,39 +123,79 @@ export default function EmailPreview( { isModalOpen, closeModal } ) { } const devices = [ - { name: 'desktop', icon: desktop, label: __( 'Desktop', 'jetpack' ), width: '100%' }, - { name: 'tablet', icon: tablet, label: __( 'Tablet', 'jetpack' ), width: '768px' }, - { name: 'mobile', icon: mobile, label: __( 'Mobile', 'jetpack' ), width: '360px' }, + { + name: 'desktop', + icon: desktop, + label: __( 'Desktop', 'jetpack' ), + width: '100%', + size: 'lg', + }, + { + name: 'tablet', + icon: tablet, + label: __( 'Tablet', 'jetpack' ), + width: '768px', + size: 'md', + }, + { + name: 'mobile', + icon: mobile, + label: __( 'Mobile', 'jetpack' ), + width: '360px', + size: 'sm', + }, ]; -const DevicePicker = ( { selectedDevice, setSelectedDevice } ) => ( - - { devices.map( device => ( - - ) ) } - -); +const DevicePicker = ( { selectedDevice, setSelectedDevice } ) => { + const [ isMedium ] = useBreakpointMatch( 'md' ); + const [ isSmall ] = useBreakpointMatch( 'sm' ); + + if ( isSmall ) { + return null; + } + + const getAvailableDevices = () => { + if ( isMedium ) { + return devices.filter( device => device.size !== 'lg' ); + } + return devices; + }; + + return ( + + { getAvailableDevices().map( device => ( + + ) ) } + + ); +}; const AccessPicker = ( { selectedAccess, setSelectedAccess } ) => { + const [ isSmall ] = useBreakpointMatch( 'sm' ); + const accessOptionsList = [ { - label: __( 'Subscribers', 'jetpack' ), + label: accessOptions.subscribers.label, value: accessOptions.subscribers.key, + icon: people, }, { - label: __( 'Paid Subscribers', 'jetpack' ), + label: accessOptions.paid_subscribers.label, value: accessOptions.paid_subscribers.key, + icon: currencyDollar, }, ]; + return ( { isBlock isAdaptiveWidth > - { accessOptionsList.map( access => ( - - ) ) } + { accessOptionsList.map( access => + isSmall ? ( + + ) : ( + + ) + ) } ); }; @@ -177,8 +230,10 @@ const HeaderActions = ( { selectedDevice, setSelectedDevice, } ) => { + const [ isSmall ] = useBreakpointMatch( 'sm' ); + return ( - + @@ -255,14 +310,14 @@ export function PreviewModal( { isOpen, onClose, postId } ) { setSelectedDevice={ setSelectedDevice } /> } - overlayClassName="jetpack-preview-email-modal-overlay" + className="jetpack-email-preview-modal" >
{ isLoading ? ( @@ -273,6 +328,7 @@ export function PreviewModal( { isOpen, onClose, postId } ) { style={ { width: deviceWidth, height: '100%', + border: 'none', } } title={ __( 'Email Preview', 'jetpack' ) } /> diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.scss b/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.scss index 5f8fcb177fdb8..8e29125ac6984 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.scss +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.scss @@ -61,8 +61,8 @@ align-items: center; } -.jetpack-preview-email-modal-overlay { - .jetpack-email-preview-select-control .components-input-control__prefix { - margin-left: 18px; +.jetpack-email-preview-modal { + h1 { + flex-shrink: 0; } } \ No newline at end of file From 5a03b6d4a6189c55279de15d1b73e7cbd910eddb Mon Sep 17 00:00:00 2001 From: Paulo Cruz Date: Thu, 8 Aug 2024 15:46:48 -0300 Subject: [PATCH 5/7] Changelog and readme.txt edits. (#38792) --- projects/packages/jetpack-mu-wpcom/CHANGELOG.md | 5 +++++ .../changelog/add-null-fallback-odie-chat-id | 4 ---- .../jetpack-mu-wpcom/changelog/fix-load-scheduled-updates | 4 ---- projects/packages/jetpack-mu-wpcom/package.json | 2 +- .../packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php | 2 +- projects/plugins/mu-wpcom-plugin/CHANGELOG.md | 4 ++++ .../mu-wpcom-plugin/changelog/add-consolidate-initial-state | 5 ----- .../mu-wpcom-plugin/changelog/add-profile-link-towpcom | 5 ----- projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-coblocks | 5 ----- .../mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks | 5 ----- .../mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 | 5 ----- .../mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 | 5 ----- .../changelog/update-sync-hpos-checksum-fields-to-consider | 5 ----- projects/plugins/mu-wpcom-plugin/composer.json | 2 +- projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php | 2 +- projects/plugins/mu-wpcom-plugin/package.json | 2 +- 16 files changed, 14 insertions(+), 48 deletions(-) delete mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id delete mode 100644 projects/packages/jetpack-mu-wpcom/changelog/fix-load-scheduled-updates delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/add-consolidate-initial-state delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/add-profile-link-towpcom delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-coblocks delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/update-sync-hpos-checksum-fields-to-consider diff --git a/projects/packages/jetpack-mu-wpcom/CHANGELOG.md b/projects/packages/jetpack-mu-wpcom/CHANGELOG.md index e8b0a2b0d0430..a7becc47d5062 100644 --- a/projects/packages/jetpack-mu-wpcom/CHANGELOG.md +++ b/projects/packages/jetpack-mu-wpcom/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.54.1] - 2024-08-08 +### Fixed +- Load Scheduled_Updates for non-wpcom users [#38772] + ## [5.54.0] - 2024-08-08 ### Added - MU WPCOM: Port enqueue_coblocks_gallery_scripts from the ETK [#38731] @@ -1116,6 +1120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Testing initial package release. +[5.54.1]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.54.0...v5.54.1 [5.54.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.53.1...v5.54.0 [5.53.1]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.53.0...v5.53.1 [5.53.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.52.1...v5.53.0 diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id b/projects/packages/jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id deleted file mode 100644 index d95a7ef42d8cf..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/changelog/add-null-fallback-odie-chat-id +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fixed - - diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-load-scheduled-updates b/projects/packages/jetpack-mu-wpcom/changelog/fix-load-scheduled-updates deleted file mode 100644 index 21a0f6ed5cb27..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/changelog/fix-load-scheduled-updates +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fixed - -Load Scheduled_Updates for non-wpcom users diff --git a/projects/packages/jetpack-mu-wpcom/package.json b/projects/packages/jetpack-mu-wpcom/package.json index 2d55a2e51017a..6fa03c5993ab4 100644 --- a/projects/packages/jetpack-mu-wpcom/package.json +++ b/projects/packages/jetpack-mu-wpcom/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-mu-wpcom", - "version": "5.54.1-alpha", + "version": "5.54.1", "description": "Enhances your site with features powered by WordPress.com", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme", "bugs": { diff --git a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php index 424b3f3710f8d..7e72fb87e2358 100644 --- a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php +++ b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php @@ -13,7 +13,7 @@ * Jetpack_Mu_Wpcom main class. */ class Jetpack_Mu_Wpcom { - const PACKAGE_VERSION = '5.54.1-alpha'; + const PACKAGE_VERSION = '5.54.1'; const PKG_DIR = __DIR__ . '/../'; const BASE_DIR = __DIR__ . '/'; const BASE_FILE = __FILE__; diff --git a/projects/plugins/mu-wpcom-plugin/CHANGELOG.md b/projects/plugins/mu-wpcom-plugin/CHANGELOG.md index a54c35983757a..4833558bcb471 100644 --- a/projects/plugins/mu-wpcom-plugin/CHANGELOG.md +++ b/projects/plugins/mu-wpcom-plugin/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2.5.5 - 2024-08-08 +### Changed +- Internal updates. + ## 2.5.4 - 2024-08-05 ### Changed - Fixup versions [#38612] diff --git a/projects/plugins/mu-wpcom-plugin/changelog/add-consolidate-initial-state b/projects/plugins/mu-wpcom-plugin/changelog/add-consolidate-initial-state deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/add-consolidate-initial-state +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/add-profile-link-towpcom b/projects/plugins/mu-wpcom-plugin/changelog/add-profile-link-towpcom deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/add-profile-link-towpcom +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-coblocks b/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-coblocks deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-coblocks +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks b/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 b/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 b/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/update-sync-hpos-checksum-fields-to-consider b/projects/plugins/mu-wpcom-plugin/changelog/update-sync-hpos-checksum-fields-to-consider deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/update-sync-hpos-checksum-fields-to-consider +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/composer.json b/projects/plugins/mu-wpcom-plugin/composer.json index b81b22a4edca5..07697655bf769 100644 --- a/projects/plugins/mu-wpcom-plugin/composer.json +++ b/projects/plugins/mu-wpcom-plugin/composer.json @@ -46,6 +46,6 @@ ] }, "config": { - "autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ2_5_5_alpha" + "autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ2_5_5" } } diff --git a/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php b/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php index 1c56f38491d9f..8b8dd2ae5115e 100644 --- a/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php +++ b/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php @@ -3,7 +3,7 @@ * * Plugin Name: WordPress.com Features * Description: Test plugin for the jetpack-mu-wpcom package - * Version: 2.5.5-alpha + * Version: 2.5.5 * Author: Automattic * License: GPLv2 or later * Text Domain: jetpack-mu-wpcom-plugin diff --git a/projects/plugins/mu-wpcom-plugin/package.json b/projects/plugins/mu-wpcom-plugin/package.json index d204e724a0cd8..619d22fd1779e 100644 --- a/projects/plugins/mu-wpcom-plugin/package.json +++ b/projects/plugins/mu-wpcom-plugin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-mu-wpcom-plugin", - "version": "2.5.5-alpha", + "version": "2.5.5", "description": "Test plugin for the jetpack-mu-wpcom package", "homepage": "https://jetpack.com", "bugs": { From c77c6acb14eed1d06ecdac8ffa5a2ba9de47560b Mon Sep 17 00:00:00 2001 From: Miguel Lezama Date: Thu, 8 Aug 2024 18:49:10 -0300 Subject: [PATCH 6/7] Newsletter: Email Preview: Improve Access Selector on mobile (#38793) --- ...ate-email-preview-access-selector-disabled | 4 ++++ .../blocks/subscriptions/email-preview.js | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/update-email-preview-access-selector-disabled diff --git a/projects/plugins/jetpack/changelog/update-email-preview-access-selector-disabled b/projects/plugins/jetpack/changelog/update-email-preview-access-selector-disabled new file mode 100644 index 0000000000000..10d4029800bec --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-email-preview-access-selector-disabled @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +feature flaged feature diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js index 34313510ad5f2..2355eaaef9751 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js @@ -24,6 +24,7 @@ import { desktop, mobile, tablet, check, people, currencyDollar } from '@wordpre import './email-preview.scss'; import { useCallback, useEffect } from 'react'; import { accessOptions } from '../../shared/memberships/constants'; +import { useAccessLevel } from '../../shared/memberships/edit'; import illustration from './email-preview-illustration.svg'; export default function EmailPreview( { isModalOpen, closeModal } ) { @@ -182,6 +183,10 @@ const DevicePicker = ( { selectedDevice, setSelectedDevice } ) => { const AccessPicker = ( { selectedAccess, setSelectedAccess } ) => { const [ isSmall ] = useBreakpointMatch( 'sm' ); + const postType = useSelect( select => select( editorStore ).getCurrentPostType(), [] ); + const accessLevel = useAccessLevel( postType ); + + const isPaidOptionDisabled = ! accessLevel || accessLevel !== accessOptions.paid_subscribers.key; const accessOptionsList = [ { @@ -193,13 +198,24 @@ const AccessPicker = ( { selectedAccess, setSelectedAccess } ) => { label: accessOptions.paid_subscribers.label, value: accessOptions.paid_subscribers.key, icon: currencyDollar, + disabled: isPaidOptionDisabled, }, ]; + const handleChange = value => { + if ( ! isPaidOptionDisabled ) { + setSelectedAccess( value ); + } + }; + + if ( isSmall && isPaidOptionDisabled ) { + return null; + } + return ( { key={ access.value } value={ access.value } label={ access.label } + disabled={ access.disabled } /> ) ) } From d1a9ad57b1ac6609ef3a864315a0c009bd774446 Mon Sep 17 00:00:00 2001 From: Karen Attfield Date: Fri, 9 Aug 2024 08:01:16 +0100 Subject: [PATCH 7/7] Contact Form: Removing deprecated Google Drive Helper file, and jetpack_form_register_pattern function (#38786) --- projects/plugins/jetpack/.phan/baseline.php | 4 +- .../lib/class-jetpack-google-drive-helper.php | 133 ------------------ .../changelog/remove-google-drive-helper | 4 + .../plugins/jetpack/modules/contact-form.php | 103 -------------- 4 files changed, 5 insertions(+), 239 deletions(-) delete mode 100644 projects/plugins/jetpack/_inc/lib/class-jetpack-google-drive-helper.php create mode 100644 projects/plugins/jetpack/changelog/remove-google-drive-helper diff --git a/projects/plugins/jetpack/.phan/baseline.php b/projects/plugins/jetpack/.phan/baseline.php index 1610ab760497e..cd06acc4b737c 100644 --- a/projects/plugins/jetpack/.phan/baseline.php +++ b/projects/plugins/jetpack/.phan/baseline.php @@ -14,7 +14,7 @@ // PhanNoopNew : 200+ occurrences // PhanTypeMismatchArgumentProbablyReal : 200+ occurrences // PhanTypeMismatchReturn : 150+ occurrences - // PhanTypeMismatchReturnProbablyReal : 140+ occurrences + // PhanTypeMismatchReturnProbablyReal : 130+ occurrences // PhanDeprecatedFunction : 120+ occurrences // PhanTypePossiblyInvalidDimOffset : 95+ occurrences // PhanRedundantCondition : 70+ occurrences @@ -116,7 +116,6 @@ '_inc/lib/admin-pages/class-jetpack-redux-state-helper.php' => ['PhanParamTooMany', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimAssignment'], '_inc/lib/admin-pages/class.jetpack-admin-page.php' => ['PhanDeprecatedProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredProperty'], '_inc/lib/class-jetpack-ai-helper.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchPropertyDefault'], - '_inc/lib/class-jetpack-google-drive-helper.php' => ['PhanTypeMismatchReturnProbablyReal'], '_inc/lib/class-jetpack-instagram-gallery-helper.php' => ['PhanTypeMismatchArgument'], '_inc/lib/class-jetpack-mapbox-helper.php' => ['PhanTypeMismatchArgumentNullable'], '_inc/lib/class-jetpack-podcast-feed-locator.php' => ['PhanDeprecatedFunctionInternal'], @@ -329,7 +328,6 @@ 'modules/comments/base.php' => ['PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredProperty'], 'modules/comments/comments.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanUndeclaredFunction'], 'modules/comments/subscription-modal-on-comment/class-jetpack-subscription-modal-on-comment.php' => ['PhanTypeMismatchReturnNullable'], - 'modules/contact-form.php' => ['PhanSuspiciousMagicConstant'], 'modules/copy-post.php' => ['PhanNoopNew'], 'modules/custom-css/csstidy/class.csstidy-ctype.php' => ['PhanRedefineFunctionInternal'], 'modules/custom-css/csstidy/class.csstidy-optimise.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginSimplifyExpressionBool', 'PhanTypeComparisonFromArray', 'PhanTypeConversionFromArray', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeInvalidRightOperandOfNumericOp', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchReturnProbablyReal'], diff --git a/projects/plugins/jetpack/_inc/lib/class-jetpack-google-drive-helper.php b/projects/plugins/jetpack/_inc/lib/class-jetpack-google-drive-helper.php deleted file mode 100644 index bbc61f4e10290..0000000000000 --- a/projects/plugins/jetpack/_inc/lib/class-jetpack-google-drive-helper.php +++ /dev/null @@ -1,133 +0,0 @@ -has_valid_connection - * @param int $user_id The user ID. - * @return array Array with single 'valid' (bool) entry. - */ - public static function has_valid_connection( $user_id ) { - _deprecated_function( __METHOD__, 'jetpack-13.4', 'Automattic\Jetpack\Forms\Service\Google_Drive_Helper->has_valid_connection' ); - $site_id = Manager::get_site_id(); - if ( is_wp_error( $site_id ) ) { - return false; - } - - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - // check for gdrive helper class, call synchronously on .com - require_lib( 'google-sheets-helper' ); - $user_id = (int) get_current_user_id(); - $token = WPCOM_Google_Sheets_helper::get_google_drive_token_for_user_id( $user_id ); - - return ! is_wp_error( $token ) && ! $token->is_expired(); - } - - $request_path = sprintf( '/sites/%d/google-drive/connection', $site_id ); - $wpcom_request = Client::wpcom_json_api_request_as_user( - $request_path, - '2', - array( - 'method' => 'GET', - 'headers' => array( - 'content-type' => 'application/json', - 'X-Forwarded-For' => ( new Visitor() )->get_ip( true ), - ), - ) - ); - - $response_code = wp_remote_retrieve_response_code( $wpcom_request ); - if ( 200 !== $response_code ) { - return new WP_Error( - 'failed_to_fetch_data', - esc_html__( 'Unable to fetch the requested data.', 'jetpack' ), - array( 'status' => $response_code ) - ); - } - $result = json_decode( wp_remote_retrieve_body( $wpcom_request ), true ); - - return ! empty( $result ) && ! empty( $result['valid'] ); - } - - /** - * Creates a Google Spreadsheet and returns some of its meta - * - * @deprecated 13.4 Use Automattic\Jetpack\Forms\Service\Google_Drive_Helper->create_sheet - * @param int $user_id The user ID. - * @param string $title The spreadsheet title. - * @param array $rows Array of arrays with values. - * @return array|WP_Error - */ - public static function create_sheet( $user_id, $title, $rows = array() ) { - _deprecated_function( __METHOD__, 'jetpack-13.4', 'Automattic\Jetpack\Forms\Service\Google_Drive_Helper->create_sheet' ); - $site_id = Manager::get_site_id(); - if ( is_wp_error( $site_id ) ) { - return false; - } - - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - // check for gdrive helper class, call synchronously on .com - require_lib( 'google-sheets-helper' ); - $helper = WPCOM_Google_Sheets_helper::create_for_user( $user_id ); - - if ( is_wp_error( $helper ) ) { - return $helper; - } - - $spreadsheet = $helper->create_spreadsheet( $title, $rows ); - - if ( is_wp_error( $spreadsheet ) ) { - return $spreadsheet; - } - - return array( - // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- as is on google client - 'sheet_link' => $spreadsheet->spreadsheetUrl, - // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- as is on google client - 'sheet_id' => $spreadsheet->spreadsheetId, - ); - } - - $request_path = sprintf( '/sites/%d/google-drive/sheets', $site_id ); - $wpcom_request = Client::wpcom_json_api_request_as_user( - $request_path, - '2', - array( - 'method' => 'POST', - 'headers' => array( - 'content-type' => 'application/json', - 'X-Forwarded-For' => ( new Visitor() )->get_ip( true ), - ), - ), - array( - 'title' => $title, - 'rows' => $rows, - ) - ); - $response_code = wp_remote_retrieve_response_code( $wpcom_request ); - if ( 200 !== $response_code ) { - return new WP_Error( - 'failed_to_fetch_data', - esc_html__( 'Unable to fetch the requested data.', 'jetpack' ), - array( 'status' => $response_code ) - ); - } - return json_decode( wp_remote_retrieve_body( $wpcom_request ), true ); - } -} diff --git a/projects/plugins/jetpack/changelog/remove-google-drive-helper b/projects/plugins/jetpack/changelog/remove-google-drive-helper new file mode 100644 index 0000000000000..44e0e8410807b --- /dev/null +++ b/projects/plugins/jetpack/changelog/remove-google-drive-helper @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Contact Form: Removing deprecated functionality diff --git a/projects/plugins/jetpack/modules/contact-form.php b/projects/plugins/jetpack/modules/contact-form.php index e943fa6b37a10..a01f48e8a82c0 100644 --- a/projects/plugins/jetpack/modules/contact-form.php +++ b/projects/plugins/jetpack/modules/contact-form.php @@ -24,106 +24,3 @@ * Load the newer Jetpack Forms package. */ Jetpack_Forms::load_contact_form(); - -/** - * Register Jetpack Form patterns - * - * @deprecated 13.4 Use Automattic\Jetpack\Forms\ContactForm\Util::register_pattern - */ -function jetpack_form_register_pattern() { - _deprecated_function( __METHOD__, 'jetpack-13.4', 'Automattic\Jetpack\Forms\ContactForm\Util::register_pattern' ); - $category_slug = 'forms'; - register_block_pattern_category( $category_slug, array( 'label' => __( 'Forms', 'jetpack' ) ) ); - - $patterns = array( - 'contact-form' => array( - 'title' => 'Contact Form', - 'blockTypes' => array( 'jetpack/contact-form' ), - 'categories' => array( $category_slug ), - 'content' => ' -
- - - - -
- ', - ), - 'newsletter-form' => array( - 'title' => 'Newsletter Subscription Form', - 'blockTypes' => array( 'jetpack/contact-form' ), - 'categories' => array( $category_slug ), - 'content' => ' -
- - - - -
- ', - ), - 'rsvp-form' => array( - 'title' => 'RSVP Form', - 'blockTypes' => array( 'jetpack/contact-form' ), - 'categories' => array( $category_slug ), - 'content' => ' -
- - - - - -
- ', - ), - 'registration-form' => array( - 'title' => 'Registration Form', - 'blockTypes' => array( 'jetpack/contact-form' ), - 'categories' => array( $category_slug ), - 'content' => ' -
- - - - - - -
- ', - ), - 'appointment-form' => array( - 'title' => 'Appointment Form', - 'blockTypes' => array( 'jetpack/contact-form' ), - 'categories' => array( $category_slug ), - 'content' => ' -
- - - - - - - -
- ', - ), - 'feedback-form' => array( - 'title' => 'Feedback Form', - 'blockTypes' => array( 'jetpack/contact-form' ), - 'categories' => array( $category_slug ), - 'content' => ' -
- - - - - -
- ', - ), - ); - - foreach ( $patterns as $name => $pattern ) { - register_block_pattern( $name, $pattern ); - } -}