Skip to content
Open
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
Expand Up @@ -189,30 +189,35 @@ export default function MyJetpackScreen() {
<h1 className="screen-reader-text">{ __( 'My Jetpack', 'jetpack-my-jetpack' ) }</h1>

<IDCModal />
<GlobalNotices />
{ ! isNewUser && (
<Container horizontalSpacing={ 0 }>
<Col>
<div id="jp-admin-notices" className="my-jetpack-jitm-card" />
</Col>
</Container>
) }
{ noticeMessage && (
<Container horizontalSpacing={ 3 } horizontalGap={ 3 }>
<Col>
<GlobalNotice
message={ noticeMessage }
title={ noticeTitle }
options={ noticeOptions }
/>
</Col>
</Container>
) }
{ isSectionVisible && userIsAdmin && <EvaluationRecommendations /> }

{ isRedirectingFromOnboarding && <OnboardingTour /> }

<MyJetpackTabPanel />
<MyJetpackTabPanel
beforeContent={
<>
<GlobalNotices />
{ ! isNewUser && (
<Container horizontalSpacing={ 0 }>
<Col>
<div id="jp-admin-notices" className="my-jetpack-jitm-card" />
</Col>
</Container>
) }
{ noticeMessage && (
<Container horizontalSpacing={ 3 } horizontalGap={ 3 }>
<Col>
<GlobalNotice
message={ noticeMessage }
title={ noticeTitle }
options={ noticeOptions }
/>
</Col>
</Container>
) }
</>
}
/>
</AdminPage>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ import { useNavigate, useParams } from 'react-router';
import useAnalytics from '../../hooks/use-analytics';
import useIsJetpackUserNew from '../../hooks/use-is-jetpack-user-new';
import { MY_JETPACK_SECTION_OVERVIEW } from './constants';
import { FullWidthSeparator } from './full-width-separator';
import styles from './styles.module.scss';
import { TabContent } from './tab-content';
import { MyJetpackSection } from './types';
import { getMyJetpackSections, isValidMyJetpackSection } from './utils';
import type { ReactNode } from 'react';

/**
* My Jetpack Tab panel component.
*
* @param {object} root0 - Component props.
* @param {ReactNode} root0.beforeContent - Content to render between the tab separator and tab content.
* @return The rendered component.
*/
export function MyJetpackTabPanel() {
export function MyJetpackTabPanel( { beforeContent }: { beforeContent?: ReactNode } ) {
const params = useParams();
const navigate = useNavigate();
const { recordEvent } = useAnalytics();
Expand Down Expand Up @@ -55,9 +59,18 @@ export function MyJetpackTabPanel() {
[ navigate, params.section, recordEvent, isNewUser ]
);

const tabRenderer = useCallback( ( tab: { name: string } ) => {
return <TabContent name={ tab.name as MyJetpackSection } />;
}, [] );
const tabRenderer = useCallback(
( tab: { name: string } ) => {
return (
<>
<FullWidthSeparator />
{ beforeContent }
<TabContent name={ tab.name as MyJetpackSection } />
</>
);
},
[ beforeContent ]
);

// Handle external navigation (URL changes not from tab clicks)
useEffect( () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import clsx from 'clsx';
import { FullWidthSeparator } from './full-width-separator';
import { HelpContent } from './help/content';
import { OverviewContent } from './overview/content';
import { ProductsContent } from './products/content';
Expand Down Expand Up @@ -33,7 +32,6 @@ export function TabContent( { name }: TabContentProps ) {

return (
<div className={ styles[ 'my-jetpack-tab-panel-inner' ] }>
<FullWidthSeparator />
<div className={ clsx( styles[ 'tab-content-wrapper' ] ) }>
<ContentComponent />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Move admin notices and JITMs below the tab bar instead of rendering inside the page header.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Button, Col, Container, H3 } from '@automattic/jetpack-components';
import { ConnectionError, useConnectionErrorNotice } from '@automattic/jetpack-connection';
import { getAdminUrl } from '@automattic/jetpack-script-data';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
Expand All @@ -15,41 +14,27 @@ const Header = () => {
};
} );

const { hasConnectionError } = useConnectionErrorNotice();

const { openConnectionsModal } = useDispatch( socialStore );

return (
<>
<Container horizontalSpacing={ 0 }>
{ hasConnectionError && (
<Col className={ styles[ 'connection-error-col' ] }>
<ConnectionError />
</Col>
) }
<Col>
<div id="jp-admin-notices" className="jetpack-social-jitm-card" />
</Col>
</Container>
<Container horizontalSpacing={ 3 } horizontalGap={ 3 } className={ styles.container }>
<Col sm={ 4 } md={ 4 } lg={ 5 }>
<H3 mt={ 2 }>{ __( 'Write once, post everywhere', 'jetpack-publicize-pkg' ) }</H3>
<div className={ styles.actions }>
{ isModuleEnabled && ! hasConnections && (
<Button onClick={ openConnectionsModal }>
{ __( 'Connect accounts', 'jetpack-publicize-pkg' ) }
</Button>
) }
<Button
href={ getAdminUrl( 'post-new.php' ) }
variant={ hasConnections ? 'primary' : 'secondary' }
>
{ __( 'Write a post', 'jetpack-publicize-pkg' ) }
<Container horizontalSpacing={ 3 } horizontalGap={ 3 } className={ styles.container }>
<Col sm={ 4 } md={ 4 } lg={ 5 }>
<H3 mt={ 2 }>{ __( 'Write once, post everywhere', 'jetpack-publicize-pkg' ) }</H3>
<div className={ styles.actions }>
{ isModuleEnabled && ! hasConnections && (
<Button onClick={ openConnectionsModal }>
{ __( 'Connect accounts', 'jetpack-publicize-pkg' ) }
</Button>
</div>
</Col>
</Container>
</>
) }
<Button
href={ getAdminUrl( 'post-new.php' ) }
variant={ hasConnections ? 'primary' : 'secondary' }
>
{ __( 'Write a post', 'jetpack-publicize-pkg' ) }
</Button>
</div>
</Col>
</Container>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@
}
}

.connection-error-col {
margin-top: 25px;
}

.bar-wrapper {
margin-bottom: var(--spacing-base);

Expand Down
29 changes: 27 additions & 2 deletions projects/packages/publicize/_inc/components/admin-page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
Col,
GlobalNotices,
} from '@automattic/jetpack-components';
import { useConnection } from '@automattic/jetpack-connection';
import {
ConnectionError,
useConnection,
useConnectionErrorNotice,
} from '@automattic/jetpack-connection';
import {
getMyJetpackUrl,
isJetpackSelfHostedSite,
Expand All @@ -25,7 +29,7 @@ import ConnectionScreen from './connection-screen';
import Header from './header';
import InfoSection from './info-section';
import PricingPage from './pricing-page';
import './styles.module.scss';
import styles from './styles.module.scss';
import SupportSection from './support-section';
import SocialImageGeneratorToggle from './toggles/social-image-generator-toggle';
import SocialModuleToggle from './toggles/social-module-toggle';
Expand All @@ -38,6 +42,7 @@ export const SocialAdminPage = () => {
const isJetpackSite = isJetpackSelfHostedSite();

const { isUserConnected, isRegistered } = useConnection();
const { hasConnectionError } = useConnectionErrorNotice();
const showConnectionCard = ! isSimple && ( ! isRegistered || ! isUserConnected );

const [ pricingPageDismissed, setPricingPageDismissed ] = useState( false );
Expand Down Expand Up @@ -101,6 +106,16 @@ export const SocialAdminPage = () => {
<GlobalNotices />
{ isJetpackSite && ! hasSocialPaidFeatures() && showPricingPage && ! pricingPageDismissed ? (
<AdminSectionHero>
<Container horizontalSpacing={ 0 }>
{ hasConnectionError && (
<Col className={ styles[ 'connection-error-col' ] }>
<ConnectionError />
</Col>
) }
<Col>
<div id="jp-admin-notices" className="jetpack-social-jitm-card" />
</Col>
</Container>
<Container horizontalSpacing={ 3 } horizontalGap={ 3 }>
<Col>
<PricingPage onDismiss={ onPricingPageDismiss } />
Expand All @@ -112,6 +127,16 @@ export const SocialAdminPage = () => {
<AdminSectionHero>
<Header />
</AdminSectionHero>
<Container horizontalSpacing={ 0 }>
{ hasConnectionError && (
<Col className={ styles[ 'connection-error-col' ] }>
<ConnectionError />
</Col>
) }
<Col>
<div id="jp-admin-notices" className="jetpack-social-jitm-card" />
</Col>
</Container>
<AdminSection>
<SocialModuleToggle />
{ canManageOptions && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
.notice {
grid-column: 1 / -1;
}

.connection-error-col {
margin-top: 25px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Move admin notices and JITMs below the page header instead of rendering inside it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Move admin notices and JITMs below the page header instead of rendering inside it.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export default function DashboardPage( { isLoading = false } ) {

return (
<>
{ /* Always in the DOM so JITM JS finds it immediately (Path A). */ }
<div id="jp-admin-notices" className="jetpack-search-jitm-card" />
{ isPageLoading && <Loading /> }
{ ! isPageLoading && (
<div className="jp-search-dashboard-page">
Expand All @@ -126,20 +128,17 @@ export default function DashboardPage( { isLoading = false } ) {
className="uses-new-admin-ui"
showFooter={ false }
>
<Container horizontalSpacing={ 0 } horizontalGap={ 3 }>
{ hasConnectionError && (
<Col lg={ 12 } md={ 12 } sm={ 12 }>
<ConnectionError />
</Col>
) }
<Col>
<div id="jp-admin-notices" className="jetpack-search-jitm-card" />
</Col>
</Container>
<MockedSearchInterface
supportsInstantSearch={ supportsInstantSearch }
supportsOnlyClassicSearch={ supportsOnlyClassicSearch }
/>
{ hasConnectionError && (
<Container horizontalSpacing={ 0 } horizontalGap={ 3 }>
<Col lg={ 12 } md={ 12 } sm={ 12 }>
<ConnectionError />
</Col>
</Container>
) }
{ isNewPricing && supportsInstantSearch && (
<PlanInfo
hasIndex={ postCount !== 0 }
Expand Down
Loading