Skip to content

Commit

Permalink
Merge branch 'trunk' into update/social/sig-feature-check
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Oct 24, 2024
2 parents 322aeda + cf5f21b commit 563eaac
Show file tree
Hide file tree
Showing 115 changed files with 516 additions and 250 deletions.
5 changes: 5 additions & 0 deletions projects/js-packages/ai-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## [0.22.0] - 2024-10-21
### Changed
- AI Client: Add types for AI assistant feature payload data branch featuresControl. [#39826]

## [0.21.0] - 2024-10-14
### Added
- AI Client: Add image styles 'auto' and 'none' to the logo generator. Order styles so those are on top in the dropdown selector. [#39689]
Expand Down Expand Up @@ -435,6 +439,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated package dependencies. [#31659]
- Updated package dependencies. [#31785]

[0.22.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.21.0...v0.22.0
[0.21.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.20.1...v0.21.0
[0.20.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.20.0...v0.20.1
[0.20.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.19.0...v0.20.0
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

AI Client: make reload handler prop optional as it still works in a fuzzy way. The error notice (modal) will instruct to reload the page when the optional prop is not provided
2 changes: 1 addition & 1 deletion projects/js-packages/ai-client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": false,
"name": "@automattic/jetpack-ai-client",
"version": "0.21.0",
"version": "0.22.0",
"description": "A JS client for consuming Jetpack AI services",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/ai-client/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,34 @@ import type React from 'react';

export const FeatureFetchFailureScreen: React.FC< {
onCancel: () => void;
onRetry: () => void;
onRetry?: () => void;
} > = ( { onCancel, onRetry } ) => {
const errorMessage = __(
'We are sorry. There was an error loading your Jetpack AI plan data. Please, try again.',
'jetpack-ai-client'
);

const errorMessageWithoutRetry = __(
'We are sorry. There was an error loading your Jetpack AI plan data. Please, reload the page and try again.',
'jetpack-ai-client'
);

return (
<div className="jetpack-ai-logo-generator-modal__notice-message-wrapper">
<div className="jetpack-ai-logo-generator-modal__notice-message">
<span className="jetpack-ai-logo-generator-modal__loading-message">{ errorMessage }</span>
<span className="jetpack-ai-logo-generator-modal__loading-message">
{ onRetry ? errorMessage : errorMessageWithoutRetry }
</span>
</div>
<div className="jetpack-ai-logo-generator-modal__notice-actions">
<Button variant="tertiary" onClick={ onCancel }>
{ __( 'Cancel', 'jetpack-ai-client' ) }
</Button>
<Button variant="primary" onClick={ onRetry }>
{ __( 'Try again', 'jetpack-ai-client' ) }
</Button>
{ onRetry && (
<Button variant="primary" onClick={ onRetry }>
{ __( 'Try again', 'jetpack-ai-client' ) }
</Button>
) }
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
isOpen,
onClose,
onApplyLogo,
onReload,
onReload = null,
siteDetails,
context,
placement,
Expand Down Expand Up @@ -73,7 +73,8 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
site,
requireUpgrade,
} = useLogoGenerator();
const { featureFetchError, firstLogoPromptFetchError, clearErrors } = useRequestErrors();
const { featureFetchError, setFeatureFetchError, firstLogoPromptFetchError, clearErrors } =
useRequestErrors();
const siteId = siteDetails?.ID;
const [ logoAccepted, setLogoAccepted ] = useState( false );
const { nextTierCheckoutURL: upgradeURL } = useCheckout();
Expand Down Expand Up @@ -105,6 +106,15 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
*/
const initializeModal = useCallback( async () => {
try {
if ( ! siteId ) {
throw new Error( 'Site ID is missing' );
}

if ( ! feature?.featuresControl?.[ 'logo-generator' ]?.enabled ) {
setFeatureFetchError( 'Failed to fetch feature data' );
throw new Error( 'Failed to fetch feature data' );
}

const hasHistory = ! isLogoHistoryEmpty( String( siteId ) );

const logoCost = feature?.costs?.[ 'jetpack-ai-logo-generator' ]?.logo ?? DEFAULT_LOGO_COST;
Expand Down Expand Up @@ -179,6 +189,7 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
isLogoHistoryEmpty,
siteId,
requireUpgrade,
setFeatureFetchError,
] );

const handleModalOpen = useCallback( async () => {
Expand All @@ -201,6 +212,15 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
recordTracksEvent( EVENT_MODAL_CLOSE, { context, placement } );
};

const handleReload = useCallback( () => {
if ( ! onReload ) {
return;
}
closeModal();
requestedFeatureData.current = false;
onReload();
}, [ onReload, closeModal ] );

const handleApplyLogo = ( mediaId: number ) => {
setLogoAccepted( true );
onApplyLogo?.( mediaId );
Expand Down Expand Up @@ -229,7 +249,7 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
// Handles modal opening logic
useEffect( () => {
// While the modal is not open, the siteId is not set, or the feature data is not available, do nothing.
if ( ! isOpen || ! siteId || ! feature?.costs ) {
if ( ! isOpen ) {
return;
}

Expand All @@ -238,7 +258,7 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
needsToHandleModalOpen.current = false;
handleModalOpen();
}
}, [ isOpen, siteId, handleModalOpen, feature ] );
}, [ isOpen, handleModalOpen ] );

let body: React.ReactNode;

Expand All @@ -248,10 +268,7 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
body = (
<FeatureFetchFailureScreen
onCancel={ closeModal }
onRetry={ () => {
closeModal();
onReload?.();
} }
onRetry={ onReload ? handleReload : null }
/>
);
} else if ( needsFeature || needsMoreRequests ) {
Expand Down
2 changes: 1 addition & 1 deletion projects/js-packages/ai-client/src/logo-generator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface GeneratorModalProps {
isOpen: boolean;
onClose: () => void;
onApplyLogo: ( mediaId: number ) => void;
onReload: () => void;
onReload?: () => void;
context: string;
placement: string;
}
Expand Down
4 changes: 4 additions & 0 deletions projects/js-packages/partner-coupon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## 0.2.93 - 2024-10-21
### Changed
- Update dependencies. [#39781]

## 0.2.92 - 2024-10-14
### Changed
- Updated package dependencies. [#39707]
Expand Down
4 changes: 0 additions & 4 deletions projects/js-packages/partner-coupon/changelog/force-a-release

This file was deleted.

2 changes: 1 addition & 1 deletion projects/js-packages/partner-coupon/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-partner-coupon",
"version": "0.2.92",
"version": "0.2.93",
"description": "This package aims to add components to make it easier to redeem partner coupons",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/partner-coupon/#readme",
"bugs": {
Expand Down
9 changes: 9 additions & 0 deletions projects/js-packages/publicize-components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ 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).

## [0.71.3] - 2024-10-21
### Changed
- Initial state: Migrated URLs in the editor to the new script data. [#39799] [#39797]
- Update dependencies. [#39781]

### Fixed
- Social: Fixed Bluesky display name when it's not set in Bluesky profile. [#39840]

## [0.71.2] - 2024-10-14
### Added
- Social: Added Bluesky to social previews. [#39659]
Expand Down Expand Up @@ -970,6 +978,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Updated package dependencies. [#24470]

[0.71.3]: https://github.com/Automattic/jetpack-publicize-components/compare/v0.71.2...v0.71.3
[0.71.2]: https://github.com/Automattic/jetpack-publicize-components/compare/v0.71.1...v0.71.2
[0.71.1]: https://github.com/Automattic/jetpack-publicize-components/compare/v0.71.0...v0.71.1
[0.71.0]: https://github.com/Automattic/jetpack-publicize-components/compare/v0.70.1...v0.71.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Social: Fixed Bluesky custom domain handle not being accepted

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Initial State: Migrated hasPaidFeatures flag with feature check on front-end


2 changes: 1 addition & 1 deletion projects/js-packages/publicize-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-publicize-components",
"version": "0.71.2",
"version": "0.71.3",
"description": "A library of JS components required by the Publicize editor plugin",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/publicize-components/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@ import {
isSimpleSite,
} from '@automattic/jetpack-shared-extension-utils';
import { Button, PanelRow } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { _x } from '@wordpress/i18n';
import { store as socialStore } from '../../social-store';
import { hasSocialPaidFeatures } from '../../utils';
import styles from './styles.module.scss';
import { useAutoSaveAndRedirect } from './use-auto-save-and-redirect';

export const EnhancedFeaturesNudge: React.FC = () => {
const hasPaidFeatures = useSelect( select => select( socialStore ).hasPaidFeatures(), [] );

const autosaveAndRedirect = useAutoSaveAndRedirect();

const isWpcom = isSimpleSite() || isAtomicSite();

if ( isWpcom || hasPaidFeatures ) {
if ( isWpcom || hasSocialPaidFeatures() ) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const isValidMastodonUsername = ( username: string ) =>

/**
* Example valid handles:
* - domain.tld
* - username.bsky.social
* - user-name.bsky.social
* - my_domain.com.bsky.social
* - my-domain.com.my-own-server.com
* - my-domain.com
*
* @param {string} handle - Handle to validate
*
Expand All @@ -23,8 +23,8 @@ const isValidMastodonUsername = ( username: string ) =>
function isValidBlueskyHandle( handle: string ) {
const parts = handle.split( '.' ).filter( Boolean );

// A valid handle should have at least 3 parts - username, domain, and tld
if ( parts.length < 3 ) {
// A valid handle should have at least 2 parts - domain, and tld
if ( parts.length < 2 ) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const reducer = combineReducers( {
socialImageGeneratorSettings,
shareStatus,
hasPaidPlan: ( state = false ) => state,
hasPaidFeatures: ( state = false ) => state,
} );

export default reducer;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const selectors = {
...jetpackSettingSelectors,
...socialImageGeneratorSettingsSelectors,
...shareStatusSelectors,
hasPaidFeatures: state => state.hasPaidFeatures,
};

export default selectors;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getScriptData } from '@automattic/jetpack-script-data';
import { getScriptData, siteHasFeature } from '@automattic/jetpack-script-data';
import { SocialScriptData } from '../types/types';

/**
Expand All @@ -9,3 +9,12 @@ import { SocialScriptData } from '../types/types';
export function getSocialScriptData(): SocialScriptData {
return getScriptData().social;
}

/**
* Check if the site has social paid features.
*
* @return {boolean} Whether the site has social paid features.
*/
export function hasSocialPaidFeatures() {
return siteHasFeature( 'social-enhanced-publishing' );
}
5 changes: 5 additions & 0 deletions projects/js-packages/script-data/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## [0.1.3] - 2024-10-21
### Fixed
- Fixed the site features for Simple sites. [#39817]

## [0.1.2] - 2024-08-21
### Changed
- Internal updates.
Expand All @@ -17,5 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added jetpack-script-data package to consolidate the logic for Jetpack Initial state [#38430]

[0.1.3]: https://github.com/Automattic/jetpack-script-data/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/Automattic/jetpack-script-data/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/Automattic/jetpack-script-data/compare/v0.1.0...v0.1.1

This file was deleted.

2 changes: 1 addition & 1 deletion projects/js-packages/script-data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/jetpack-script-data",
"version": "0.1.2",
"version": "0.1.3",
"description": "A library to provide data for script handles and the corresponding utility functions for Jetpack.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/script-data/#readme",
"bugs": {
Expand Down
5 changes: 5 additions & 0 deletions projects/js-packages/shared-extension-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## [0.15.14] - 2024-10-21
### Changed
- Update dependencies. [#39781]

## [0.15.13] - 2024-10-14
### Changed
- Updated package dependencies. [#39707]
Expand Down Expand Up @@ -471,6 +475,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Core: prepare utility for release

[0.15.14]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.15.13...0.15.14
[0.15.13]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.15.12...0.15.13
[0.15.12]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.15.11...0.15.12
[0.15.11]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.15.10...0.15.11
Expand Down
Loading

0 comments on commit 563eaac

Please sign in to comment.