Skip to content

Commit

Permalink
Social: Add Social Share status component and cleanup panels (#39049)
Browse files Browse the repository at this point in the history
* Move PostPublishPanels to publicize components

* changelog

* Wrap with ThemeProvider

* Move share status component to postpublish component

* Add feature flag to postpublishShareStatus

* Cleanup ThemeProvider

* Pass targetDom and jsDoc update
  • Loading branch information
gmjuhasz authored Aug 23, 2024
1 parent 487c09a commit 5321148
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Moved PostPublishPanels component to publicize-components package
3 changes: 1 addition & 2 deletions projects/js-packages/publicize-components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export { default as SocialImageGeneratorToggle } from './src/components/social-i
export { default as TemplatePickerButton } from './src/components/social-image-generator/template-picker/button';
export { default as PublicizePanel } from './src/components/panel';
export { default as ReviewPrompt } from './src/components/review-prompt';
export { default as PostPublishReviewPrompt } from './src/components/post-publish-review-prompt';
export { default as PostPublishManualSharing } from './src/components/post-publish-manual-sharing';
export { default as PostPublishPanels } from './src/components/post-publish-panels';
export { default as RefreshJetpackSocialSettingsWrapper } from './src/components/refresh-jetpack-social-settings';
export { default as ConnectionManagement } from './src/components/connection-management';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.wrapper {
margin-top: 1rem;
padding-block: 1rem;
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import usePublicizeConfig from '../../hooks/use-publicize-config';
import useRefreshConnections from '../../hooks/use-refresh-connections';
import { usePostJustPublished } from '../../hooks/use-saving-post';
import useSelectSocialMediaConnections from '../../hooks/use-social-media-connections';
import { store as socialStore } from '../../social-store';
import PublicizeForm from '../form';
import { ManualSharing } from '../manual-sharing';
import { SharePostRow } from '../share-post';
import { ShareStatusModal } from '../share-status-modal';
import styles from './styles.module.scss';
import './global.scss';

Expand All @@ -26,13 +26,6 @@ const PublicizePanel = ( { prePublish, children } ) => {

const { isPublicizeEnabled, hidePublicizeFeature, togglePublicizeFeature } = usePublicizeConfig();

const { featureFlags } = useSelect( select => {
const store = select( socialStore );
return {
featureFlags: store.featureFlags(),
};
}, [] );

// Refresh connections when the post is just published.
usePostJustPublished(
function () {
Expand Down Expand Up @@ -81,8 +74,8 @@ const PublicizePanel = ( { prePublish, children } ) => {
) }
{ isPostPublished && (
<>
<ShareStatusModal />
<ManualSharing />
{ featureFlags?.useShareStatus && 'Share status modal comes here' }
</>
) }
</PanelWrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import { ThemeProvider } from '@automattic/jetpack-components';
import { JetpackEditorPanelLogo } from '@automattic/jetpack-shared-extension-utils';
import { useSelect } from '@wordpress/data';
import { PluginPostPublishPanel } from '@wordpress/edit-post';
import { store as editorStore } from '@wordpress/editor';
import { __ } from '@wordpress/i18n';
import { store as socialStore } from '../../social-store';
import { ManualSharingInfo } from '../manual-sharing/info';
import { ShareButtons } from '../share-buttons/share-buttons';
import styles from './styles.module.scss';
/**
* Post Publish Manual Sharing component.
*
* @return {import('react').ReactNode} Post Publish Manual Sharing component.
* @return {import('react').JSX.Element} Post Publish Manual Sharing component.
*/
export default function PostPublishManualSharing() {
const { isCurrentPostPublished } = useSelect( select => select( editorStore ), [] );

const { featureFlags } = useSelect( select => {
const store = select( socialStore );
return {
featureFlags: store.featureFlags(),
};
}, [] );

if ( ! isCurrentPostPublished() ) {
return null;
}
Expand All @@ -34,11 +25,8 @@ export default function PostPublishManualSharing() {
id="publicize-manual-sharing"
icon={ <JetpackEditorPanelLogo /> }
>
<ThemeProvider>
<ManualSharingInfo className={ styles.description } variant="body-small" />
<ShareButtons />
{ featureFlags?.useShareStatus && 'Share status modal comes here' }
</ThemeProvider>
<ManualSharingInfo className={ styles.description } variant="body-small" />
<ShareButtons />
</PluginPostPublishPanel>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ThemeProvider } from '@automattic/jetpack-components';
import PostPublishManualSharing from '../post-publish-manual-sharing';
import PostPublishReviewPrompt from '../post-publish-review-prompt';
import { PostPublishShareStatus } from '../post-publish-share-status';

const PostPublishPanels = () => {
return (
<ThemeProvider targetDom={ document.body }>
<PostPublishShareStatus />
<PostPublishManualSharing />
<PostPublishReviewPrompt />
</ThemeProvider>
);
};

export default PostPublishPanels;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { usePostStartedPublishing } from '../../hooks/use-saving-post';
import useSocialMediaConnections from '../../hooks/use-social-media-connections';
import ReviewPrompt from '../review-prompt';

const PostPublishReviewPropmpt = () => {
const PostPublishReviewPrompt = () => {
const [ isReviewRequestDismissed, setIsReviewRequestDismissed ] = useState(
getJetpackData()?.social?.reviewRequestDismissed ?? true
);
Expand Down Expand Up @@ -54,4 +54,4 @@ const PostPublishReviewPropmpt = () => {
);
};

export default PostPublishReviewPropmpt;
export default PostPublishReviewPrompt;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useSelect } from '@wordpress/data';
import { PluginPostPublishPanel } from '@wordpress/edit-post';
import { store as socialStore } from '../../social-store';
import { ShareStatusModal } from '../share-status-modal';

/**
* Post publish share status component.
*
* @return {import('react').ReactNode} - Post publish share status component.
*/
export function PostPublishShareStatus() {
const { featureFlags } = useSelect( select => {
const store = select( socialStore );
return {
featureFlags: store.featureFlags(),
};
}, [] );

if ( ! featureFlags.useShareStatus ) {
return null;
}

return (
<PluginPostPublishPanel id="publicize-share-status">
Your post was successfully shared in 4 connections.
<ShareStatusModal />
</PluginPostPublishPanel>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Button } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { store as socialStore } from '../../social-store';
import styles from './styles.module.scss';

/**
* Share status modal component.
*
* @return {import('react').ReactNode} - Share status modal component.
*/
export function ShareStatusModal() {
const { featureFlags } = useSelect( select => {
const store = select( socialStore );
return {
featureFlags: store.featureFlags(),
};
}, [] );

if ( ! featureFlags.useShareStatus ) {
return null;
}

return (
<div className={ styles.wrapper }>
<Button variant="secondary">{ __( 'Review sharing status', 'jetpack' ) }</Button>{ ' ' }
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.wrapper {
margin-top: 1rem;
padding-block: 1rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Moved PostPublishPanels component to publicize-coomponents package
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import {
PublicizePanel,
SocialImageGeneratorPanel,
usePublicizeConfig,
PostPublishPanels,
} from '@automattic/jetpack-publicize-components';
import { useModuleStatus } from '@automattic/jetpack-shared-extension-utils';
import { PostTypeSupportCheck } from '@wordpress/editor';
import JetpackPluginSidebar from '../../shared/jetpack-plugin-sidebar';
import { PublicizePlaceholder } from './components/placeholder';
import PublicizeSkeletonLoader from './components/skeleton-loader';
import UpsellNotice from './components/upsell';
import PostPublishPanels from './post-publish';
import PrePublishPanels from './pre-publish';

import './editor.scss';
Expand Down

This file was deleted.

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

Moved PostPublishPanels component to publicize-components package
6 changes: 2 additions & 4 deletions projects/plugins/social/src/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
usePublicizeConfig,
useSocialMediaConnections,
PublicizePanel,
PostPublishReviewPrompt,
PostPublishManualSharing,
useSyncPostDataToStore,
PostPublishPanels,
} from '@automattic/jetpack-publicize-components';
import { JetpackEditorPanelLogo } from '@automattic/jetpack-shared-extension-utils';
import { PanelBody } from '@wordpress/components';
Expand Down Expand Up @@ -113,8 +112,7 @@ const JetpackSocialSidebar = () => {
<SocialPreviewsPanel openModal={ openModal } />
</PluginPrePublishPanel>

<PostPublishManualSharing />
<PostPublishReviewPrompt />
<PostPublishPanels />
</PostTypeSupportCheck>
);
};

0 comments on commit 5321148

Please sign in to comment.