Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial State: Replace isEnhancedPublishingEnabled with siteHasFeature call #39835

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Initial state: Migrated isEnhancedPublishingEnabled to feature check
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { getRedirectUrl } from '@automattic/jetpack-components';
import { siteHasFeature } from '@automattic/jetpack-script-data';
import { ExternalLink } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { usePublicizeConfig } from '../../..';
import { features } from '../../utils/constants';
import Notice from '../notice';

export const InstagramNoMediaNotice: React.FC = () => {
const { isEnhancedPublishingEnabled } = usePublicizeConfig();

return isEnhancedPublishingEnabled ? (
return siteHasFeature( features.ENHANCED_PUBLISHING ) ? (
<Notice type={ 'warning' }>
{ __(
'To share to Instagram, add an image/video, or enable Social Image Generator.',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { usePublicizeConfig } from '../../..';
import { siteHasFeature } from '@automattic/jetpack-script-data';
import useSocialMediaMessage from '../../hooks/use-social-media-message';
import { features } from '../../utils/constants';
import MediaSection from '../media-section';
import MessageBoxControl from '../message-box-control';

Expand All @@ -16,8 +17,6 @@ type SharePostFormProps = {
export const SharePostForm: React.FC< SharePostFormProps > = ( { analyticsData = null } ) => {
const { message, updateMessage, maxLength } = useSocialMediaMessage();

const { isEnhancedPublishingEnabled } = usePublicizeConfig();

return (
<>
<MessageBoxControl
Expand All @@ -26,7 +25,9 @@ export const SharePostForm: React.FC< SharePostFormProps > = ( { analyticsData =
message={ message }
analyticsData={ analyticsData }
/>
{ isEnhancedPublishingEnabled && <MediaSection analyticsData={ analyticsData } /> }
{ siteHasFeature( features.ENHANCED_PUBLISHING ) && (
<MediaSection analyticsData={ analyticsData } />
) }
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Notice, getRedirectUrl } from '@automattic/jetpack-components';
import { siteHasFeature } from '@automattic/jetpack-script-data';
import { InstagramPreviews } from '@automattic/social-previews';
import { ExternalLink } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { __, _x } from '@wordpress/i18n';
import React from 'react';
import usePublicizeConfig from '../../hooks/use-publicize-config';
import useSocialMediaMessage from '../../hooks/use-social-media-message';
import { SOCIAL_STORE_ID, CONNECTION_SERVICE_INSTAGRAM_BUSINESS } from '../../social-store';
import { features } from '../../utils/constants';

/**
* The Instagram tab component.
Expand All @@ -19,7 +20,6 @@ export function Instagram( props ) {
const { username: name, profileImage } = useSelect( select =>
select( SOCIAL_STORE_ID ).getConnectionProfileDetails( CONNECTION_SERVICE_INSTAGRAM_BUSINESS )
);
const { isEnhancedPublishingEnabled } = usePublicizeConfig();

const { message: text } = useSocialMediaMessage();

Expand All @@ -42,7 +42,7 @@ export function Instagram( props ) {
</ExternalLink>,
] }
>
{ isEnhancedPublishingEnabled
{ siteHasFeature( features.ENHANCED_PUBLISHING )
? __(
'To share to Instagram, add an image/video, or enable Social Image Generator.',
'jetpack'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ export default function usePublicizeConfig() {
*/
const hasPaidPlan = !! getJetpackData()?.social?.hasPaidPlan;

/**
* isEnhancedPublishingEnabled:
* Whether the site has the enhanced publishing feature enabled. If true, it means that
* the site has the Advanced plan.
*/
const isEnhancedPublishingEnabled = !! getJetpackData()?.social?.isEnhancedPublishingEnabled;

/**\
* Returns true if the post type is a Jetpack Social Note.
*/
Expand All @@ -110,7 +103,6 @@ export default function usePublicizeConfig() {
hidePublicizeFeature,
isPostAlreadyShared,
hasPaidPlan,
isEnhancedPublishingEnabled,
isSocialImageGeneratorAvailable:
!! getJetpackData()?.social?.isSocialImageGeneratorAvailable && ! isJetpackSocialNote,
isSocialImageGeneratorEnabled: !! getJetpackData()?.social?.isSocialImageGeneratorEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const jetpackSettingSelectors = {
showPricingPage: state => state.jetpackSettings.show_pricing_page,
isUpdatingJetpackSettings: state => state.jetpackSettings.is_updating,
hasPaidPlan: state => ! ( state.jetpackSettings?.showNudge ?? true ),
isEnhancedPublishingEnabled: state => state.jetpackSettings?.isEnhancedPublishingEnabled ?? false,
getDismissedNotices: state => state.jetpackSettings?.dismissedNotices,
isSocialNotesEnabled: state => state.jetpackSettings?.social_notes_enabled,
isSocialNotesSettingsUpdating: state => state.jetpackSettings?.social_notes_is_updating,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const features = {
ENHANCED_PUBLISHING: 'social-enhanced-publishing',
};
Loading