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 1 commit
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,11 @@
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 Notice from '../notice';

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

return isEnhancedPublishingEnabled ? (
return siteHasFeature( 'social-enhanced-publishing' ) ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using constants for these feature strings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks

<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,4 +1,4 @@
import { usePublicizeConfig } from '../../..';
import { siteHasFeature } from '@automattic/jetpack-script-data';
import useSocialMediaMessage from '../../hooks/use-social-media-message';
import MediaSection from '../media-section';
import MessageBoxControl from '../message-box-control';
Expand All @@ -16,8 +16,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 +24,9 @@ export const SharePostForm: React.FC< SharePostFormProps > = ( { analyticsData =
message={ message }
analyticsData={ analyticsData }
/>
{ isEnhancedPublishingEnabled && <MediaSection analyticsData={ analyticsData } /> }
{ siteHasFeature( 'social-enhanced-publishing' ) && (
<MediaSection analyticsData={ analyticsData } />
) }
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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';

Expand All @@ -19,7 +19,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 +41,7 @@ export function Instagram( props ) {
</ExternalLink>,
] }
>
{ isEnhancedPublishingEnabled
{ siteHasFeature( 'social-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
Loading