Skip to content
Closed
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
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

4 changes: 0 additions & 4 deletions projects/js-packages/components/changelog/pr-47345

This file was deleted.

4 changes: 0 additions & 4 deletions projects/js-packages/components/changelog/pr-47361

This file was deleted.

4 changes: 0 additions & 4 deletions projects/js-packages/components/changelog/pr-47388

This file was deleted.

This file was deleted.

This file was deleted.

75 changes: 13 additions & 62 deletions projects/js-packages/components/components/admin-page/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import restApi from '@automattic/jetpack-api';
import { Page } from '@wordpress/admin-ui';
import '@wordpress/admin-ui/build-style/style.css';
import {
__experimentalHeading as Heading, // eslint-disable-line @wordpress/no-unsafe-wp-apis
__experimentalHStack as HStack, // eslint-disable-line @wordpress/no-unsafe-wp-apis
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import clsx from 'clsx';
import { useEffect, useCallback } from 'react';
Expand All @@ -27,7 +21,7 @@ import type { FC, ReactNode } from 'react';
const AdminPage: FC< AdminPageProps > = ( {
children,
className,
moduleName = 'Jetpack' /** "Jetpack" is a product name, do not translate. */,
moduleName = __( 'Jetpack', 'jetpack-components' ),
moduleNameHref,
showHeader = true,
showFooter = true,
Expand All @@ -38,11 +32,6 @@ const AdminPage: FC< AdminPageProps > = ( {
apiNonce = '',
optionalMenuItems,
header,
title,
subTitle,
logo,
actions,
tabs,
} ) => {
useEffect( () => {
restApi.setApiRoot( apiRoot );
Expand Down Expand Up @@ -71,55 +60,6 @@ const AdminPage: FC< AdminPageProps > = ( {
}
}, [] );

// Compose the title with logo for the admin-ui Page header.
// Note: The inner Heading causes a double h2 wrapping because Page's Header
// also wraps title in a Heading. This is a known issue — the inner Heading is
// needed until https://github.com/WordPress/gutenberg/pull/75899 fixes
// non-string title rendering in admin-ui. Once that lands, remove the Heading
// here and pass the plain HStack with a string child.
const composedTitle = title ? (
<HStack spacing={ 2 } justify="left">
{ logo || <JetpackLogo showText={ false } height={ 20 } /> }
<Heading as="h2" level={ 3 } weight={ 500 } truncate>
{ title }
</Heading>
</HStack>
) : undefined;

const footer = showFooter && (
<Container horizontalSpacing={ 5 }>
<Col>
<JetpackFooter
moduleName={ moduleName }
moduleNameHref={ moduleNameHref }
menu={ optionalMenuItems }
useInternalLinks={ useInternalLinks }
/>
</Col>
</Container>
);

// When title is provided, use admin-ui Page for the full page layout.
if ( showHeader && composedTitle ) {
return (
<div className={ rootClassName }>
<Page
title={ composedTitle }
subTitle={ subTitle }
actions={ actions }
showSidebarToggle={ false }
>
{ tabs }
<Container fluid horizontalSpacing={ 0 }>
<Col>{ children }</Col>
</Container>
{ footer }
</Page>
</div>
);
}

// Legacy path: no title provided, render the classic header.
return (
<div className={ rootClassName }>
{ showHeader && (
Expand All @@ -145,7 +85,18 @@ const AdminPage: FC< AdminPageProps > = ( {
<Container fluid horizontalSpacing={ 0 }>
<Col>{ children }</Col>
</Container>
{ footer }
{ showFooter && (
<Container horizontalSpacing={ 5 }>
<Col>
<JetpackFooter
moduleName={ moduleName }
moduleNameHref={ moduleNameHref }
menu={ optionalMenuItems }
useInternalLinks={ useInternalLinks }
/>
</Col>
</Container>
) }
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@
background-color: var(--jp-white);
}

// Remove the admin-ui header border. Scoped to .admin-page so this only
// applies within our component. Ideally admin-ui would expose a prop or
// CSS custom property for this — revisit if the upstream API changes.
:global(.admin-ui-page__header) {
border-bottom: none;
position: relative;
}

// Normalize admin headers: implementation of admin-ui needs to
// comprehend old wp-admin floating containers, such as Hello Dolly.
:global(.admin-ui-page) {
clear: both;
}

.admin-page-header {
display: flex;
align-items: center;
Expand All @@ -40,8 +26,3 @@
color: #fff;
}
}

// Make Hello Dolly background white for Jetpack admin pages.
:global(.jetpack-admin-page #dolly) {
background-color: #fff;
}
29 changes: 1 addition & 28 deletions projects/js-packages/components/components/admin-page/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,10 @@ export type AdminPageProps = {
showHeader?: boolean;

/**
* Custom header. Optional.
* @deprecated Use `title` and `subTitle` props instead for the unified header.
* Custom header. Optional
*/
header?: ReactNode;

/**
* Product title displayed in the unified header (e.g. "Social", "Backup").
* When provided, renders the admin-ui Page header instead of the legacy header slot.
*/
title?: string;

/**
* Optional tagline displayed below the title in the unified header.
*/
subTitle?: string;

/**
* Custom logo element for the unified header. Defaults to JetpackLogo icon.
*/
logo?: ReactNode;

/**
* Action elements displayed on the right side of the unified header.
*/
actions?: ReactNode;

/**
* Tab navigation displayed below the title/tagline in the unified header.
*/
tabs?: ReactNode;

/**
* Whether or not to display the Footer
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ExternalIcon: FC = () => (
* @return {ReactNode} JetpackFooter component.
*/
const JetpackFooter: FC< JetpackFooterProps > = ( {
moduleName = 'Jetpack' /** "Jetpack" is a product name, do not translate. */,
moduleName = __( 'Jetpack', 'jetpack-components' ),

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

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

This changes the default moduleName from an explicitly non-translatable product name (per the prior inline comment) to a translatable string. If “Jetpack” is intended to remain a brand/product name, keep it non-translated and rely on translator comments where needed; otherwise the UI may end up showing localized brand text inconsistently across products.

Suggested change
moduleName = __( 'Jetpack', 'jetpack-components' ),
moduleName = 'Jetpack',

Copilot uses AI. Check for mistakes.
className,
moduleNameHref = 'https://jetpack.com',
menu,
Expand Down
1 change: 0 additions & 1 deletion projects/js-packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"@automattic/jetpack-script-data": "workspace:*",
"@automattic/number-formatters": "workspace:*",
"@babel/runtime": "^7",
"@wordpress/admin-ui": "1.8.0",
"@wordpress/browserslist-config": "6.40.0",
"@wordpress/components": "32.2.0",
"@wordpress/compose": "7.40.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function main() {
return;
}

for await ( const filePath of fs.glob( '**/*.{scss,css}', {
for await ( const filePath of fs.glob( '**/*.scss', {
cwd: packageRoot,
exclude: Array.from( IGNORED_DIRS, dir => `**/${ dir }/**` ),
} ) ) {
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions projects/js-packages/webpack-config/src/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ const defaultRequestMap = {
external: 'JetpackConnection',
handle: 'jetpack-connection',
},
// Bundle admin-ui CSS with our assets. The JS side is already handled by the
// DependencyExtractionPlugin's BUNDLED_PACKAGES list, but the CSS subpath import
// doesn't match that exact-match check and would be incorrectly externalized.
'@wordpress/admin-ui/build-style/style.css': {
external: false,
},
};

const DependencyExtractionPlugin = ( { requestMap, ...options } = {} ) => {
Expand Down
3 changes: 0 additions & 3 deletions projects/js-packages/webpack-config/src/webpack/css-rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ const CssRule = ( options = {} ) => {
'\\.(?:' + exts.map( ext => ext.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' ) ).join( '|' ) + ')$',
'i'
),
// CSS imports are always side effects (they inject styles into the DOM),
// so override any package.json "sideEffects: false" declarations.
sideEffects: true,
use: [
MiniCssExtractLoader( options.MiniCssExtractLoader ),
CssLoader( {
Expand Down

This file was deleted.

81 changes: 81 additions & 0 deletions projects/packages/backup/src/js/components/Admin/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { JetpackVaultPressBackupLogo } from '@automattic/jetpack-components';
import { useSelect } from '@wordpress/data';
import { createInterpolateElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { useMemo } from 'react';
import useCapabilities from '../../hooks/useCapabilities';
import useConnection from '../../hooks/useConnection';
import { STORE_ID } from '../../store';
import { useShowBackUpNow } from '../back-up-now/hooks';
import { BackupNowButton } from '../back-up-now/index';
import { useIsFullyConnected } from './hooks';

const Header = () => {
const showActivateLicenseLink = useShowActivateLicenseLink();
const showBackUpNowButton = useShowBackUpNow();

return (
<div className="jetpack-admin-page__header">
<span className="jetpack-admin-page__logo">
<JetpackVaultPressBackupLogo />
</span>
{ showActivateLicenseLink && <ActivateLicenseLink /> }
{ showBackUpNowButton && (
<BackupNowButton variant="primary" tracksEventName="jetpack_backup_plugin_backup_now">
{ __( 'Back up now', 'jetpack-backup-pkg' ) }
</BackupNowButton>
) }
</div>
);
};

const useShowActivateLicenseLink = () => {
const connectionStatus = useConnection();
const isFullyConnected = useIsFullyConnected();
const { capabilitiesLoaded, hasBackupPlan } = useCapabilities();

// Give people a chance to activate a license if they're not fully connected,
// OR if they have a full user connection but no Backup capabilities
return useMemo( () => {
// At least wait until we know the status of the site and user connections
const connectionLoaded = Object.keys( connectionStatus ).length > 0;
if ( ! connectionLoaded ) {
return false;
}

if ( ! isFullyConnected ) {
return true;
}

// Even if we're fully connected, wait until we know the site's capabilities
// before deciding to show an activation link
if ( ! capabilitiesLoaded ) {
return false;
}

return ! hasBackupPlan;
}, [ connectionStatus, isFullyConnected, hasBackupPlan, capabilitiesLoaded ] );
};

const ActivateLicenseLink = () => {
const activateLicenseUrl = useSelect( select => {
const wpAdminUrl = select( STORE_ID ).getSiteData().adminUrl;
return `${ wpAdminUrl }admin.php?page=my-jetpack#/add-license`;
}, [] );

return (
<p>
{ createInterpolateElement(
__(
'Already have an existing plan or license key? <a>Click here to get started</a>',
'jetpack-backup-pkg'
),
{
a: <a href={ activateLicenseUrl } />,
}
) }
</p>
);
};

export default Header;
Loading
Loading