From cbf4e67d5eec2bfdcfba9bcbc1e68bc9dccd0e05 Mon Sep 17 00:00:00 2001 From: MILLER/F Date: Wed, 8 Nov 2023 17:23:10 +0000 Subject: [PATCH 01/16] Change tier hash (#34011) --- projects/plugins/jetpack/changelog/add-tier-hash | 4 ++++ .../plugins/jetpack/extensions/shared/memberships/utils.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/add-tier-hash diff --git a/projects/plugins/jetpack/changelog/add-tier-hash b/projects/plugins/jetpack/changelog/add-tier-hash new file mode 100644 index 0000000000000..3186dc60cb896 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-tier-hash @@ -0,0 +1,4 @@ +Significance: patch +Type: compat + +Added tier hash diff --git a/projects/plugins/jetpack/extensions/shared/memberships/utils.js b/projects/plugins/jetpack/extensions/shared/memberships/utils.js index f09b6bee5307d..76f0a59b28720 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/utils.js +++ b/projects/plugins/jetpack/extensions/shared/memberships/utils.js @@ -22,10 +22,10 @@ export const encodeValueForShortcodeAttribute = value => { .replace( /\u200b/g, '​' ); }; -export const getPaidPlanLink = alreadyHasNewsletterPlans => { +export const getPaidPlanLink = alreadyHasTierPlans => { const link = 'https://wordpress.com/earn/payments-plans/' + location.hostname; // We force the "Newsletters plan" link only if there is no plans already created - return alreadyHasNewsletterPlans ? link : link + '#add-newsletter-payment-plan'; + return alreadyHasTierPlans ? link : link + '#add-tier-plan'; }; export const getShowMisconfigurationWarning = ( postVisibility, accessLevel ) => { From 435393d37bb9107f8270b99545ef326de030658c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Wed, 8 Nov 2023 12:12:31 -0600 Subject: [PATCH 02/16] AI Assistant: introduce action to increase requests counter (#34019) * introduce constants file * introduce ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT * introduce a reducer file * reduce the encrease counter action * changelog --- .../update-ai-assistant-reduce-requests | 4 + .../extensions/store/wordpress-com/actions.ts | 27 ++++-- .../store/wordpress-com/constants.ts | 12 +++ .../extensions/store/wordpress-com/index.ts | 73 +-------------- .../extensions/store/wordpress-com/reducer.ts | 93 +++++++++++++++++++ 5 files changed, 133 insertions(+), 76 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/update-ai-assistant-reduce-requests create mode 100644 projects/plugins/jetpack/extensions/store/wordpress-com/constants.ts create mode 100644 projects/plugins/jetpack/extensions/store/wordpress-com/reducer.ts diff --git a/projects/plugins/jetpack/changelog/update-ai-assistant-reduce-requests b/projects/plugins/jetpack/changelog/update-ai-assistant-reduce-requests new file mode 100644 index 0000000000000..b1cead40d8683 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-ai-assistant-reduce-requests @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +AI Assistant: introduce action to increase requests counter diff --git a/projects/plugins/jetpack/extensions/store/wordpress-com/actions.ts b/projects/plugins/jetpack/extensions/store/wordpress-com/actions.ts index 64e84d027b416..5ebccaf31544a 100644 --- a/projects/plugins/jetpack/extensions/store/wordpress-com/actions.ts +++ b/projects/plugins/jetpack/extensions/store/wordpress-com/actions.ts @@ -3,8 +3,16 @@ */ import apiFetch from '@wordpress/api-fetch'; /** - * Types + * Types & Constants */ +import { + ACTION_FETCH_FROM_API, + ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT, + ACTION_REQUEST_AI_ASSISTANT_FEATURE, + ACTION_SET_PLANS, + ACTION_STORE_AI_ASSISTANT_FEATURE, + ENDPOINT_AI_ASSISTANT_FEATURE, +} from './constants'; import type { Plan } from './types'; import type { AiFeatureProps } from './types'; import type { SiteAIAssistantFeatureEndpointResponseProps } from '../../types'; @@ -41,21 +49,21 @@ export function mapAIFeatureResponseToAiFeatureProps( const actions = { setPlans( plans: Array< Plan > ) { return { - type: 'SET_PLANS', + type: ACTION_SET_PLANS, plans, }; }, fetchFromAPI( url: string ) { return { - type: 'FETCH_FROM_API', + type: ACTION_FETCH_FROM_API, url, }; }, storeAiAssistantFeature( feature: AiFeatureProps ) { return { - type: 'STORE_AI_ASSISTANT_FEATURE', + type: ACTION_STORE_AI_ASSISTANT_FEATURE, feature, }; }, @@ -68,11 +76,11 @@ const actions = { fetchAiAssistantFeature() { return async ( { dispatch } ) => { // Dispatch isFetching action. - dispatch( { type: 'REQUEST_AI_ASSISTANT_FEATURE' } ); + dispatch( { type: ACTION_REQUEST_AI_ASSISTANT_FEATURE } ); try { const response: SiteAIAssistantFeatureEndpointResponseProps = await apiFetch( { - path: '/wpcom/v2/jetpack-ai/ai-assistant-feature', + path: ENDPOINT_AI_ASSISTANT_FEATURE, } ); // Store the feature in the store. @@ -85,6 +93,13 @@ const actions = { } }; }, + + increaseAiAssistantRequestsCount( count = 1 ) { + return { + type: ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT, + count, + }; + }, }; export default actions; diff --git a/projects/plugins/jetpack/extensions/store/wordpress-com/constants.ts b/projects/plugins/jetpack/extensions/store/wordpress-com/constants.ts new file mode 100644 index 0000000000000..91c46907438d6 --- /dev/null +++ b/projects/plugins/jetpack/extensions/store/wordpress-com/constants.ts @@ -0,0 +1,12 @@ +/** + * Actions + */ +export const ACTION_SET_PLANS = 'SET_PLANS'; +export const ACTION_FETCH_FROM_API = 'FETCH_FROM_API'; +export const ACTION_STORE_AI_ASSISTANT_FEATURE = 'STORE_AI_ASSISTANT_FEATURE'; +export const ACTION_REQUEST_AI_ASSISTANT_FEATURE = 'REQUEST_AI_ASSISTANT_FEATURE'; +export const ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT = 'INCREASE_AI_ASSISTANT_REQUESTS_COUNT'; +/** + * Endpoints + */ +export const ENDPOINT_AI_ASSISTANT_FEATURE = '/wpcom/v2/jetpack-ai/ai-assistant-feature'; diff --git a/projects/plugins/jetpack/extensions/store/wordpress-com/index.ts b/projects/plugins/jetpack/extensions/store/wordpress-com/index.ts index ef337a7726118..f737bf19446e4 100644 --- a/projects/plugins/jetpack/extensions/store/wordpress-com/index.ts +++ b/projects/plugins/jetpack/extensions/store/wordpress-com/index.ts @@ -6,6 +6,7 @@ import { createReduxStore, register } from '@wordpress/data'; * Internal dependencies */ import actions from './actions'; +import reducer from './reducer'; /** * Types */ @@ -13,81 +14,13 @@ import type { PlanStateProps } from './types'; const store = 'wordpress-com/plans'; -const INITIAL_STATE: PlanStateProps = { - plans: [], - features: { - aiAssistant: { - hasFeature: false, - isOverLimit: false, - requestsCount: 0, - requestsLimit: 0, - requireUpgrade: false, - errorMessage: '', - errorCode: '', - upgradeType: 'default', - currentTier: { - value: 1, - }, - usagePeriod: { - currentStart: '', - nextStart: '', - requestsCount: 0, - }, - _meta: { - isRequesting: false, - }, - }, - }, -}; - const wordpressPlansStore = createReduxStore( store, { __experimentalUseThunks: true, - reducer( state = INITIAL_STATE, action ) { - switch ( action.type ) { - case 'SET_PLANS': - return { - ...state, - plans: action.plans, - }; - - case 'REQUEST_AI_ASSISTANT_FEATURE': - return { - ...state, - features: { - ...state.features, - aiAssistant: { - ...state.features.aiAssistant, - _meta: { - ...state.features.aiAssistant._meta, - isRequesting: true, - }, - }, - }, - }; - - case 'STORE_AI_ASSISTANT_FEATURE': { - return { - ...state, - features: { - ...state.features, - aiAssistant: { - ...action.feature, - _meta: { - ...state.features.aiAssistant._meta, - isRequesting: false, - }, - }, - }, - }; - } - } - - return state; - }, - actions, + reducer, + selectors: { /* * Return the plan with the given slug. diff --git a/projects/plugins/jetpack/extensions/store/wordpress-com/reducer.ts b/projects/plugins/jetpack/extensions/store/wordpress-com/reducer.ts new file mode 100644 index 0000000000000..16d66949bbd77 --- /dev/null +++ b/projects/plugins/jetpack/extensions/store/wordpress-com/reducer.ts @@ -0,0 +1,93 @@ +/** + * Types + */ +import { + ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT, + ACTION_REQUEST_AI_ASSISTANT_FEATURE, + ACTION_SET_PLANS, + ACTION_STORE_AI_ASSISTANT_FEATURE, +} from './constants'; +import type { PlanStateProps } from './types'; + +const INITIAL_STATE: PlanStateProps = { + plans: [], + features: { + aiAssistant: { + hasFeature: false, + isOverLimit: false, + requestsCount: 0, + requestsLimit: 0, + requireUpgrade: false, + errorMessage: '', + errorCode: '', + upgradeType: 'default', + currentTier: { + value: 1, + }, + usagePeriod: { + currentStart: '', + nextStart: '', + requestsCount: 0, + }, + _meta: { + isRequesting: false, + }, + }, + }, +}; + +export default function reducer( state = INITIAL_STATE, action ) { + switch ( action.type ) { + case ACTION_SET_PLANS: + return { + ...state, + plans: action.plans, + }; + + case ACTION_REQUEST_AI_ASSISTANT_FEATURE: + return { + ...state, + features: { + ...state.features, + aiAssistant: { + ...state.features.aiAssistant, + _meta: { + ...state.features.aiAssistant._meta, + isRequesting: true, + }, + }, + }, + }; + + case ACTION_STORE_AI_ASSISTANT_FEATURE: { + return { + ...state, + features: { + ...state.features, + aiAssistant: { + ...action.feature, + _meta: { + ...state.features.aiAssistant._meta, + isRequesting: false, + }, + }, + }, + }; + } + + case ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT: { + return { + ...state, + features: { + ...state.features, + aiAssistant: { + ...state.features.aiAssistant, + requestsCount: state.features.aiAssistant.requestsCount + action.count, + }, + }, + }; + } + } + + return state; +} From ee6116849df21db2342ba1e470aa14f41ee61afe Mon Sep 17 00:00:00 2001 From: Miguel Lezama Date: Wed, 8 Nov 2023 16:43:02 -0300 Subject: [PATCH 03/16] Subscribe Block: Fix regression in the editor (#34023) --- .../changelog/fix-subscribe-block-editor | 4 ++ .../extensions/blocks/subscriptions/edit.js | 48 ++++++++++--------- 2 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/fix-subscribe-block-editor diff --git a/projects/plugins/jetpack/changelog/fix-subscribe-block-editor b/projects/plugins/jetpack/changelog/fix-subscribe-block-editor new file mode 100644 index 0000000000000..56bdd8c76fa6e --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-subscribe-block-editor @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Subscribe Block: Fix display in the editor. diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/edit.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/edit.js index 74ac2f69a9e8c..f4bf97b6c23cc 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/edit.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/edit.js @@ -286,29 +286,31 @@ export function SubscriptionEdit( props ) { ) }
-
-
- - setAttributes( { submitButtonText: value } ) } - style={ buttonStyles } - value={ submitButtonText } - withoutInteractiveFormatting - allowedFormats={ [ 'core/bold', 'core/italic', 'core/strikethrough' ] } - /> +
+
+
+ + setAttributes( { submitButtonText: value } ) } + style={ buttonStyles } + value={ submitButtonText } + withoutInteractiveFormatting + allowedFormats={ [ 'core/bold', 'core/italic', 'core/strikethrough' ] } + /> +
{ showSubscribersTotal && ( From b36bfb68b672ed57117cdef6458221b81cbe664e Mon Sep 17 00:00:00 2001 From: Miguel Lezama Date: Wed, 8 Nov 2023 16:46:43 -0300 Subject: [PATCH 04/16] Subscription Block: Enhance button text and styles. (#33995) --- .../update-subscribe-block-submit-text | 4 ++ .../blocks/subscriptions/subscriptions.php | 55 ++++++++++++++----- 2 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/update-subscribe-block-submit-text diff --git a/projects/plugins/jetpack/changelog/update-subscribe-block-submit-text b/projects/plugins/jetpack/changelog/update-subscribe-block-submit-text new file mode 100644 index 0000000000000..a8a1155850875 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-subscribe-block-submit-text @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +fix to previous PR diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index cf001e0f73acc..157fc69f148ae 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -550,20 +550,20 @@ function render_block( $attributes ) { $styles = get_element_styles_from_attributes( $attributes ); $include_social_followers = isset( $attributes['includeSocialFollowers'] ) ? (bool) get_attribute( $attributes, 'includeSocialFollowers' ) : true; - $is_paid_subscriber = get_attribute( $attributes, 'isPaidSubscriber', false ); $data = array( 'widget_id' => Jetpack_Subscriptions_Widget::$instance_count, 'subscribe_email' => $subscribe_email, - + 'is_paid_subscriber' => get_attribute( $attributes, 'isPaidSubscriber', false ), 'wrapper_attributes' => get_block_wrapper_attributes( array( 'class' => $classes['block_wrapper'], ) ), - 'subscribe_placeholder' => get_attribute( $attributes, 'subscribePlaceholder', esc_html__( 'Type your email…', 'jetpack' ) ), - 'submit_button_text' => get_attribute( $attributes, 'submitButtonText', $is_paid_subscriber ? esc_html__( 'Upgrade', 'jetpack' ) : esc_html__( 'Subscribe', 'jetpack' ) ), - 'submit_button_text_subscribed' => get_attribute( $attributes, 'submitButtonTextSubscribed', esc_html__( 'Subscribed', 'jetpack' ) ), + 'subscribe_placeholder' => get_attribute( $attributes, 'subscribePlaceholder', __( 'Type your email…', 'jetpack' ) ), + 'submit_button_text' => get_attribute( $attributes, 'submitButtonText', __( 'Subscribe', 'jetpack' ) ), + 'submit_button_text_subscribed' => get_attribute( $attributes, 'submitButtonTextSubscribed', __( 'Subscribed', 'jetpack' ) ), + 'submit_button_text_upgrade' => get_attribute( $attributes, 'submitButtonTextUpgrade', __( 'Upgrade subscription', 'jetpack' ) ), 'success_message' => get_attribute( $attributes, 'successMessage', @@ -618,10 +618,7 @@ function render_for_website( $data, $classes, $styles ) { $subscribe_field_id = apply_filters( 'subscribe_field_id', 'subscribe-field' . $widget_id_suffix, $data['widget_id'] ); $tier_id = get_post_meta( $post_id, META_NAME_FOR_POST_TIER_ID_SETTINGS, true ); $is_subscribed = Jetpack_Memberships::is_current_user_subscribed(); - $button_text = wp_kses( - html_entity_decode( $is_subscribed ? ( '✓ ' . $data['submit_button_text_subscribed'] ) : $data['submit_button_text'], ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ), - Jetpack_Subscriptions_Widget::$allowed_html_tags_for_submit_button - ); + $button_text = get_submit_button_text( $data ); ob_start(); @@ -710,7 +707,7 @@ class="" name="jetpack_subscriptions_widget" > - +

@@ -739,17 +736,14 @@ class="" */ function render_for_email( $data, $styles ) { $submit_button_wrapper_style = ! empty( $styles['submit_button_wrapper'] ) ? 'style="' . esc_attr( $styles['submit_button_wrapper'] ) . '"' : ''; - $button_text = wp_kses( - html_entity_decode( $data['submit_button_text'], ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ), - Jetpack_Subscriptions_Widget::$allowed_html_tags_for_submit_button - ); + $button_text = get_submit_button_text( $data ); $html = '
@@ -912,6 +906,37 @@ function get_current_url() { return $current_url; } +/** + * Get the submit button text based on the subscription status. + * + * @param array $data Array containing block view data. + * + * @return string + */ +function get_submit_button_text( $data ) { + if ( ! Jetpack_Memberships::is_current_user_subscribed() ) { + return $data['submit_button_text']; + } + if ( ! Jetpack_Memberships::user_can_view_post() ) { + return $data['submit_button_text_upgrade']; + } + return '✓ ' . $data['submit_button_text_subscribed']; +} + +/** + * Sanitize the submit button text. + * + * @param string $text String containing the submit button text. + * + * @return string + */ +function sanitize_submit_text( $text ) { + return wp_kses( + html_entity_decode( $text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ), + Jetpack_Subscriptions_Widget::$allowed_html_tags_for_submit_button + ); +} + /** * Returns paywall content blocks if user is not authenticated * From b8c2d2f0e564a725d8a365d3c02064015b067f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Wed, 8 Nov 2023 15:53:35 -0600 Subject: [PATCH 05/16] AI Client: ensure dispatching unclear error prompt once per request/response (#34025) * ensure dispatching unclear prompt error once * changelog * Update projects/js-packages/ai-client/src/suggestions-event-source/index.ts Co-authored-by: Douglas Henri * Update projects/js-packages/ai-client/src/suggestions-event-source/index.ts Co-authored-by: Douglas Henri * update camelCase change * bump new version --------- Co-authored-by: Douglas Henri --- ...pdate-ai-client-dispatch-unclear-prompt-once | 4 ++++ projects/js-packages/ai-client/package.json | 2 +- .../src/suggestions-event-source/index.ts | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 projects/js-packages/ai-client/changelog/update-ai-client-dispatch-unclear-prompt-once diff --git a/projects/js-packages/ai-client/changelog/update-ai-client-dispatch-unclear-prompt-once b/projects/js-packages/ai-client/changelog/update-ai-client-dispatch-unclear-prompt-once new file mode 100644 index 0000000000000..b347b4d1605f9 --- /dev/null +++ b/projects/js-packages/ai-client/changelog/update-ai-client-dispatch-unclear-prompt-once @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +AI Client: ensure dispatching unclear error prompt once per request/response diff --git a/projects/js-packages/ai-client/package.json b/projects/js-packages/ai-client/package.json index 9e34ff929c9ff..bdd1d6f62bb61 100644 --- a/projects/js-packages/ai-client/package.json +++ b/projects/js-packages/ai-client/package.json @@ -1,7 +1,7 @@ { "private": false, "name": "@automattic/jetpack-ai-client", - "version": "0.1.14", + "version": "0.1.15-alpha", "description": "A JS client for consuming Jetpack AI services", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/ai-client/#readme", "bugs": { diff --git a/projects/js-packages/ai-client/src/suggestions-event-source/index.ts b/projects/js-packages/ai-client/src/suggestions-event-source/index.ts index a21bed9d997fe..2025203546442 100644 --- a/projects/js-packages/ai-client/src/suggestions-event-source/index.ts +++ b/projects/js-packages/ai-client/src/suggestions-event-source/index.ts @@ -72,6 +72,9 @@ export default class SuggestionsEventSource extends EventTarget { isPromptClear: boolean; controller: AbortController; + // Flag to detect if the unclear prompt event was already dispatched + errorUnclearPromptTriggered: boolean; + constructor( data: SuggestionsEventSourceConstructorArgs ) { super(); this.fullMessage = ''; @@ -157,6 +160,9 @@ export default class SuggestionsEventSource extends EventTarget { bodyData.model = options.model; } + // Clean the unclear prompt trigger flag + this.errorUnclearPromptTriggered = false; + await fetchEventSource( url, { openWhenHidden: true, method: 'POST', @@ -257,8 +263,19 @@ export default class SuggestionsEventSource extends EventTarget { */ const replacedMessage = this.fullMessage.replace( /__|(\*\*)/g, '' ); if ( replacedMessage.startsWith( 'JETPACK_AI_ERROR' ) ) { + /* + * Check if the unclear prompt event was already dispatched, + * to ensure that it is dispatched only once per request. + */ + if ( this.errorUnclearPromptTriggered ) { + return; + } + this.errorUnclearPromptTriggered = true; + // The unclear prompt marker was found, so we dispatch an error event this.dispatchEvent( new CustomEvent( ERROR_UNCLEAR_PROMPT ) ); + debug( 'Unclear error prompt dispatched' ); + this.dispatchEvent( new CustomEvent( ERROR_RESPONSE, { detail: getErrorData( ERROR_UNCLEAR_PROMPT ), From 1fa57e6858143a06bd18c761c984785e6f0f322e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Wed, 8 Nov 2023 16:21:37 -0600 Subject: [PATCH 06/16] AI Assistant: connect useAiFeature() hook with the plans store (#34001) * introdude getIsRequestingAiAssistantFeature select * only expose feature data from selector * polish TS def and usage * comnnect AI Assistant feature hook with the store * clean obsolte code from custom hook * changelog * rename hook with useAiFeature() --- ...pdate-ai-assistant-connect-with-components | 4 ++ .../components/upgrade-prompt/index.tsx | 4 +- .../extensions/blocks/ai-assistant/edit.js | 4 +- .../components/ai-assistant-bar/index.tsx | 4 +- .../hooks/use-ai-feature/Readme.md | 4 +- .../hooks/use-ai-feature/index.ts | 61 ++++--------------- .../ai-assistant-plugin-sidebar/index.tsx | 4 +- .../components/usage-panel/index.tsx | 4 +- .../extensions/store/wordpress-com/index.ts | 24 ++++++-- .../extensions/store/wordpress-com/types.ts | 5 +- 10 files changed, 52 insertions(+), 66 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/update-ai-assistant-connect-with-components diff --git a/projects/plugins/jetpack/changelog/update-ai-assistant-connect-with-components b/projects/plugins/jetpack/changelog/update-ai-assistant-connect-with-components new file mode 100644 index 0000000000000..b3beb9007d6f8 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-ai-assistant-connect-with-components @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +AI Assistant: connect useAiFeature() hook with the plans store diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/upgrade-prompt/index.tsx b/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/upgrade-prompt/index.tsx index b01cbb9f9d598..b09baf1f4bc07 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/upgrade-prompt/index.tsx +++ b/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/upgrade-prompt/index.tsx @@ -9,7 +9,7 @@ import React from 'react'; */ import { Nudge } from '../../../../shared/components/upgrade-nudge'; import useAICheckout from '../../hooks/use-ai-checkout'; -import useAIFeature from '../../hooks/use-ai-feature'; +import useAiFeature from '../../hooks/use-ai-feature'; import { canUserPurchasePlan } from '../../lib/connection'; /** @@ -102,7 +102,7 @@ const VIPUpgradePrompt = (): React.ReactNode => { }; const UpgradePrompt = () => { - const { upgradeType } = useAIFeature(); + const { upgradeType } = useAiFeature(); // If the user is on a VIP site, show the VIP upgrade prompt. if ( upgradeType === 'vip' ) { diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js b/projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js index 6fa8730716448..cf37de32a6429 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js +++ b/projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js @@ -33,7 +33,7 @@ import { promptTemplates } from './components/prompt-templates-control'; import ToolbarControls from './components/toolbar-controls'; import UpgradePrompt from './components/upgrade-prompt'; import { getStoreBlockId } from './extensions/ai-assistant/with-ai-assistant'; -import useAIFeature from './hooks/use-ai-feature'; +import useAiFeature from './hooks/use-ai-feature'; import useSuggestionsFromOpenAI from './hooks/use-suggestions-from-openai'; import { isUserConnected } from './lib/connection'; import { getImagesFromOpenAI } from './lib/image'; @@ -89,7 +89,7 @@ export default function AIAssistantEdit( { attributes, setAttributes, clientId } const isMobileViewport = useViewportMatch( 'medium', '<' ); - const { requireUpgrade: requireUpgradeOnStart, refresh: refreshFeatureData } = useAIFeature(); + const { requireUpgrade: requireUpgradeOnStart, refresh: refreshFeatureData } = useAiFeature(); const requireUpgrade = requireUpgradeOnStart || errorData?.code === 'error_quota_exceeded'; diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/extensions/jetpack-contact-form/components/ai-assistant-bar/index.tsx b/projects/plugins/jetpack/extensions/blocks/ai-assistant/extensions/jetpack-contact-form/components/ai-assistant-bar/index.tsx index 1d1be990813ef..93a4d4fe996c8 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/extensions/jetpack-contact-form/components/ai-assistant-bar/index.tsx +++ b/projects/plugins/jetpack/extensions/blocks/ai-assistant/extensions/jetpack-contact-form/components/ai-assistant-bar/index.tsx @@ -24,7 +24,7 @@ import React from 'react'; */ import ConnectPrompt from '../../../../components/connect-prompt'; import UpgradePrompt from '../../../../components/upgrade-prompt'; -import useAIFeature from '../../../../hooks/use-ai-feature'; +import useAiFeature from '../../../../hooks/use-ai-feature'; import { isUserConnected } from '../../../../lib/connection'; import { PROMPT_TYPE_JETPACK_FORM_CUSTOM_PROMPT, getPrompt } from '../../../../lib/prompt'; import { AiAssistantUiContext } from '../../ui-handler/context'; @@ -96,7 +96,7 @@ export default function AiAssistantBar( { onDone: focusOnPrompt, } ); - const { requireUpgrade } = useAIFeature(); + const { requireUpgrade } = useAiFeature(); const siteRequireUpgrade = requestingError?.code === ERROR_QUOTA_EXCEEDED || requireUpgrade; diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/Readme.md b/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/Readme.md index ef5e87245b461..3465264c2ba5b 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/Readme.md +++ b/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/Readme.md @@ -1,10 +1,10 @@ -# useAIFeature() +# useAiFeature() React custom hook that provides valuable data about AI requests for the site. ```es6 function UpgradePlan() { - const { hasFeature, count, refresh } = useAIFeature(); + const { hasFeature, count, refresh } = useAiFeature(); if ( ! hasFeature ) { return null; } diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/index.ts b/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/index.ts index 0ffc176487fcd..e01870d1fd29a 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/index.ts +++ b/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/index.ts @@ -1,13 +1,8 @@ /** * External dependencies */ -import apiFetch from '@wordpress/api-fetch'; +import { useDispatch, useSelect } from '@wordpress/data'; import { useEffect, useState } from '@wordpress/element'; -/** - * Types & constants - */ -import { AiFeatureProps } from '../../../../store/wordpress-com/types'; -import type { SiteAIAssistantFeatureEndpointResponseProps } from '../../../../types'; const NUM_FREE_REQUESTS_LIMIT = 20; @@ -32,59 +27,29 @@ export const AI_Assistant_Initial_State = { }, }; -export async function getAIFeatures(): Promise< AiFeatureProps > { - const response: SiteAIAssistantFeatureEndpointResponseProps = await apiFetch( { - path: '/wpcom/v2/jetpack-ai/ai-assistant-feature', - } ); +export default function useAiFeature() { + const [ error ] = useState< Error >( null ); - return { - hasFeature: !! response[ 'has-feature' ], - isOverLimit: !! response[ 'is-over-limit' ], - requestsCount: response[ 'requests-count' ], - requestsLimit: response[ 'requests-limit' ], - requireUpgrade: !! response[ 'site-require-upgrade' ], - errorMessage: response[ 'error-message' ], - errorCode: response[ 'error-code' ], - upgradeType: response[ 'upgrade-type' ], - usagePeriod: { - currentStart: response[ 'usage-period' ]?.[ 'current-start' ], - nextStart: response[ 'usage-period' ]?.[ 'next-start' ], - requestsCount: response[ 'usage-period' ]?.[ 'requests-count' ] || 0, - }, - currentTier: { - value: response[ 'current-tier' ]?.value || 1, - }, - }; -} + const { data, loading } = useSelect( select => { + const { getAiAssistantFeature, getIsRequestingAiAssistantFeature } = + select( 'wordpress-com/plans' ); -export default function useAIFeature() { - const [ data, setData ] = useState< AiFeatureProps >( AI_Assistant_Initial_State ); - const [ loading, setLoading ] = useState< boolean >( false ); - const [ error, setError ] = useState< Error >( null ); - - const loadFeatures = async () => { - setLoading( true ); - setError( null ); + return { + data: getAiAssistantFeature(), + loading: getIsRequestingAiAssistantFeature(), + }; + }, [] ); - try { - const aiFeatures = await getAIFeatures(); - setData( aiFeatures ); - } catch ( err ) { - setError( err ); - } finally { - setLoading( false ); - } - }; + const { fetchAiAssistantFeature: loadFeatures } = useDispatch( 'wordpress-com/plans' ); useEffect( () => { loadFeatures(); - }, [] ); + }, [ loadFeatures ] ); return { ...data, loading, error, - setLoading, refresh: loadFeatures, }; } diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/index.tsx b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/index.tsx index 061e9a2c1de1a..d126f56f02f13 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/index.tsx +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/index.tsx @@ -12,7 +12,7 @@ import React from 'react'; * Internal dependencies */ import useAICheckout from '../../../../blocks/ai-assistant/hooks/use-ai-checkout'; -import useAIFeature, { +import useAiFeature, { UpgradeTypeProp, } from '../../../../blocks/ai-assistant/hooks/use-ai-feature'; import JetpackPluginSidebar from '../../../../shared/jetpack-plugin-sidebar'; @@ -66,7 +66,7 @@ const Upgrade = ( { }; export default function AiAssistantPluginSidebar() { - const { requireUpgrade, upgradeType } = useAIFeature(); + const { requireUpgrade, upgradeType } = useAiFeature(); const { autosaveAndRedirect, isRedirecting } = useAICheckout(); const title = __( 'AI Assistant', 'jetpack' ); diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/usage-panel/index.tsx b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/usage-panel/index.tsx index e7c860ee6f779..2943825b001ac 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/usage-panel/index.tsx +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/usage-panel/index.tsx @@ -10,7 +10,7 @@ import React from 'react'; */ import './style.scss'; import useAICheckout from '../../../../blocks/ai-assistant/hooks/use-ai-checkout'; -import useAIFeature from '../../../../blocks/ai-assistant/hooks/use-ai-feature'; +import useAiFeature from '../../../../blocks/ai-assistant/hooks/use-ai-feature'; import { canUserPurchasePlan } from '../../../../blocks/ai-assistant/lib/connection'; import UsageControl from '../usage-bar'; import './style.scss'; @@ -20,7 +20,7 @@ export default function UsagePanel() { const canUpgrade = canUserPurchasePlan(); // fetch usage data - const { hasFeature, requestsCount, requestsLimit, isOverLimit, loading } = useAIFeature(); + const { hasFeature, requestsCount, requestsLimit, isOverLimit, loading } = useAiFeature(); return (
diff --git a/projects/plugins/jetpack/extensions/store/wordpress-com/index.ts b/projects/plugins/jetpack/extensions/store/wordpress-com/index.ts index f737bf19446e4..803ff783f2522 100644 --- a/projects/plugins/jetpack/extensions/store/wordpress-com/index.ts +++ b/projects/plugins/jetpack/extensions/store/wordpress-com/index.ts @@ -10,7 +10,7 @@ import reducer from './reducer'; /** * Types */ -import type { PlanStateProps } from './types'; +import type { AiFeatureProps, PlanStateProps } from './types'; const store = 'wordpress-com/plans'; @@ -36,11 +36,25 @@ const wordpressPlansStore = createReduxStore( store, { /** * Return the AI Assistant feature. * - * @param {object} state - The Plans state tree. - * @returns {object} The AI Assistant feature data. + * @param {PlanStateProps} state - The Plans state tree. + * @returns {AiFeatureProps} The AI Assistant feature data. */ - getAiAssistantFeature( state: PlanStateProps ): object { - return state.features.aiAssistant; + getAiAssistantFeature( state: PlanStateProps ): AiFeatureProps { + // Clean up the _meta property. + const data = { ...state.features.aiAssistant }; + delete data._meta; + + return data; + }, + + /** + * Get the isRequesting flag for the AI Assistant feature. + * + * @param {PlanStateProps} state - The Plans state tree. + * @returns {boolean} The isRequesting flag. + */ + getIsRequestingAiAssistantFeature( state: PlanStateProps ): boolean { + return state.features.aiAssistant?._meta?.isRequesting; }, }, diff --git a/projects/plugins/jetpack/extensions/store/wordpress-com/types.ts b/projects/plugins/jetpack/extensions/store/wordpress-com/types.ts index 39f6aa8ad8033..06a43531a3558 100644 --- a/projects/plugins/jetpack/extensions/store/wordpress-com/types.ts +++ b/projects/plugins/jetpack/extensions/store/wordpress-com/types.ts @@ -7,7 +7,7 @@ export type Plan = { export type PlanStateProps = { plans: Array< Plan >; features: { - aiAssistant?: AiFeatureProps; + aiAssistant?: AiFeatureStateProps; }; }; @@ -31,6 +31,9 @@ export type AiFeatureProps = { nextStart: string; requestsCount: number; }; +}; + +export type AiFeatureStateProps = AiFeatureProps & { _meta?: { isRequesting: boolean; }; From e1fc8e4ae96730b2e0f0022471332d303e5706f4 Mon Sep 17 00:00:00 2001 From: Eru Penkman Date: Thu, 9 Nov 2023 11:16:02 +1000 Subject: [PATCH 07/16] Add/blogging-prompts: Add bloganuary field (#33852) --- ...-rest-api-v3-endpoint-blogging-prompts.php | 33 +++++++++++++++++++ .../add-blogging-prompts-bloganuary-field | 4 +++ 2 files changed, 37 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/add-blogging-prompts-bloganuary-field diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v3-endpoint-blogging-prompts.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v3-endpoint-blogging-prompts.php index ae3f154882bae..f30b77419a0b5 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v3-endpoint-blogging-prompts.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v3-endpoint-blogging-prompts.php @@ -306,9 +306,38 @@ public function prepare_item_for_response( $prompt, $request ) { $data['answered_link_text'] = __( 'View all responses', 'jetpack' ); } + if ( $this->is_in_bloganuary( $prompt->post_date_gmt ) && rest_is_field_included( 'bloganuary_id', $fields ) ) { + $data['bloganuary_id'] = $this->get_bloganuary_id( $prompt->post_date_gmt ); + } + return $data; } + /** + * Return true if the post is in "Bloganuary" + * + * @param string $post_date_gmt Post date in GMT. + * @return bool True if the post is in "Bloganuary". + */ + protected function is_in_bloganuary( $post_date_gmt ) { + $post_month = gmdate( 'm', strtotime( $post_date_gmt ) ); + return $post_month === '01'; + } + + /** + * Return the bloganuary id of the form `bloganuary-yyyy-dd` + * + * @param string $post_date_gmt Post date in GMT. + * @return string Bloganuary id. + */ + protected function get_bloganuary_id( $post_date_gmt ) { + $post_year_day = gmdate( 'Y-d', strtotime( $post_date_gmt ) ); + if ( $this->force_year ) { + $post_year_day = $this->force_year . '-' . gmdate( 'd', strtotime( $post_date_gmt ) ); + } + return 'bloganuary-' . $post_year_day; + } + /** * Format a date for a blogging prompt, omiting the time. * @@ -444,6 +473,10 @@ public function get_item_schema() { 'description' => __( 'Text for the link to answers for the prompt.', 'jetpack' ), 'type' => 'string', ), + 'bloganuary_id' => array( + 'description' => __( 'Id used by the bloganuary promotion', 'jetpack' ), + 'type' => 'string', + ), ), ); } diff --git a/projects/plugins/jetpack/changelog/add-blogging-prompts-bloganuary-field b/projects/plugins/jetpack/changelog/add-blogging-prompts-bloganuary-field new file mode 100644 index 0000000000000..62902a357556b --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-blogging-prompts-bloganuary-field @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Add bloganuary date field to blogging prompts api. This field will be used for the bloganuary promotion. From d9c1f3b34f1c84b09967dfedc59f059098516f4e Mon Sep 17 00:00:00 2001 From: Peter Petrov Date: Thu, 9 Nov 2023 12:16:30 +0200 Subject: [PATCH 08/16] JS Components: Fix react warnings in Boost Score Graph (#34014) --- .../changelog/fix-boost-score-graph-warnings | 4 + .../boost-score-graph/background.tsx | 80 +++++++++---------- projects/js-packages/components/package.json | 2 +- 3 files changed, 45 insertions(+), 41 deletions(-) create mode 100644 projects/js-packages/components/changelog/fix-boost-score-graph-warnings diff --git a/projects/js-packages/components/changelog/fix-boost-score-graph-warnings b/projects/js-packages/components/changelog/fix-boost-score-graph-warnings new file mode 100644 index 0000000000000..f295af6e72646 --- /dev/null +++ b/projects/js-packages/components/changelog/fix-boost-score-graph-warnings @@ -0,0 +1,4 @@ +Significance: minor +Type: fixed + +Fix react warnings in Boost Score Graph. diff --git a/projects/js-packages/components/components/boost-score-graph/background.tsx b/projects/js-packages/components/components/boost-score-graph/background.tsx index 070b4a4e13ac0..ada7cfdc8a61b 100644 --- a/projects/js-packages/components/components/boost-score-graph/background.tsx +++ b/projects/js-packages/components/components/boost-score-graph/background.tsx @@ -96,23 +96,23 @@ export const Background: FunctionComponent = () => { - - - - - - - - - - - - - + strokeWidth="2" + strokeLinecap="round" + strokeLinejoin="round" + /> + + + + + + + + + + + + + { - - - - - - - - - - - - - + strokeWidth="2" + strokeLinecap="round" + strokeLinejoin="round" + /> + + + + + + + + + + + + + { width="1185.3" height="239.127" filterUnits="userSpaceOnUse" - color-interpolation-filters="sRGB" + colorInterpolationFilters="sRGB" > - + @@ -161,8 +161,8 @@ export const Background: FunctionComponent = () => { y2="199" gradientUnits="userSpaceOnUse" > - - + + { y2="220.999" gradientUnits="userSpaceOnUse" > - - + + diff --git a/projects/js-packages/components/package.json b/projects/js-packages/components/package.json index bed5d1ff222cf..7d77dcd172dc2 100644 --- a/projects/js-packages/components/package.json +++ b/projects/js-packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@automattic/jetpack-components", - "version": "0.44.4", + "version": "0.45.0-alpha", "description": "Jetpack Components Package", "author": "Automattic", "license": "GPL-2.0-or-later", From b780fda17e848cc10f31dd6dd6f62c33a25b899b Mon Sep 17 00:00:00 2001 From: Tim Broddin Date: Thu, 9 Nov 2023 11:26:29 +0100 Subject: [PATCH 09/16] Fixed subscribe block redirect issue on non-post pages (#33932) * Fixed subscribe block redirect issue on non-post pages * Bind showing of subscribe modal to all `.wp-block-jetpack-subscriptions__container form` --- .../fix-subscribe-form-redirect-to-post-bug | 4 ++ .../blocks/subscriptions/subscriptions.php | 19 ++++-- .../extensions/blocks/subscriptions/view.js | 67 +++++++++---------- 3 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/fix-subscribe-form-redirect-to-post-bug diff --git a/projects/plugins/jetpack/changelog/fix-subscribe-form-redirect-to-post-bug b/projects/plugins/jetpack/changelog/fix-subscribe-form-redirect-to-post-bug new file mode 100644 index 0000000000000..d394aa3a79bcd --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-subscribe-form-redirect-to-post-bug @@ -0,0 +1,4 @@ +Significance: minor +Type: bugfix + +Subscribe block: only redirect to post when inside a post context diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index 157fc69f148ae..de3db8fe910e4 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -609,12 +609,19 @@ function get_post_access_level_for_current_post() { * @return string */ function render_for_website( $data, $classes, $styles ) { - $blog_id = \Jetpack_Options::get_option( 'id' ); - $widget_id_suffix = Jetpack_Subscriptions_Widget::$instance_count > 1 ? '-' . Jetpack_Subscriptions_Widget::$instance_count : ''; - $form_id = 'subscribe-blog' . $widget_id_suffix; - $form_url = defined( 'SUBSCRIBE_BLOG_URL' ) ? SUBSCRIBE_BLOG_URL : '#'; - $post_access_level = get_post_access_level_for_current_post(); - $post_id = get_the_ID(); + $blog_id = \Jetpack_Options::get_option( 'id' ); + $widget_id_suffix = Jetpack_Subscriptions_Widget::$instance_count > 1 ? '-' . Jetpack_Subscriptions_Widget::$instance_count : ''; + $form_id = 'subscribe-blog' . $widget_id_suffix; + $form_url = defined( 'SUBSCRIBE_BLOG_URL' ) ? SUBSCRIBE_BLOG_URL : '#'; + $post_access_level = get_post_access_level_for_current_post(); + + $post_id = null; + if ( in_the_loop() ) { + $post_id = get_the_ID(); + } elseif ( is_singular( 'post' ) ) { + $post_id = get_queried_object_id(); + } + $subscribe_field_id = apply_filters( 'subscribe_field_id', 'subscribe-field' . $widget_id_suffix, $data['widget_id'] ); $tier_id = get_post_meta( $post_id, META_NAME_FOR_POST_TIER_ID_SETTINGS, true ); $is_subscribed = Jetpack_Memberships::is_current_user_subscribed(); diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/view.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/view.js index b6e80738215c9..a37535a0d3081 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/view.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/view.js @@ -55,39 +55,38 @@ domReady( function () { } ); } - const form = document.querySelector( '.wp-block-jetpack-subscriptions__container form' ); - if ( ! form ) { - return; - } - if ( ! form.payments_attached ) { - form.payments_attached = true; - form.addEventListener( 'submit', function ( event ) { - if ( form.resubmitted ) { - return; - } - - const emailInput = form.querySelector( 'input[type=email]' ); - const email = emailInput ? emailInput.value : form.dataset.subscriber_email; - - if ( ! email ) { - return; - } - - event.preventDefault(); - - const post_id = form.querySelector( 'input[name=post_id]' )?.value ?? ''; - const tier_id = form.querySelector( 'input[name=tier_id]' )?.value ?? ''; - - show_iframe( { - email, - post_id, - tier_id, - blog: form.dataset.blog, - plan: 'newsletter', - source: 'jetpack_subscribe', - post_access_level: form.dataset.post_access_level, - display: 'alternate', + const forms = document.querySelectorAll( '.wp-block-jetpack-subscriptions__container form' ); + forms.forEach( form => { + if ( ! form.payments_attached ) { + form.payments_attached = true; + form.addEventListener( 'submit', function ( event ) { + if ( form.resubmitted ) { + return; + } + + const emailInput = form.querySelector( 'input[type=email]' ); + const email = emailInput ? emailInput.value : form.dataset.subscriber_email; + + if ( ! email ) { + return; + } + + event.preventDefault(); + + const post_id = form.querySelector( 'input[name=post_id]' )?.value ?? ''; + const tier_id = form.querySelector( 'input[name=tier_id]' )?.value ?? ''; + + show_iframe( { + email, + post_id, + tier_id, + blog: form.dataset.blog, + plan: 'newsletter', + source: 'jetpack_subscribe', + post_access_level: form.dataset.post_access_level, + display: 'alternate', + } ); } ); - } ); - } + } + } ); } ); From bd5a24d3080983ea2c6a0e43d1ae427c58939999 Mon Sep 17 00:00:00 2001 From: Tim Broddin Date: Thu, 9 Nov 2023 11:48:18 +0100 Subject: [PATCH 10/16] Release jetpack-mu-wpcom 4.18.0 --- projects/packages/jetpack-mu-wpcom/CHANGELOG.md | 5 +++++ .../changelog/add-launchpad_is_task_complete_id_map | 4 ---- .../packages/jetpack-mu-wpcom/changelog/fix-version-bumps | 5 ----- .../changelog/update-docker-php-memory-limit | 5 ----- 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 | 2 ++ projects/plugins/mu-wpcom-plugin/changelog/fix-version-bumps | 5 ----- .../mu-wpcom-plugin/changelog/update-docker-php-memory-limit | 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 +- 12 files changed, 12 insertions(+), 29 deletions(-) delete mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-launchpad_is_task_complete_id_map delete mode 100644 projects/packages/jetpack-mu-wpcom/changelog/fix-version-bumps delete mode 100644 projects/packages/jetpack-mu-wpcom/changelog/update-docker-php-memory-limit delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/fix-version-bumps delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/update-docker-php-memory-limit diff --git a/projects/packages/jetpack-mu-wpcom/CHANGELOG.md b/projects/packages/jetpack-mu-wpcom/CHANGELOG.md index e23ee6002ad02..dc3633fac7739 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). +## [4.18.0] - 2023-11-09 +### Added +- Take id_map in consideration when checking if a task is completed inside wpcom_launchpad_is_task_option_completed. [#34009] + ## [4.17.0] - 2023-11-08 ### Added - Added Launchpad tasks and task list to the Subscriber page. [#33948] @@ -425,6 +429,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Testing initial package release. +[4.18.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.17.0...v4.18.0 [4.17.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.2...v4.17.0 [4.16.2]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.1...v4.16.2 [4.16.1]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v4.16.0...v4.16.1 diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-launchpad_is_task_complete_id_map b/projects/packages/jetpack-mu-wpcom/changelog/add-launchpad_is_task_complete_id_map deleted file mode 100644 index 48e24905947de..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/changelog/add-launchpad_is_task_complete_id_map +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: added - -Take id_map in consideration when checking if a task is completed inside wpcom_launchpad_is_task_option_completed. diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-version-bumps b/projects/packages/jetpack-mu-wpcom/changelog/fix-version-bumps deleted file mode 100644 index 8864676d95ebb..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/changelog/fix-version-bumps +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: fixed -Comment: Version bumps - - diff --git a/projects/packages/jetpack-mu-wpcom/changelog/update-docker-php-memory-limit b/projects/packages/jetpack-mu-wpcom/changelog/update-docker-php-memory-limit deleted file mode 100644 index fe7e3acc72374..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/changelog/update-docker-php-memory-limit +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Bump version - - diff --git a/projects/packages/jetpack-mu-wpcom/package.json b/projects/packages/jetpack-mu-wpcom/package.json index 7a1df3b78e555..0d82e43e81529 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": "4.18.0-alpha", + "version": "4.18.0", "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 04bab4366a745..2ad2e9ba7e424 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 @@ -14,7 +14,7 @@ */ class Jetpack_Mu_Wpcom { - const PACKAGE_VERSION = '4.18.0-alpha'; + const PACKAGE_VERSION = '4.18.0'; const PKG_DIR = __DIR__ . '/../'; /** diff --git a/projects/plugins/mu-wpcom-plugin/CHANGELOG.md b/projects/plugins/mu-wpcom-plugin/CHANGELOG.md index 786341904fd57..9c185f542dd65 100644 --- a/projects/plugins/mu-wpcom-plugin/CHANGELOG.md +++ b/projects/plugins/mu-wpcom-plugin/CHANGELOG.md @@ -5,6 +5,8 @@ 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). +## 1.7.9 - 2023-11-09 + ## 1.7.8 - 2023-11-08 ## 1.7.7 - 2023-11-03 diff --git a/projects/plugins/mu-wpcom-plugin/changelog/fix-version-bumps b/projects/plugins/mu-wpcom-plugin/changelog/fix-version-bumps deleted file mode 100644 index 8864676d95ebb..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/fix-version-bumps +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: fixed -Comment: Version bumps - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/update-docker-php-memory-limit b/projects/plugins/mu-wpcom-plugin/changelog/update-docker-php-memory-limit deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/update-docker-php-memory-limit +++ /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 4ab2faf25f054..c1aa37183314e 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ⓥ1_7_9_alpha" + "autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ1_7_9" } } diff --git a/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php b/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php index 503964ab71163..a407639332d28 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: 1.7.9-alpha + * Version: 1.7.9 * 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 1410b1ec63422..f3ac3cfaae138 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": "1.7.9-alpha", + "version": "1.7.9", "description": "Test plugin for the jetpack-mu-wpcom package", "homepage": "https://jetpack.com", "bugs": { From 0cdc4131c3c01ac1d0f56803d23652ed3fc43e7f Mon Sep 17 00:00:00 2001 From: Peter Petrov Date: Thu, 9 Nov 2023 13:13:56 +0200 Subject: [PATCH 11/16] Boost: Migrate svelte components to react (#33886) --- pnpm-lock.yaml | 3 + .../boost/app/assets/src/css/admin-style.scss | 2 - .../src/css/components/icon-tooltip.scss | 24 ----- .../app/assets/src/css/components/score.scss | 4 +- .../assets/src/css/components/support.scss | 13 --- .../src/js/elements/ActivateLicense.svelte | 37 -------- .../js/elements/ImageCDNRecommendation.svelte | 28 ------ .../src/js/elements/OtherGroupContext.svelte | 33 ------- .../js/elements/RecommendationContext.svelte | 32 ------- .../image-size-analysis/MultiProgress.svelte | 7 +- .../RecommendationsMeta.svelte | 5 +- .../RecommendationsPage.svelte | 6 +- .../recommendations/Hero.svelte | 64 ------------- .../benefits/BenefitsInterstitial.svelte | 6 +- .../getting-started/GettingStarted.svelte | 4 +- .../src/js/pages/settings/Settings.svelte | 5 +- .../settings/elements/ScoreContext.svelte | 44 --------- .../sections/AdvancedCriticalCss.svelte | 2 +- .../js/pages/settings/sections/Modules.svelte | 2 +- .../js/pages/settings/sections/Score.svelte | 8 +- .../js/pages/settings/sections/Support.svelte | 31 ------ .../components/activate-license/index.tsx | 24 +++++ .../activate-license/styles.module.scss | 12 +++ .../back-button/index.tsx} | 0 .../image-cdn-recommendation/index.tsx | 28 ++++++ .../styles.module.scss | 7 ++ .../components/isa-hero/index.tsx | 95 +++++++++++++++++++ .../components/isa-hero/styles.module.scss | 29 ++++++ .../isa-other-group-context/index.tsx | 29 ++++++ .../styles.module.scss | 11 +++ .../minify-meta/index.tsx} | 2 +- .../sections/score/context-tooltip/index.tsx | 57 +++++++++++ .../score/context-tooltip/styles.module.scss | 22 +++++ .../sections/support/index.tsx | 34 +++++++ .../sections/support/styles.module.scss | 13 +++ .../app/assets/src/js/sections/Header.svelte | 2 +- .../changelog/boost-react-migrate-components | 4 + .../boost-react-migrate-components#2 | 5 + projects/plugins/boost/composer.json | 4 +- projects/plugins/boost/composer.lock | 2 +- projects/plugins/boost/jetpack-boost.php | 4 +- projects/plugins/boost/package.json | 3 +- .../lib/pages/wp-admin/JetpackBoostPage.js | 2 +- .../e2e/specs/modules/speed-score.test.js | 4 +- 44 files changed, 414 insertions(+), 339 deletions(-) delete mode 100644 projects/plugins/boost/app/assets/src/css/components/icon-tooltip.scss delete mode 100644 projects/plugins/boost/app/assets/src/css/components/support.scss delete mode 100644 projects/plugins/boost/app/assets/src/js/elements/ActivateLicense.svelte delete mode 100644 projects/plugins/boost/app/assets/src/js/elements/ImageCDNRecommendation.svelte delete mode 100644 projects/plugins/boost/app/assets/src/js/elements/OtherGroupContext.svelte delete mode 100644 projects/plugins/boost/app/assets/src/js/elements/RecommendationContext.svelte delete mode 100644 projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/Hero.svelte delete mode 100644 projects/plugins/boost/app/assets/src/js/pages/settings/elements/ScoreContext.svelte delete mode 100644 projects/plugins/boost/app/assets/src/js/pages/settings/sections/Support.svelte create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/components/activate-license/index.tsx create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/components/activate-license/styles.module.scss rename projects/plugins/boost/app/assets/src/js/react-components/{common/back-button/BackButton.tsx => components/back-button/index.tsx} (100%) create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/components/image-cdn-recommendation/index.tsx create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/components/image-cdn-recommendation/styles.module.scss create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/components/isa-hero/index.tsx create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/components/isa-hero/styles.module.scss create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/components/isa-other-group-context/index.tsx create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/components/isa-other-group-context/styles.module.scss rename projects/plugins/boost/app/assets/src/js/react-components/{pages/settings/elements/MinifyMeta.tsx => components/minify-meta/index.tsx} (96%) create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/sections/score/context-tooltip/index.tsx create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/sections/score/context-tooltip/styles.module.scss create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/sections/support/index.tsx create mode 100644 projects/plugins/boost/app/assets/src/js/react-components/sections/support/styles.module.scss create mode 100644 projects/plugins/boost/changelog/boost-react-migrate-components create mode 100644 projects/plugins/boost/changelog/boost-react-migrate-components#2 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38189fb4b6df2..1c8b55a212544 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2595,6 +2595,9 @@ importers: '@wordpress/element': specifier: 5.21.0 version: 5.21.0 + classnames: + specifier: 2.3.2 + version: 2.3.2 history: specifier: 5.3.0 version: 5.3.0 diff --git a/projects/plugins/boost/app/assets/src/css/admin-style.scss b/projects/plugins/boost/app/assets/src/css/admin-style.scss index a6f66b83e6e58..15306299468be 100644 --- a/projects/plugins/boost/app/assets/src/css/admin-style.scss +++ b/projects/plugins/boost/app/assets/src/css/admin-style.scss @@ -21,9 +21,7 @@ @import 'components/checklist'; @import 'components/icons'; @import 'components/badge'; -@import 'components/support'; @import 'components/snackbar'; -@import 'components/icon-tooltip'; @import 'components/pricing-table.scss'; // React Migration CSS diff --git a/projects/plugins/boost/app/assets/src/css/components/icon-tooltip.scss b/projects/plugins/boost/app/assets/src/css/components/icon-tooltip.scss deleted file mode 100644 index 11e03a8238130..0000000000000 --- a/projects/plugins/boost/app/assets/src/css/components/icon-tooltip.scss +++ /dev/null @@ -1,24 +0,0 @@ -.icon-tooltip-wrapper.wide-tooltip { - // Widen tooltips marked as "wide". - .icon-tooltip-helper .components-popover__content { - width: 440px; - } - - // Allow bulleted lists in wide tooltips. - ul { - margin: 0 0 0 30px; - list-style-type: disc; - } - - // Remove bottom margin from last list item. - ul li:last-child { - margin-bottom: 0; - } -} - -// Narrow down tooltips that are not marked as "wide". -.icon-tooltip-wrapper:not( .wide-tooltip ) { - .icon-tooltip-helper .components-popover__content { - width: 250px; - } -} diff --git a/projects/plugins/boost/app/assets/src/css/components/score.scss b/projects/plugins/boost/app/assets/src/css/components/score.scss index 89a515289eb1a..34b72445a387e 100644 --- a/projects/plugins/boost/app/assets/src/css/components/score.scss +++ b/projects/plugins/boost/app/assets/src/css/components/score.scss @@ -39,7 +39,7 @@ $no_boost_score_size: 28px; } } - button { + .action-button { color: $gray_90; &.components-button.is-link { @@ -156,7 +156,7 @@ $no_boost_score_size: 28px; height:12px; transform:translate(-50%,50%) rotate(45deg); background-color:$primary-white; - + @include box-shadow(); } } diff --git a/projects/plugins/boost/app/assets/src/css/components/support.scss b/projects/plugins/boost/app/assets/src/css/components/support.scss deleted file mode 100644 index b6fae96b9f322..0000000000000 --- a/projects/plugins/boost/app/assets/src/css/components/support.scss +++ /dev/null @@ -1,13 +0,0 @@ -.jb-support { - display: grid; - grid-template-columns: auto auto; - align-items: center; - - & &__title { - margin-bottom: $halfling; - } - - &__cta { - text-align: right; - } -} diff --git a/projects/plugins/boost/app/assets/src/js/elements/ActivateLicense.svelte b/projects/plugins/boost/app/assets/src/js/elements/ActivateLicense.svelte deleted file mode 100644 index b601cc9b0de85..0000000000000 --- a/projects/plugins/boost/app/assets/src/js/elements/ActivateLicense.svelte +++ /dev/null @@ -1,37 +0,0 @@ - - -

- Click here to get started', - 'jetpack-boost' - )} - vars={{ - link: [ - 'a', - { - class: 'jb-activate-license__link', - href: 'admin.php?page=my-jetpack#/add-license', - }, - ], - }} - /> -

- - diff --git a/projects/plugins/boost/app/assets/src/js/elements/ImageCDNRecommendation.svelte b/projects/plugins/boost/app/assets/src/js/elements/ImageCDNRecommendation.svelte deleted file mode 100644 index 2702c1d931ef4..0000000000000 --- a/projects/plugins/boost/app/assets/src/js/elements/ImageCDNRecommendation.svelte +++ /dev/null @@ -1,28 +0,0 @@ - - -

- Image CDN.', 'jetpack-boost' )} - /> -

-

- - {__( - "Jetpack Boost's Image CDN can automatically resize many images to the correct size for you.", - 'jetpack-boost' - )} - -

- - diff --git a/projects/plugins/boost/app/assets/src/js/elements/OtherGroupContext.svelte b/projects/plugins/boost/app/assets/src/js/elements/OtherGroupContext.svelte deleted file mode 100644 index 476ec24087ff2..0000000000000 --- a/projects/plugins/boost/app/assets/src/js/elements/OtherGroupContext.svelte +++ /dev/null @@ -1,33 +0,0 @@ - - -
- i -
-

- {__( - 'In addition to the Homepage, Pages and Posts, Boost will also analyze the following custom post types found on your site:', - 'jetpack-boost' - )} -

-
    - - {#each Object.entries( Jetpack_Boost.site.postTypes ) as [slug, label]} -
  • {label}
  • - {/each} -
- -
-
- - diff --git a/projects/plugins/boost/app/assets/src/js/elements/RecommendationContext.svelte b/projects/plugins/boost/app/assets/src/js/elements/RecommendationContext.svelte deleted file mode 100644 index d24e87793050e..0000000000000 --- a/projects/plugins/boost/app/assets/src/js/elements/RecommendationContext.svelte +++ /dev/null @@ -1,32 +0,0 @@ - - -
- i -
- - -
-
- - diff --git a/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/MultiProgress.svelte b/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/MultiProgress.svelte index 14f809295c348..e5fef55de66eb 100644 --- a/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/MultiProgress.svelte +++ b/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/MultiProgress.svelte @@ -1,12 +1,15 @@ - -{#if hasActiveGroup && isaLastUpdated} - {@const ( lastUpdated = formatter.format( isaLastUpdated ) )} - -
- Latest report as of {lastUpdated} - {#if totalIssueCount} -

- {sprintf( - /* translators: %d: number of image recommendations */ - _n( - '%d Image Recommendation', - '%d Image Recommendations', - totalIssueCount, - 'jetpack-boost' - ), - totalIssueCount - )} - - {#if ! isImageCdnModuleActive && totalIssueCount > 0} - - {/if} -

- {/if} - - {#if needsRefresh} - Refresh to see the latest recommendations.', - 'jetpack-boost' - )} - vars={actionLinkTemplateVar( () => refresh(), 'refresh' )} - /> - {/if} -
-{:else} -
-   -

 

-
-{/if} diff --git a/projects/plugins/boost/app/assets/src/js/pages/benefits/BenefitsInterstitial.svelte b/projects/plugins/boost/app/assets/src/js/pages/benefits/BenefitsInterstitial.svelte index 7a54f29b5d5a8..4886ce7fe569a 100644 --- a/projects/plugins/boost/app/assets/src/js/pages/benefits/BenefitsInterstitial.svelte +++ b/projects/plugins/boost/app/assets/src/js/pages/benefits/BenefitsInterstitial.svelte @@ -1,9 +1,9 @@ - -
- i -
-

- {__( - "Your Overall Score is a summary of your website performance across both mobile and desktop devices. It gives a general idea of your sites' overall performance.", - 'jetpack-boost' - )} -

- - - - - - - - - - - - - -
A90+
B75 - 90
C50 - 75
- - - - - - - - - - - - - -
D35 - 50
E25 - 35
F0 - 25
- -
-
diff --git a/projects/plugins/boost/app/assets/src/js/pages/settings/sections/AdvancedCriticalCss.svelte b/projects/plugins/boost/app/assets/src/js/pages/settings/sections/AdvancedCriticalCss.svelte index a4e9d2fcd9494..697c3efc58a9b 100644 --- a/projects/plugins/boost/app/assets/src/js/pages/settings/sections/AdvancedCriticalCss.svelte +++ b/projects/plugins/boost/app/assets/src/js/pages/settings/sections/AdvancedCriticalCss.svelte @@ -3,7 +3,7 @@ import { __, _n, sprintf } from '@wordpress/i18n'; import CloseButton from '../../../elements/CloseButton.svelte'; import ReactComponent from '../../../elements/ReactComponent.svelte'; - import BackButton from '../../../react-components/common/back-button/BackButton'; + import BackButton from '../../../react-components/components/back-button'; import { replaceCssState, updateProvider } from '../../../stores/critical-css-state'; import { groupErrorsByFrequency } from '../../../stores/critical-css-state-errors'; import { type Provider } from '../../../stores/critical-css-state-types'; diff --git a/projects/plugins/boost/app/assets/src/js/pages/settings/sections/Modules.svelte b/projects/plugins/boost/app/assets/src/js/pages/settings/sections/Modules.svelte index fb25fe858e137..ae941c5ed6d72 100644 --- a/projects/plugins/boost/app/assets/src/js/pages/settings/sections/Modules.svelte +++ b/projects/plugins/boost/app/assets/src/js/pages/settings/sections/Modules.svelte @@ -15,7 +15,7 @@ isaSummary, } from '../../../modules/image-size-analysis/store/isa-summary'; import { RegenerateCriticalCssSuggestion } from '../../../react-components/RegenerateCriticalCssSuggestion'; - import MinifyMeta from '../../../react-components/pages/settings/elements/MinifyMeta'; + import MinifyMeta from '../../../react-components/components/minify-meta'; import config from '../../../stores/config'; import { criticalCssState, diff --git a/projects/plugins/boost/app/assets/src/js/pages/settings/sections/Score.svelte b/projects/plugins/boost/app/assets/src/js/pages/settings/sections/Score.svelte index 6179c83fba0af..dfd3179ac1dae 100644 --- a/projects/plugins/boost/app/assets/src/js/pages/settings/sections/Score.svelte +++ b/projects/plugins/boost/app/assets/src/js/pages/settings/sections/Score.svelte @@ -9,6 +9,7 @@ import { scoreChangeModal, ScoreChangeMessage } from '../../../api/speed-scores'; import ErrorNotice from '../../../elements/ErrorNotice.svelte'; import ReactComponent from '../../../elements/ReactComponent.svelte'; + import ContextTooltip from '../../../react-components/sections/score/context-tooltip'; import { performanceHistoryPanelDS } from '../../../stores/data-sync-client'; import { dismissedAlerts } from '../../../stores/dismissed-alerts'; import { modulesState } from '../../../stores/modules'; @@ -18,9 +19,10 @@ import { castToString } from '../../../utils/cast-to-string'; import debounce from '../../../utils/debounce'; import PopOut from '../elements/PopOut.svelte'; - import ScoreContext from '../elements/ScoreContext.svelte'; import History from './History.svelte'; + // @todo - move score-context markup/styles here, as it's not used anywhere else. + // Flat list of which modules are active; useful for tracking changes in state. export let activeModules: boolean[]; export let criticalCssCreated: number; @@ -145,11 +147,11 @@ {/if} {#if ! isLoading && ! loadError} - + {/if} -
-
-
-
diff --git a/projects/plugins/boost/app/assets/src/js/react-components/components/activate-license/index.tsx b/projects/plugins/boost/app/assets/src/js/react-components/components/activate-license/index.tsx new file mode 100644 index 0000000000000..822652b17fa80 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/activate-license/index.tsx @@ -0,0 +1,24 @@ +import { createInterpolateElement } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; +import styles from './styles.module.scss'; + +const ActivateLicense = () => { + const activateLicenseUrl = 'admin.php?page=my-jetpack#/add-license'; + + return ( +

+ { createInterpolateElement( + __( + 'Already have an existing plan or license key? Click here to get started', + 'jetpack-boost' + ), + { + // eslint-disable-next-line jsx-a11y/anchor-has-content + link: , + } + ) } +

+ ); +}; + +export default ActivateLicense; diff --git a/projects/plugins/boost/app/assets/src/js/react-components/components/activate-license/styles.module.scss b/projects/plugins/boost/app/assets/src/js/react-components/components/activate-license/styles.module.scss new file mode 100644 index 0000000000000..4f3f5159d9cb6 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/activate-license/styles.module.scss @@ -0,0 +1,12 @@ +.activate-license { + font-size: 13px; +} + +.link { + color: var( --blue-50 ) !important; + + &:hover, + &:active { + color: var( --blue-60 ) !important; + } +} diff --git a/projects/plugins/boost/app/assets/src/js/react-components/common/back-button/BackButton.tsx b/projects/plugins/boost/app/assets/src/js/react-components/components/back-button/index.tsx similarity index 100% rename from projects/plugins/boost/app/assets/src/js/react-components/common/back-button/BackButton.tsx rename to projects/plugins/boost/app/assets/src/js/react-components/components/back-button/index.tsx diff --git a/projects/plugins/boost/app/assets/src/js/react-components/components/image-cdn-recommendation/index.tsx b/projects/plugins/boost/app/assets/src/js/react-components/components/image-cdn-recommendation/index.tsx new file mode 100644 index 0000000000000..01d14ec5bba07 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/image-cdn-recommendation/index.tsx @@ -0,0 +1,28 @@ +import { createInterpolateElement } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; +import styles from './styles.module.scss'; + +const ImageCdnRecommendation = () => { + return ( + <> +

+ { createInterpolateElement( + __( 'We recommend enabling the Image CDN.', 'jetpack-boost' ), + { + b: , + } + ) } +

+

+ + { __( + "Jetpack Boost's Image CDN can automatically resize many images to the correct size for you.", + 'jetpack-boost' + ) } + +

+ + ); +}; + +export default ImageCdnRecommendation; diff --git a/projects/plugins/boost/app/assets/src/js/react-components/components/image-cdn-recommendation/styles.module.scss b/projects/plugins/boost/app/assets/src/js/react-components/components/image-cdn-recommendation/styles.module.scss new file mode 100644 index 0000000000000..cfc5025c9d125 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/image-cdn-recommendation/styles.module.scss @@ -0,0 +1,7 @@ +.paragraph { + margin-top: 0 !important; +} + +.paragraph:last-of-type { + margin-bottom: 0 !important; +} diff --git a/projects/plugins/boost/app/assets/src/js/react-components/components/isa-hero/index.tsx b/projects/plugins/boost/app/assets/src/js/react-components/components/isa-hero/index.tsx new file mode 100644 index 0000000000000..8d07461fb7e5b --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/isa-hero/index.tsx @@ -0,0 +1,95 @@ +import { IconTooltip } from '@automattic/jetpack-components'; +import classNames from 'classnames'; +import { createInterpolateElement } from '@wordpress/element'; +import { __, _n, sprintf } from '@wordpress/i18n'; +import ImageCdnRecommendation from '../image-cdn-recommendation'; +import styles from './styles.module.scss'; + +// removed in:fade={{ duration: 300, easing: quadOut }} from .jb-hero + +export const Hero = ( { + needsRefresh, + refresh, + isImageCdnModuleActive, + isaLastUpdated, + hasActiveGroup, + totalIssueCount, +} ) => { + const formatter = new Intl.DateTimeFormat( 'en-US', { + month: 'long', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + hour12: true, + } ); + + const lastUpdated = formatter.format( isaLastUpdated ); + const showLatestReport = hasActiveGroup && !! isaLastUpdated; + + return ( + <> + { showLatestReport ? ( +
+ ) : ( + <> +   +

 

+ + ) } + + ); +}; diff --git a/projects/plugins/boost/app/assets/src/js/react-components/components/isa-hero/styles.module.scss b/projects/plugins/boost/app/assets/src/js/react-components/components/isa-hero/styles.module.scss new file mode 100644 index 0000000000000..1e18f94b38565 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/isa-hero/styles.module.scss @@ -0,0 +1,29 @@ +.hero { + padding: 50px 0 30px; + display: flex; + flex-direction: column; + gap: calc( var( --gap ) / 2 ); +} + +@keyframes fadeIn { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} + +.fade-in { + animation-duration: 300ms; + animation-name: fadeIn; +} + +.tooltip { + margin-left: 8px; +} + +.tooltip button svg { + fill: var( --gray-30 ); +} diff --git a/projects/plugins/boost/app/assets/src/js/react-components/components/isa-other-group-context/index.tsx b/projects/plugins/boost/app/assets/src/js/react-components/components/isa-other-group-context/index.tsx new file mode 100644 index 0000000000000..7aeacc50dc545 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/isa-other-group-context/index.tsx @@ -0,0 +1,29 @@ +import { IconTooltip } from '@automattic/jetpack-components'; +import { __ } from '@wordpress/i18n'; +import styles from './styles.module.scss'; + +const OtherGroupContext = () => { + return ( + +

+ { __( + 'In addition to the Homepage, Pages and Posts, Boost will also analyze the following custom post types found on your site:', + 'jetpack-boost' + ) } +

+
    + { Object.entries( Jetpack_Boost.site.postTypes ).map( ( [ key, value ] ) => ( +
  • { value }
  • + ) ) } +
+
+ ); +}; + +export default OtherGroupContext; diff --git a/projects/plugins/boost/app/assets/src/js/react-components/components/isa-other-group-context/styles.module.scss b/projects/plugins/boost/app/assets/src/js/react-components/components/isa-other-group-context/styles.module.scss new file mode 100644 index 0000000000000..bcc3f099bd99b --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/isa-other-group-context/styles.module.scss @@ -0,0 +1,11 @@ +.tooltip { + margin-left: 8px; +} + +.tooltip p:first-child { + margin-top: 0; +} + +.tooltip button svg { + fill: var( --gray-30 ); +} diff --git a/projects/plugins/boost/app/assets/src/js/react-components/pages/settings/elements/MinifyMeta.tsx b/projects/plugins/boost/app/assets/src/js/react-components/components/minify-meta/index.tsx similarity index 96% rename from projects/plugins/boost/app/assets/src/js/react-components/pages/settings/elements/MinifyMeta.tsx rename to projects/plugins/boost/app/assets/src/js/react-components/components/minify-meta/index.tsx index 459fe7ee3d773..c57b65e9e45c3 100644 --- a/projects/plugins/boost/app/assets/src/js/react-components/pages/settings/elements/MinifyMeta.tsx +++ b/projects/plugins/boost/app/assets/src/js/react-components/components/minify-meta/index.tsx @@ -1,7 +1,7 @@ import { DataSyncProvider } from '@automattic/jetpack-react-data-sync-client'; import { useEffect, useState } from 'react'; import { __, sprintf } from '@wordpress/i18n'; -import { type Props, useMetaQuery, useConfig } from '../../../../stores/minify'; +import { type Props, useMetaQuery, useConfig } from '../../../stores/minify'; const MetaComponent = ( { inputLabel, buttonText, placeholder, datasyncKey }: Props ) => { const config = useConfig(); diff --git a/projects/plugins/boost/app/assets/src/js/react-components/sections/score/context-tooltip/index.tsx b/projects/plugins/boost/app/assets/src/js/react-components/sections/score/context-tooltip/index.tsx new file mode 100644 index 0000000000000..57c1789a64a46 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/sections/score/context-tooltip/index.tsx @@ -0,0 +1,57 @@ +import { IconTooltip } from '@automattic/jetpack-components'; +import { __ } from '@wordpress/i18n'; +import styles from './styles.module.scss'; + +const ContextTooltip = () => { + return ( + +

+ { __( + "Your Overall Score is a summary of your website performance across both mobile and desktop devices. It gives a general idea of your sites' overall performance.", + 'jetpack-boost' + ) } +

+ + + + + + + + + + + + + + + +
A90+
B75 - 90
C50 - 75
+ + + + + + + + + + + + + + + +
D35 - 50
E25 - 35
F0 - 25
+
+ ); +}; + +export default ContextTooltip; diff --git a/projects/plugins/boost/app/assets/src/js/react-components/sections/score/context-tooltip/styles.module.scss b/projects/plugins/boost/app/assets/src/js/react-components/sections/score/context-tooltip/styles.module.scss new file mode 100644 index 0000000000000..443b53c20046d --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/sections/score/context-tooltip/styles.module.scss @@ -0,0 +1,22 @@ +.table { + width: 49%; + margin: 0; + display: inline-block; +} + +.table td { + padding-left: 10px; +} + +.tooltip { + margin: 8px 0 0 6px; +} + +.tooltip p:first-child { + margin-top: 0; +} + +.tooltip button svg { + margin: 0; + fill: var( --gray-30 ); +} diff --git a/projects/plugins/boost/app/assets/src/js/react-components/sections/support/index.tsx b/projects/plugins/boost/app/assets/src/js/react-components/sections/support/index.tsx new file mode 100644 index 0000000000000..a21421761e37d --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/sections/support/index.tsx @@ -0,0 +1,34 @@ +import { __ } from '@wordpress/i18n'; +import { openPaidSupport } from '../../../utils/paid-plan'; +import styles from './styles.module.scss'; + +const Support = () => { + return ( +
+
+
+
+

{ __( "We're here to help", 'jetpack-boost' ) }

+

+ { __( + 'Your paid plan gives you access to prioritized Jetpack Boost support', + 'jetpack-boost' + ) } +

+
+
+ +
+
+
+
+ ); +}; + +export default Support; diff --git a/projects/plugins/boost/app/assets/src/js/react-components/sections/support/styles.module.scss b/projects/plugins/boost/app/assets/src/js/react-components/sections/support/styles.module.scss new file mode 100644 index 0000000000000..29f4a92f9a607 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/react-components/sections/support/styles.module.scss @@ -0,0 +1,13 @@ +.support { + display: grid; + grid-template-columns: auto auto; + align-items: center; +} + +.title { + margin-bottom: 24px !important; // @todo - use variable $halfling +} + +.cta { + text-align: right; +} diff --git a/projects/plugins/boost/app/assets/src/js/sections/Header.svelte b/projects/plugins/boost/app/assets/src/js/sections/Header.svelte index ac380041b72a8..1a4d5704e37e4 100644 --- a/projects/plugins/boost/app/assets/src/js/sections/Header.svelte +++ b/projects/plugins/boost/app/assets/src/js/sections/Header.svelte @@ -1,7 +1,7 @@