Repository navigation
Revert "Normalize admin page headers with unified AdminHeader wrapping @wordpress/admin-ui" #47411
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the default
moduleNamefrom 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.