Skip to content
Merged
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
@@ -1,5 +1,5 @@
import { ActionButton, Notice } from '@automattic/jetpack-components';
import { __ } from '@wordpress/i18n';
import { Notice } from '@wordpress/ui';
import PropTypes from 'prop-types';
import { Component } from 'react';
import { connect } from 'react-redux';
Expand All @@ -12,26 +12,23 @@ export class ConnectionBanner extends Component {
from: PropTypes.string,
};

handleClick() {
handleClick = () => {
this.props.doConnectUser( null, this.props.from );
}
};

render() {
const { description, title } = this.props;

const connectButtonProps = {
label: __( 'Connect your WordPress.com account', 'jetpack' ),
onClick: () => this.handleClick(),
};

return (
<Notice
title={ title }
hideCloseButton
actions={ [ <ActionButton key="connect" { ...connectButtonProps } /> ] }
>
{ description }
</Notice>
<Notice.Root intent="info">
<Notice.Title>{ title }</Notice.Title>
<Notice.Description>{ description }</Notice.Description>
<Notice.Actions>
<Notice.ActionButton onClick={ this.handleClick }>
{ __( 'Connect your WordPress.com account', 'jetpack' ) }
</Notice.ActionButton>
</Notice.Actions>
</Notice.Root>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ describe( 'ConnectionBanner', () => {
};

describe( 'Initially', () => {
it( 'does not pass any properties to ConnectButton', () => {
it( 'renders the connect action button', () => {
render( <ConnectionBanner { ...testProps } /> );
const button = screen.getByLabelText( 'Connect your WordPress.com account' );
const button = screen.getByRole( 'button', {
name: 'Connect your WordPress.com account',
} );
expect( button ).toBeInTheDocument();
} );
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Internal: migrate the connection banner Notice to @wordpress/ui.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Internal: migrate Notice usages to @wordpress/ui.
30 changes: 13 additions & 17 deletions projects/plugins/protect/src/js/routes/firewall/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
ToggleControl,
ContextualUpgradeTrigger,
useBreakpointMatch,
Notice as JetpackNotice,
} from '@automattic/jetpack-components';
import { Popover } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { Icon, closeSmall } from '@wordpress/icons';
import { Notice } from '@wordpress/ui';
import moment from 'moment';
import { useCallback, useEffect, useState, useMemo } from 'react';
import Textarea from '../../components/textarea';
Expand Down Expand Up @@ -221,23 +221,19 @@ const FirewallPage = () => {
* Module Disabled Notice
*/
const moduleDisabledNotice = (
<JetpackNotice
level="error"
title="Jetpack Firewall is currently disabled."
children={ <Text>{ __( 'Re-enable the Firewall to continue.', 'jetpack-protect' ) }</Text> }
actions={ [
<Button
key="enable"
variant="link"
onClick={ toggleWaf }
isLoading={ isToggling }
disabled={ isToggling }
>
<Notice.Root intent="error">
<Notice.Title>
{ __( 'Jetpack Firewall is currently disabled.', 'jetpack-protect' ) }
</Notice.Title>
<Notice.Description>
<Text>{ __( 'Re-enable the Firewall to continue.', 'jetpack-protect' ) }</Text>
</Notice.Description>
<Notice.Actions>
<Notice.ActionButton onClick={ toggleWaf } loading={ isToggling } disabled={ isToggling }>
{ __( 'Enable Firewall', 'jetpack-protect' ) }
</Button>,
] }
hideCloseButton={ true }
/>
</Notice.ActionButton>
</Notice.Actions>
</Notice.Root>
);

/**
Expand Down
69 changes: 27 additions & 42 deletions projects/plugins/protect/src/js/routes/settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {
Text,
ToggleControl,
AdminSectionHero,
Notice,
Button,
getRedirectUrl,
} from '@automattic/jetpack-components';
import { ExternalLink } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Icon, info } from '@wordpress/icons';
import { Notice } from '@wordpress/ui';
import { useCallback } from 'react';
import useAccountProtectionQuery from '../../data/account-protection/use-account-protection-query';
import useToggleAccountProtectionMutation from '../../data/account-protection/use-toggle-account-protection-module-mutation';
Expand Down Expand Up @@ -61,58 +60,44 @@ const SettingsPage = () => {
<div className={ styles[ 'toggle-section__content' ] }>
<Text variant="title-medium">{ __( 'Account protection', 'jetpack-protect' ) }</Text>
{ ! accountProtection.isSupported && (
<Notice
level="warning"
hideCloseButton={ true }
className={ styles[ 'toggle-section__alert' ] }
title={
<Text>
{ __(
'This feature has been disabled by your site administrator or hosting provider.',
'jetpack-protect'
) }
</Text>
}
actions={ [
<Button
variant="link"
isExternalLink
<Notice.Root intent="warning" className={ styles[ 'toggle-section__alert' ] }>
<Notice.Title>
{ __(
'This feature has been disabled by your site administrator or hosting provider.',
'jetpack-protect'
) }
</Notice.Title>
<Notice.Actions>
<Notice.ActionLink
href={ getRedirectUrl( 'jetpack-account-protection', {
anchor: 'unsupported-environments',
} ) }
key="learn-more"
openInNewTab
>
{ __( 'Learn more', 'jetpack-protect' ) }
</Button>,
] }
/>
</Notice.ActionLink>
</Notice.Actions>
</Notice.Root>
) }
{ accountProtection.isSupported && accountProtection.hasUnsupportedJetpackVersion && (
<Notice
level="warning"
hideCloseButton={ true }
className={ styles[ 'toggle-section__alert' ] }
title={
<Text>
{ __(
'This feature has been disabled because the Jetpack Protect plugin is installed with an unsupported version of the Jetpack plugin. Please update the Jetpack plugin to version 14.5 or later to enable this feature.',
'jetpack-protect'
) }
</Text>
}
actions={ [
<Button
variant="link"
isExternalLink
<Notice.Root intent="warning" className={ styles[ 'toggle-section__alert' ] }>
<Notice.Title>
{ __(
'This feature has been disabled because the Jetpack Protect plugin is installed with an unsupported version of the Jetpack plugin. Please update the Jetpack plugin to version 14.5 or later to enable this feature.',
'jetpack-protect'
) }
</Notice.Title>
<Notice.Actions>
<Notice.ActionLink
href={ getRedirectUrl( 'jetpack-account-protection', {
anchor: 'requirements',
} ) }
key="learn-more"
openInNewTab
>
{ __( 'Learn more', 'jetpack-protect' ) }
</Button>,
] }
/>
</Notice.ActionLink>
</Notice.Actions>
</Notice.Root>
) }
<Text className={ styles[ 'toggle-section__description' ] }>
{ createInterpolateElement(
Expand Down
Loading