diff --git a/projects/js-packages/publicize-components/changelog/update-social-initial-stat-migrate-shares-data b/projects/js-packages/publicize-components/changelog/update-social-initial-stat-migrate-shares-data
new file mode 100644
index 0000000000000..b1cfb12b7f277
--- /dev/null
+++ b/projects/js-packages/publicize-components/changelog/update-social-initial-stat-migrate-shares-data
@@ -0,0 +1,4 @@
+Significance: minor
+Type: removed
+
+Social: Removed share limits UI and data logic
diff --git a/projects/js-packages/publicize-components/index.ts b/projects/js-packages/publicize-components/index.ts
index c24bfa53c11b8..ae4ab198d4d45 100644
--- a/projects/js-packages/publicize-components/index.ts
+++ b/projects/js-packages/publicize-components/index.ts
@@ -31,9 +31,7 @@ export * from './src/social-store';
export * from './src/utils';
export * from './src/components/share-post';
export * from './src/hooks/use-sync-post-data-to-store';
-export * from './src/components/share-limits-bar';
export * from './src/hooks/use-saving-post';
-export * from './src/hooks/use-share-limits';
export * from './src/hooks/use-post-meta';
export * from './src/components/share-buttons';
export * from './src/components/manage-connections-modal';
diff --git a/projects/js-packages/publicize-components/src/components/form/enhanced-features-nudge.tsx b/projects/js-packages/publicize-components/src/components/form/enhanced-features-nudge.tsx
new file mode 100644
index 0000000000000..ce90b960e33a2
--- /dev/null
+++ b/projects/js-packages/publicize-components/src/components/form/enhanced-features-nudge.tsx
@@ -0,0 +1,44 @@
+import { getRedirectUrl } from '@automattic/jetpack-components';
+import {
+ getSiteFragment,
+ isAtomicSite,
+ 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 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 ) {
+ return null;
+ }
+
+ return (
+
+
+ { _x(
+ 'Unlock enhanced media sharing features.',
+ 'Call to action to buy a new plan',
+ 'jetpack'
+ ) }
+
+
+ );
+};
diff --git a/projects/js-packages/publicize-components/src/components/form/index.tsx b/projects/js-packages/publicize-components/src/components/form/index.tsx
index 5d0f342b3326b..6e1b2eb9039c1 100644
--- a/projects/js-packages/publicize-components/src/components/form/index.tsx
+++ b/projects/js-packages/publicize-components/src/components/form/index.tsx
@@ -16,7 +16,7 @@ import { ThemedConnectionsModal as ManageConnectionsModal } from '../manage-conn
import { SocialPostModal } from '../social-post-modal/modal';
import { ConnectionNotice } from './connection-notice';
import { ConnectionsList } from './connections-list';
-import { ShareCountInfo } from './share-count-info';
+import { EnhancedFeaturesNudge } from './enhanced-features-nudge';
import { SharePostForm } from './share-post-form';
/**
@@ -50,7 +50,7 @@ export default function PublicizeForm() {
{ featureFlags.useEditorPreview && isPublicizeEnabled ? : null }
-
+
>
) : null }
diff --git a/projects/js-packages/publicize-components/src/components/form/share-count-info.tsx b/projects/js-packages/publicize-components/src/components/form/share-count-info.tsx
deleted file mode 100644
index 6d30af8765702..0000000000000
--- a/projects/js-packages/publicize-components/src/components/form/share-count-info.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import { IconTooltip, Text, ThemeProvider } from '@automattic/jetpack-components';
-import { getRedirectUrl } from '@automattic/jetpack-components';
-import {
- getSiteFragment,
- isAtomicSite,
- isSimpleSite,
-} from '@automattic/jetpack-shared-extension-utils';
-import { Button, PanelRow } from '@wordpress/components';
-import { useSelect } from '@wordpress/data';
-import { __, _x } from '@wordpress/i18n';
-import { useShareLimits } from '../../hooks/use-share-limits';
-import { store as socialStore } from '../../social-store';
-import { ShareLimitsBar } from '../share-limits-bar';
-import { ShareCountNotice } from './share-count-notice';
-import styles from './styles.module.scss';
-import { useAutoSaveAndRedirect } from './use-auto-save-and-redirect';
-
-export const ShareCountInfo: React.FC = () => {
- const { showShareLimits, hasPaidFeatures } = useSelect( select => {
- const store = select( socialStore );
- return {
- showShareLimits: store.showShareLimits(),
- hasPaidFeatures: store.hasPaidFeatures(),
- };
- }, [] );
-
- const { noticeType, usedCount, scheduledCount, remainingCount } = useShareLimits();
- const autosaveAndRedirect = useAutoSaveAndRedirect();
-
- const isWpcom = isSimpleSite() || isAtomicSite();
-
- if ( isWpcom || ( ! showShareLimits && hasPaidFeatures ) ) {
- return null;
- }
-
- return (
-
-
-
- { showShareLimits ? (
- <>
-
-
- { __( 'Auto-shares this cycle', 'jetpack' ) }
-
-
-
- { __(
- 'As a free Jetpack Social user, you get 30 shares within every rolling 30-day window.',
- 'jetpack'
- ) }
-
-
-
-
-
-
- >
- ) : null }
- { noticeType === 'default' && ! hasPaidFeatures ? (
-
- { _x(
- 'Unlock enhanced media sharing features.',
- 'Call to action to buy a new plan',
- 'jetpack'
- ) }
-
- ) : null }
-
-
-
- );
-};
diff --git a/projects/js-packages/publicize-components/src/components/form/share-count-notice.tsx b/projects/js-packages/publicize-components/src/components/form/share-count-notice.tsx
deleted file mode 100644
index 668067ab621f4..0000000000000
--- a/projects/js-packages/publicize-components/src/components/form/share-count-notice.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { getRedirectUrl } from '@automattic/jetpack-components';
-import { getSiteFragment } from '@automattic/jetpack-shared-extension-utils';
-import { Button } from '@wordpress/components';
-import { useSelect } from '@wordpress/data';
-import { _x } from '@wordpress/i18n';
-import { useShareLimits } from '../../hooks/use-share-limits';
-import { store as socialStore } from '../../social-store';
-import Notice from '../notice';
-import { useAutoSaveAndRedirect } from './use-auto-save-and-redirect';
-
-export const ShareCountNotice: React.FC = () => {
- const showShareLimits = useSelect( select => select( socialStore ).showShareLimits(), [] );
-
- const autosaveAndRedirect = useAutoSaveAndRedirect();
- const { message } = useShareLimits();
-
- if ( ! showShareLimits || ! message ) {
- return null;
- }
-
- return (
-
- { _x( 'Upgrade', 'Call to action to buy a new plan', 'jetpack' ) }
- ,
- ] }
- >
- { message }
-
- );
-};
diff --git a/projects/js-packages/publicize-components/src/components/form/styles.module.scss b/projects/js-packages/publicize-components/src/components/form/styles.module.scss
index 752d496a258a1..85b6af7fc55a3 100644
--- a/projects/js-packages/publicize-components/src/components/form/styles.module.scss
+++ b/projects/js-packages/publicize-components/src/components/form/styles.module.scss
@@ -24,26 +24,7 @@
margin-inline-start: 15px;
}
-.bar-wrapper {
- :global .record-meter-bar {
- .record-meter-bar__legend--items {
- flex-wrap: wrap;
- }
-
- .record-meter-bar__items {
- height: 0.5rem;
- margin-bottom: 0.8em;
- }
-
- .record-meter-bar__legend--item-circle {
- width: 0.5rem;
- height: 0.5rem;
- }
- }
-}
-
-.share-count-info {
- flex-grow: 1;
+.enhanced-features-nudge {
margin-block-end: 1rem;
}
@@ -52,16 +33,6 @@
margin-bottom: 0.25rem;
}
-p.auto-share-title {
- font-weight: 600;
- text-transform: uppercase;
-}
-
-.title-container {
- display: flex;
- gap: 0.4rem;
-}
-
.no-connections-text {
display: block;
margin-bottom: 1rem;
diff --git a/projects/js-packages/publicize-components/src/components/form/use-connection-state.ts b/projects/js-packages/publicize-components/src/components/form/use-connection-state.ts
index db70d01935c8f..e994363e19d4a 100644
--- a/projects/js-packages/publicize-components/src/components/form/use-connection-state.ts
+++ b/projects/js-packages/publicize-components/src/components/form/use-connection-state.ts
@@ -1,4 +1,3 @@
-import { useSelect } from '@wordpress/data';
import { useCallback } from '@wordpress/element';
import { useMemo } from 'react';
import { usePublicizeConfig } from '../../..';
@@ -8,18 +7,11 @@ import useMediaDetails from '../../hooks/use-media-details';
import useMediaRestrictions from '../../hooks/use-media-restrictions';
import { NO_MEDIA_ERROR } from '../../hooks/use-media-restrictions/constants';
import useSocialMediaConnections from '../../hooks/use-social-media-connections';
-import { store as socialStore } from '../../social-store';
import { Connection } from '../../social-store/types';
export const useConnectionState = () => {
- const { connections, enabledConnections } = useSocialMediaConnections();
+ const { connections } = useSocialMediaConnections();
const { isPublicizeEnabled, isPublicizeDisabledBySitePlan } = usePublicizeConfig();
- const { showShareLimits, numberOfSharesRemaining } = useSelect( select => {
- return {
- showShareLimits: select( socialStore ).showShareLimits(),
- numberOfSharesRemaining: select( socialStore ).numberOfSharesRemaining(),
- };
- }, [] );
const { attachedMedia } = useAttachedMedia();
const featuredImageId = useFeaturedImage();
const mediaId = attachedMedia[ 0 ]?.id || featuredImageId;
@@ -29,8 +21,6 @@ export const useConnectionState = () => {
useMediaDetails( mediaId )[ 0 ]
);
- const outOfConnections = showShareLimits && numberOfSharesRemaining <= enabledConnections.length;
-
/**
* Returns whether a connection is in good shape.
*
@@ -69,20 +59,14 @@ export const useConnectionState = () => {
*/
const shouldBeDisabled = useCallback(
( connection: Connection ) => {
- const { enabled, toggleable } = connection;
-
- const isOutOfConnections = ! enabled && toggleable && outOfConnections;
- // A connection toggle should be disabled if
return (
// Publicize is disabled
! isPublicizeEnabled ||
- // or if there are no more connections available
- isOutOfConnections ||
// or the connection is not in good shape
! isInGoodShape( connection )
);
},
- [ isInGoodShape, isPublicizeEnabled, outOfConnections ]
+ [ isInGoodShape, isPublicizeEnabled ]
);
/**
diff --git a/projects/js-packages/publicize-components/src/components/share-limits-bar/index.tsx b/projects/js-packages/publicize-components/src/components/share-limits-bar/index.tsx
deleted file mode 100644
index b9167cfa71e36..0000000000000
--- a/projects/js-packages/publicize-components/src/components/share-limits-bar/index.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import { RecordMeterBar } from '@automattic/jetpack-components';
-import { useMemo } from '@wordpress/element';
-import { __, _x } from '@wordpress/i18n';
-import clsx from 'clsx';
-import { ShareLimits } from '../../hooks/use-share-limits';
-import styles from './styles.module.scss';
-
-type NoticeType = ShareLimits[ 'noticeType' ];
-
-export type ShareLimitsBarProps = {
- usedCount: number;
- scheduledCount: number;
- remainingCount?: number;
- remainingLabel?: string;
- className?: string;
- noticeType?: NoticeType;
- legendCaption?: string;
-};
-
-const colorsForUsed: Record< NoticeType, string > = {
- error: 'var(--jp-red-50)',
- warning: 'var(--jp-yellow-20)',
- default: 'var(--jp-green)',
-};
-
-const colorsForScheduled: Record< NoticeType, string > = {
- error: 'var(--jp-red-50)',
- warning: 'var(--jp-yellow-20)',
- default: 'var(--jp-green-5)',
-};
-
-export const ShareLimitsBar = ( {
- usedCount,
- scheduledCount,
- remainingCount,
- remainingLabel,
- className,
- noticeType = 'default',
- legendCaption,
-}: ShareLimitsBarProps ) => {
- const items = useMemo( () => {
- const scheduledMessage = __( 'scheduled', 'jetpack' );
- const usedAndScheduledMessage = __( 'used or scheduled', 'jetpack' );
- return [
- ( noticeType === 'default' || scheduledCount === 0 ) && {
- count: usedCount,
- backgroundColor: colorsForUsed[ noticeType ],
- label: __( 'used', 'jetpack' ),
- },
- scheduledCount > 0 && {
- count: noticeType === 'default' ? scheduledCount : scheduledCount + usedCount,
- backgroundColor: colorsForScheduled[ noticeType ],
- label: noticeType === 'default' ? scheduledMessage : usedAndScheduledMessage,
- },
- {
- count: remainingCount,
- backgroundColor: 'var(--jp-gray-off)',
- label:
- remainingLabel ||
- _x(
- 'left',
- 'Referring to the quantity remaning, not the direction - left/right.',
- 'jetpack'
- ),
- },
- ].filter( Boolean );
- }, [ noticeType, scheduledCount, usedCount, remainingCount, remainingLabel ] );
-
- return (
-
-
-
- );
-};
diff --git a/projects/js-packages/publicize-components/src/components/share-limits-bar/styles.module.scss b/projects/js-packages/publicize-components/src/components/share-limits-bar/styles.module.scss
deleted file mode 100644
index cc9e08dc42925..0000000000000
--- a/projects/js-packages/publicize-components/src/components/share-limits-bar/styles.module.scss
+++ /dev/null
@@ -1,12 +0,0 @@
-.bar-wrapper {
- :global .record-meter-bar__items{
- height: 1.5rem;
- }
-}
-
-.wrapper {
- :global .record-meter-bar__legend {
- display: flex;
- gap: 1rem;
- }
-}
diff --git a/projects/js-packages/publicize-components/src/hooks/use-publicize-config/index.js b/projects/js-packages/publicize-components/src/hooks/use-publicize-config/index.js
index 9cbb80cf1f70d..f1b896fcd5aab 100644
--- a/projects/js-packages/publicize-components/src/hooks/use-publicize-config/index.js
+++ b/projects/js-packages/publicize-components/src/hooks/use-publicize-config/index.js
@@ -21,11 +21,9 @@ const republicizeFeatureName = 'republicize';
* for toggling support for the current post.
*/
export default function usePublicizeConfig() {
- const sharesData = getJetpackData()?.social?.sharesData ?? {};
const blogID = getJetpackData()?.wpcomBlogId;
- const isShareLimitEnabled = sharesData.is_share_limit_enabled;
const isRePublicizeFeatureAvailable =
- getJetpackExtensionAvailability( republicizeFeatureName )?.available || isShareLimitEnabled;
+ getJetpackExtensionAvailability( republicizeFeatureName )?.available;
const isPostPublished = useSelect( select => select( editorStore ).isCurrentPostPublished(), [] );
const currentPostType = useSelect( select => select( editorStore ).getCurrentPostType(), [] );
const { isUserConnected } = useConnection();
@@ -115,9 +113,7 @@ export default function usePublicizeConfig() {
isRePublicizeFeatureAvailable,
isRePublicizeUpgradableViaUpsell,
hidePublicizeFeature,
- isShareLimitEnabled,
isPostAlreadyShared,
- numberOfSharesRemaining: sharesData.shares_remaining,
hasPaidPlan,
isEnhancedPublishingEnabled,
isSocialImageGeneratorAvailable:
diff --git a/projects/js-packages/publicize-components/src/hooks/use-share-limits/index.ts b/projects/js-packages/publicize-components/src/hooks/use-share-limits/index.ts
deleted file mode 100644
index 049b6a2d37e7b..0000000000000
--- a/projects/js-packages/publicize-components/src/hooks/use-share-limits/index.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import { useSelect } from '@wordpress/data';
-import { __, _n, sprintf } from '@wordpress/i18n';
-import { store as socialStore } from '../../social-store';
-
-export type ShareLimits = {
- status: 'approaching' | 'exceeded' | 'full' | 'none';
- noticeType: 'default' | 'warning' | 'error';
- message: string;
- usedCount: number;
- scheduledCount: number;
- remainingCount: number;
-};
-
-export type UseShareLimitsArgs = {
- scheduledCountAdjustment?: number;
- usedCountAdjustment?: number;
-};
-
-/**
- * Returns the messages for the share limits
- *
- * @param {number} remainingCount - The number of shares left
- * @return {ReturnType} Share limits messages
- */
-export function getMessages( remainingCount: number ) {
- const remaining = Number.isFinite( remainingCount )
- ? sprintf(
- // translators: %d: The number of shares to social media remaining
- _n(
- 'You have %d auto-share remaining.',
- 'You have %d auto-shares remaining.',
- remainingCount,
- 'jetpack'
- ),
- remainingCount
- )
- : '';
- return {
- default: '',
- exceeded: __(
- 'You have reached your auto-share limit. Scheduled posts will not be shared until shares become available.',
- 'jetpack'
- ),
- full: __( 'You have reached your auto-share limit.', 'jetpack' ),
- approaching: remaining,
- };
-}
-
-/**
- * Returns the share limits details
- *
- * @param {UseShareLimitsArgs} args - Arguments
- *
- * @return {ShareLimits} Share limits details
- */
-export function useShareLimits( {
- scheduledCountAdjustment = 0,
- usedCountAdjustment = 0,
-}: UseShareLimitsArgs = {} ): ShareLimits {
- return useSelect(
- select => {
- const store = select( socialStore );
-
- const shareLimit = store.getShareLimit();
- const scheduledShares = store.getScheduledSharesCount() + scheduledCountAdjustment;
- const usedSharesCount = store.getSharesUsedCount() + usedCountAdjustment;
- const totalSharesCount = usedSharesCount + scheduledShares;
- const remainingCount = store.numberOfSharesRemaining();
- const messages = getMessages( remainingCount );
-
- let noticeType: ShareLimits[ 'noticeType' ] = 'default';
- let status: ShareLimits[ 'status' ] = 'none';
- let message = messages.default;
-
- // If they have exceeded their limit
- if ( totalSharesCount > shareLimit ) {
- noticeType = 'error';
- status = 'exceeded';
- message = messages.exceeded;
- } else if ( totalSharesCount === shareLimit ) {
- status = 'full';
- noticeType = 'error';
- message = messages.full;
- }
- // If they have used 90% of their limit, they are almost at the end
- else if ( totalSharesCount >= shareLimit * 0.9 ) {
- status = 'approaching';
- noticeType = 'error';
- message = messages.approaching;
- }
- // If they have used 80% of their limit, they are approaching it
- else if ( totalSharesCount >= shareLimit * 0.8 ) {
- status = 'approaching';
- noticeType = 'warning';
- message = messages.approaching;
- }
-
- return {
- status,
- noticeType,
- message,
- usedCount: usedSharesCount,
- scheduledCount: scheduledShares,
- remainingCount,
- };
- },
- [ scheduledCountAdjustment, usedCountAdjustment ]
- );
-}
diff --git a/projects/js-packages/publicize-components/src/hooks/use-share-limits/test/index.test.tsx b/projects/js-packages/publicize-components/src/hooks/use-share-limits/test/index.test.tsx
deleted file mode 100644
index c31c40dfb7cfc..0000000000000
--- a/projects/js-packages/publicize-components/src/hooks/use-share-limits/test/index.test.tsx
+++ /dev/null
@@ -1,210 +0,0 @@
-import { renderHook } from '@testing-library/react';
-import { RegistryProvider, createRegistry, createReduxStore } from '@wordpress/data';
-import { WPDataRegistry } from '@wordpress/data/build-types/registry';
-import { getMessages, useShareLimits } from '../';
-import { SOCIAL_STORE_CONFIG, SOCIAL_STORE_ID } from '../../../social-store';
-import { SocialStoreState } from '../../../social-store/types';
-
-type DeepPartial< T > = T extends object
- ? {
- [ P in keyof T ]?: DeepPartial< T[ P ] >;
- }
- : T;
-
-/**
- * Create a registry with stores.
- *
- * @param {Partial< SocialStoreState >} initialState - Initial state for the store.
- *
- * @return {WPDataRegistry} Registry.
- */
-function createRegistryWithStores( initialState = {} ): WPDataRegistry {
- // Create a registry.
- const registry = createRegistry();
-
- const socialStore = createReduxStore( SOCIAL_STORE_ID, { ...SOCIAL_STORE_CONFIG, initialState } );
- // Register stores.
- // @ts-expect-error The registry type is not correct. This comment can be removed when register() exists in the type.
- registry.register( socialStore );
-
- return registry;
-}
-
-/**
- * Returns the initial state for the store.
- *
- * @param {Partial< SocialStoreState >} data - Data to override the default state
- *
- * @return {SocialStoreState} Initial state for the store
- */
-function getStoreInitialState( data: DeepPartial< SocialStoreState > ) {
- return {
- ...data,
- sharesData: {
- is_share_limit_enabled: true,
- to_be_publicized_count: 0,
- share_limit: 30,
- publicized_count: 0,
- shared_posts_count: 0,
- ...data.sharesData,
- },
- };
-}
-
-const messages = getMessages( 0 );
-
-describe( 'useShareLimits', () => {
- it( 'should return the default values', () => {
- const { result } = renderHook( () => useShareLimits() );
-
- expect( result.current ).toEqual( {
- status: 'none',
- noticeType: 'default',
- message: getMessages( Infinity ).default,
- usedCount: 0,
- scheduledCount: 0,
- remainingCount: Infinity,
- } );
- } );
-
- const testCases = [
- {
- name: 'should return the default values at the beginning',
- sharesData: {
- publicized_count: 0,
- to_be_publicized_count: 0,
- },
- expected: {
- status: 'none',
- noticeType: 'default',
- message: getMessages( 30 ).default,
- usedCount: 0,
- scheduledCount: 0,
- remainingCount: 30,
- },
- },
- {
- name: 'should return "default" with default message when used + scheduled < limit',
- sharesData: {
- publicized_count: 5,
- to_be_publicized_count: 5,
- },
- expected: {
- status: 'none',
- noticeType: 'default',
- message: getMessages( 20 ).default,
- usedCount: 5,
- scheduledCount: 5,
- remainingCount: 20,
- },
- },
- {
- name: 'should return "full" with limit exceeded message when the limit is reached without scheduled posts',
- sharesData: {
- publicized_count: 30,
- to_be_publicized_count: 0,
- },
- expected: {
- status: 'full',
- noticeType: 'error',
- message: messages.full,
- usedCount: 30,
- scheduledCount: 0,
- remainingCount: 0,
- },
- },
- {
- name: 'should return "full" with scheduled shares message when the limit is reached with scheduled posts',
- sharesData: {
- publicized_count: 15,
- to_be_publicized_count: 15,
- },
- expected: {
- status: 'full',
- noticeType: 'error',
- message: messages.full,
- usedCount: 15,
- scheduledCount: 15,
- remainingCount: 0,
- },
- },
- {
- name: 'should return "crossed" with limit exceeded message when the limit is crossed without scheduled posts',
- sharesData: {
- publicized_count: 35, // impossible to reach this number but just in case
- to_be_publicized_count: 0,
- },
- expected: {
- status: 'exceeded',
- noticeType: 'error',
- message: messages.exceeded,
- usedCount: 35,
- scheduledCount: 0,
- remainingCount: 0,
- },
- },
- {
- name: 'should return "crossed" with limit exceeded message when the limit is crossed with scheduled posts',
- sharesData: {
- publicized_count: 30,
- to_be_publicized_count: 5,
- },
- expected: {
- status: 'exceeded',
- noticeType: 'error',
- message: messages.exceeded,
- usedCount: 30,
- scheduledCount: 5,
- remainingCount: 0,
- },
- },
- {
- name: 'should return "approaching" with approaching limit message when the limit is approached without scheduled posts',
- sharesData: {
- publicized_count: 25,
- to_be_publicized_count: 0,
- },
- expected: {
- status: 'approaching',
- noticeType: 'warning',
- message: getMessages( 5 ).approaching,
- usedCount: 25,
- scheduledCount: 0,
- remainingCount: 5,
- },
- },
- {
- name: 'should return "approaching" with approaching limit message when the limit is approached with scheduled posts',
- sharesData: {
- publicized_count: 20,
- to_be_publicized_count: 5,
- },
- expected: {
- status: 'approaching',
- noticeType: 'warning',
- message: getMessages( 5 ).approaching,
- usedCount: 20,
- scheduledCount: 5,
- remainingCount: 5,
- },
- },
- ];
-
- for ( const { name, expected, ...initiaState } of testCases ) {
- describe( 'dynamic tests', () => {
- it( `${ name }`, () => {
- const { result } = renderHook( () => useShareLimits(), {
- wrapper: ( { children } ) => (
-
- { children }
-
- ),
- } );
-
- expect( result.current ).toEqual( expected );
- } );
- } );
- }
-} );
diff --git a/projects/js-packages/publicize-components/src/social-store/actions/connection-data.js b/projects/js-packages/publicize-components/src/social-store/actions/connection-data.js
index f9fc9f81dd418..1594de17cb502 100644
--- a/projects/js-packages/publicize-components/src/social-store/actions/connection-data.js
+++ b/projects/js-packages/publicize-components/src/social-store/actions/connection-data.js
@@ -82,7 +82,7 @@ export function mergeConnections( freshConnections ) {
const connections = [];
const defaults = {
done: false,
- enabled: Boolean( select.numberOfSharesRemaining() ),
+ enabled: true,
toggleable: true,
};
diff --git a/projects/js-packages/publicize-components/src/social-store/selectors/shares-data.ts b/projects/js-packages/publicize-components/src/social-store/selectors/shares-data.ts
index 2d2716f7e5e7c..deb1d4194e4eb 100644
--- a/projects/js-packages/publicize-components/src/social-store/selectors/shares-data.ts
+++ b/projects/js-packages/publicize-components/src/social-store/selectors/shares-data.ts
@@ -1,41 +1,4 @@
import { SocialStoreState } from '../types';
-import settings from './jetpack-settings';
-
-/**
- * Whether the share limit is enabled.
- *
- * @param {SocialStoreState} state - Global state tree
- *
- * @return {boolean} Whether the share limit is enabled
- */
-export function isShareLimitEnabled( state: SocialStoreState ) {
- return state.sharesData?.is_share_limit_enabled ?? false;
-}
-
-/**
- * Whether to show the share limits.
- *
- * @param {SocialStoreState} state - Global state tree
- *
- * @return {boolean} Whether to show the share limits
- */
-export function showShareLimits( state: SocialStoreState ) {
- if ( settings.hasPaidPlan( state ) || state.hasPaidPlan ) {
- return false;
- }
- return isShareLimitEnabled( state );
-}
-
-/**
- * Returns the current share limit.
- *
- * @param {SocialStoreState} state - Global state tree
- *
- * @return {number} Current share limit
- */
-export function getShareLimit( state: SocialStoreState ) {
- return state.sharesData?.share_limit ?? 30;
-}
/**
* Returns the total number of shares already used.
@@ -82,39 +45,3 @@ export function getTotalSharesCount( state: SocialStoreState ) {
export function getSharedPostsCount( state: SocialStoreState ) {
return state.sharesData?.shared_posts_count ?? 0;
}
-
-export type NumberOfSharesRemainingOptions = {
- /**
- * Whether to include scheduled shares
- */
- includeScheduled?: boolean;
-};
-
-/**
- * Returns the number of shares remaining.
- *
- * @param {SocialStoreState} state - Global state tree
- * @param {NumberOfSharesRemainingOptions} options - Options
- *
- * @return {number} Number of shares remaining
- */
-export function numberOfSharesRemaining(
- state: SocialStoreState,
- options: NumberOfSharesRemainingOptions = {}
-) {
- if ( ! showShareLimits( state ) ) {
- return Infinity;
- }
-
- // Allow partial options to be passed in
- const { includeScheduled } = {
- includeScheduled: true,
- ...options,
- };
-
- const sharesUsed = getSharesUsedCount( state );
- const sharesLimit = getShareLimit( state );
- const scheduledShares = includeScheduled ? getScheduledSharesCount( state ) : 0;
-
- return Math.max( sharesLimit - sharesUsed - scheduledShares, 0 );
-}
diff --git a/projects/js-packages/publicize-components/src/social-store/selectors/test/shares-data.test.js b/projects/js-packages/publicize-components/src/social-store/selectors/test/shares-data.test.js
index e10a6e62c1e51..603bdaec779ce 100644
--- a/projects/js-packages/publicize-components/src/social-store/selectors/test/shares-data.test.js
+++ b/projects/js-packages/publicize-components/src/social-store/selectors/test/shares-data.test.js
@@ -1,73 +1,11 @@
import {
getScheduledSharesCount,
- getShareLimit,
getSharedPostsCount,
getSharesUsedCount,
getTotalSharesCount,
- isShareLimitEnabled,
- numberOfSharesRemaining,
- showShareLimits,
} from '../shares-data';
describe( 'Social store selectors: sharesData', () => {
- describe( 'isShareLimitEnabled', () => {
- it( 'should return the default value when no data', () => {
- expect( isShareLimitEnabled( {} ) ).toBe( false );
- expect( isShareLimitEnabled( { sharesData: {} } ) ).toBe( false );
- } );
-
- it( 'should return the value from state', () => {
- expect( isShareLimitEnabled( { sharesData: { is_share_limit_enabled: true } } ) ).toBe(
- true
- );
- expect( isShareLimitEnabled( { sharesData: { is_share_limit_enabled: false } } ) ).toBe(
- false
- );
- } );
- } );
-
- describe( 'showShareLimits', () => {
- it( 'should return the default value when no data', () => {
- expect( showShareLimits( {} ) ).toBe( false );
- expect( showShareLimits( { sharesData: {} } ) ).toBe( false );
- } );
-
- it( 'should fallback to isShareLimitEnabled if there is no paid plan', () => {
- expect( showShareLimits( { sharesData: { is_share_limit_enabled: true } } ) ).toBe( true );
- expect( showShareLimits( { sharesData: { s_share_limit_enabled: false } } ) ).toBe( false );
- } );
-
- it( 'should return false if there is a paid plan', () => {
- expect(
- showShareLimits( {
- sharesData: {
- is_share_limit_enabled: true,
- },
- hasPaidPlan: true,
- } )
- ).toBe( false );
-
- expect(
- showShareLimits( {
- jetpackSettings: { showNudge: false },
- sharesData: { is_share_limit_enabled: true },
- } )
- ).toBe( false );
- } );
- } );
-
- describe( 'getShareLimit', () => {
- it( 'should return the default value when no data', () => {
- expect( getShareLimit( {} ) ).toBe( 30 );
- expect( getShareLimit( { sharesData: {} } ) ).toBe( 30 );
- } );
-
- it( 'should return the value from state', () => {
- expect( getShareLimit( { sharesData: { share_limit: 100 } } ) ).toBe( 100 );
- expect( getShareLimit( { sharesData: { share_limit: 0 } } ) ).toBe( 0 );
- } );
- } );
-
describe( 'getSharesUsedCount', () => {
it( 'should return the default value when no data', () => {
expect( getSharesUsedCount( {} ) ).toBe( 0 );
@@ -132,93 +70,4 @@ describe( 'Social store selectors: sharesData', () => {
expect( getSharedPostsCount( { sharesData: { shared_posts_count: 0 } } ) ).toBe( 0 );
} );
} );
-
- describe( 'numberOfSharesRemaining', () => {
- it( 'should return infinity when share limits are not applied', () => {
- expect( numberOfSharesRemaining( {} ) ).toBe( Infinity );
- expect( numberOfSharesRemaining( { sharesData: { is_share_limit_enabled: false } } ) ).toBe(
- Infinity
- );
- } );
-
- it( 'should return 0 instead of negative number when limits are crossed', () => {
- expect(
- numberOfSharesRemaining( {
- sharesData: {
- is_share_limit_enabled: true,
- publicized_count: 35,
- },
- } )
- ).toBe( 0 );
- } );
-
- const suites = [
- [
- 'should count used and scheduled shares',
- {
- includeScheduled: true,
- },
- [
- {
- sharesUsed: 10,
- scheduledShares: 10,
- result: 10,
- },
- {
- sharesUsed: 20,
- scheduledShares: 10,
- result: 0,
- },
- {
- sharesUsed: 0,
- scheduledShares: 0,
- result: 30,
- },
- ],
- ],
- [
- 'should count used shares but not the scheduled shares',
- {
- includeScheduled: false,
- },
- [
- {
- sharesUsed: 10,
- scheduledShares: 10,
- result: 20,
- },
- {
- sharesUsed: 30,
- scheduledShares: 10,
- result: 0,
- },
- {
- sharesUsed: 0,
- scheduledShares: 0,
- result: 30,
- },
- ],
- ],
- ];
-
- for ( const [ name, args, cases ] of suites ) {
- it( `${ name }`, () => {
- for ( const { sharesUsed, scheduledShares, result } of cases ) {
- expect(
- numberOfSharesRemaining(
- {
- sharesData: {
- is_share_limit_enabled: true,
- publicized_count: sharesUsed,
- to_be_publicized_count: scheduledShares,
- share_limit: 30,
- },
- },
- args
- )
- ).toBe( result );
- }
- } );
- }
- } );
} );
diff --git a/projects/js-packages/publicize-components/src/social-store/types.ts b/projects/js-packages/publicize-components/src/social-store/types.ts
index fa786da610e83..d51b0ae8b88e5 100644
--- a/projects/js-packages/publicize-components/src/social-store/types.ts
+++ b/projects/js-packages/publicize-components/src/social-store/types.ts
@@ -1,7 +1,5 @@
export type SharesData = {
- is_share_limit_enabled: boolean;
to_be_publicized_count: number;
- share_limit: number;
publicized_count: number;
shared_posts_count: number;
};
diff --git a/projects/js-packages/publicize-components/src/types/types.ts b/projects/js-packages/publicize-components/src/types/types.ts
index 255fff7d4fd7d..10abe2931230d 100644
--- a/projects/js-packages/publicize-components/src/types/types.ts
+++ b/projects/js-packages/publicize-components/src/types/types.ts
@@ -39,8 +39,6 @@ type ConnectionDataSelectors = {
type SharesDataSelectors = {
getSharesCount: () => number;
getPostsCount: () => number;
- isShareLimitEnabled: () => boolean;
- numberOfSharesRemaining: () => number;
};
type SiteDataSelectors = {
diff --git a/projects/plugins/social/changelog/update-social-initial-stat-migrate-shares-data b/projects/plugins/social/changelog/update-social-initial-stat-migrate-shares-data
new file mode 100644
index 0000000000000..b1cfb12b7f277
--- /dev/null
+++ b/projects/plugins/social/changelog/update-social-initial-stat-migrate-shares-data
@@ -0,0 +1,4 @@
+Significance: minor
+Type: removed
+
+Social: Removed share limits UI and data logic
diff --git a/projects/plugins/social/src/js/components/admin-page/test/index.test.jsx b/projects/plugins/social/src/js/components/admin-page/test/index.test.jsx
index 2189c3ee6c07f..fe6184c585049 100644
--- a/projects/plugins/social/src/js/components/admin-page/test/index.test.jsx
+++ b/projects/plugins/social/src/js/components/admin-page/test/index.test.jsx
@@ -14,7 +14,6 @@ describe( 'load the app', () => {
renderHook( () => useSelect( select => ( storeSelect = select( SOCIAL_STORE_ID ) ) ) );
jest.spyOn( storeSelect, 'showPricingPage' ).mockReset().mockReturnValue( true );
jest.spyOn( storeSelect, 'hasPaidPlan' ).mockReset().mockReturnValue( true );
- jest.spyOn( storeSelect, 'isShareLimitEnabled' ).mockReset().mockReturnValue( true );
jest.spyOn( storeSelect, 'getPluginVersion' ).mockReset().mockReturnValue( version );
render( );
expect( screen.getByText( `Jetpack Social ${ version }` ) ).toBeInTheDocument();
diff --git a/projects/plugins/social/src/js/components/header/index.js b/projects/plugins/social/src/js/components/header/index.js
index 10604c5dd3db0..8d5678ab91821 100644
--- a/projects/plugins/social/src/js/components/header/index.js
+++ b/projects/plugins/social/src/js/components/header/index.js
@@ -5,14 +5,9 @@ import {
Button,
SocialIcon,
getUserLocale,
- Text,
} from '@automattic/jetpack-components';
import { ConnectionError, useConnectionErrorNotice } from '@automattic/jetpack-connection';
-import {
- ShareLimitsBar,
- store as socialStore,
- useShareLimits,
-} from '@automattic/jetpack-publicize-components';
+import { store as socialStore } from '@automattic/jetpack-publicize-components';
import { getScriptData } from '@automattic/jetpack-script-data';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
@@ -29,7 +24,6 @@ const Header = () => {
newPostUrl,
postsCount,
totalShareCount,
- showShareLimits,
} = useSelect( select => {
const store = select( socialStore );
return {
@@ -39,7 +33,6 @@ const Header = () => {
newPostUrl: `${ store.getAdminUrl() }post-new.php`,
postsCount: store.getSharedPostsCount(),
totalShareCount: store.getTotalSharesCount(),
- showShareLimits: store.showShareLimits(),
};
} );
// TODO - Replace this with a utility function like `getSocialFeatureFlags` when available
@@ -52,8 +45,6 @@ const Header = () => {
compactDisplay: 'short',
} );
- const { noticeType, usedCount, scheduledCount, remainingCount } = useShareLimits();
-
const { openConnectionsModal } = useDispatch( socialStore );
return (
@@ -91,44 +82,22 @@ const Header = () => {
- { showShareLimits ? (
- <>
-
-
-
- { __(
- 'As a free Jetpack Social user, you get 30 shares within every rolling 30-day window.',
- 'jetpack-social'
- ) }
-
-
- >
- ) : (
- ,
- label: __( 'Total shares past 30 days', 'jetpack-social' ),
- loading: null === totalShareCount,
- value: formatter.format( totalShareCount ),
- },
- {
- icon: ,
- label: __( 'Posted this month', 'jetpack-social' ),
- loading: null === postsCount,
- value: formatter.format( postsCount ),
- },
- ] }
- />
- ) }
+ ,
+ label: __( 'Total shares past 30 days', 'jetpack-social' ),
+ loading: null === totalShareCount,
+ value: formatter.format( totalShareCount ),
+ },
+ {
+ icon: ,
+ label: __( 'Posted this month', 'jetpack-social' ),
+ loading: null === postsCount,
+ value: formatter.format( postsCount ),
+ },
+ ] }
+ />
>