diff --git a/projects/packages/account-protection/src/class-settings.php b/projects/packages/account-protection/src/class-settings.php index 6e0f771b63511..51ffa48b5aa0f 100644 --- a/projects/packages/account-protection/src/class-settings.php +++ b/projects/packages/account-protection/src/class-settings.php @@ -7,26 +7,24 @@ namespace Automattic\Jetpack\Account_Protection; -use Automattic\Jetpack\Modules; - /** * Account Protection Settings */ class Settings { /** - * Modules instance. + * Account Protection instance. * - * @var Modules|null + * @var Account_Protection */ - private $modules; + private $account_protection; /** - * Constructor. + * Constructor for dependency injection. * - * @param Modules|null $modules Modules instance. + * @param ?Account_Protection|null $account_protection Account protection dependency. */ - public function __construct( ?Modules $modules = null ) { - $this->modules = $modules ?? new Modules(); + public function __construct( ?Account_Protection $account_protection = null ) { + $this->account_protection = $account_protection ?? new Account_Protection(); } /** @@ -35,11 +33,11 @@ public function __construct( ?Modules $modules = null ) { * @return array */ public function get() { - $account_protection = new Account_Protection( $this->modules ); - - return array( - 'isEnabled' => $account_protection->is_enabled(), - 'isSupported' => $account_protection->is_supported_environment(), + $settings = array( + 'isEnabled' => $this->account_protection->is_enabled(), + 'isSupported' => $this->account_protection->is_supported_environment(), ); + + return $settings; } } diff --git a/projects/packages/account-protection/tests/php/test-settings.php b/projects/packages/account-protection/tests/php/test-settings.php index a9bc6b26b1944..267c8fd516c05 100644 --- a/projects/packages/account-protection/tests/php/test-settings.php +++ b/projects/packages/account-protection/tests/php/test-settings.php @@ -10,17 +10,18 @@ */ class Settings_Test extends BaseTestCase { public function test_base_case() { - $modules_mock = $this->createMock( Modules::class ); - $modules_mock->expects( $this->once() ) - ->method( 'is_active' ) - ->willReturn( true ); + $modules_mock = $this->createMock( Modules::class ); + $modules_mock->expects( $this->once() ) + ->method( 'is_active' ) + ->with( Account_Protection::ACCOUNT_PROTECTION_MODULE_NAME ) + ->willReturn( true ); - $modules_mock->expects( $this->never() ) - ->method( 'activate' ); + $modules_mock->expects( $this->never() ) + ->method( 'activate' ); - $settings = ( new Settings( $modules_mock ) )->get(); + $settings = ( new Settings( new Account_Protection( $modules_mock ) ) )->get(); - $this->assertTrue( $settings['isSupported'] ); - $this->assertTrue( $settings['isEnabled'] ); + $this->assertTrue( $settings['isSupported'] ); + $this->assertTrue( $settings['isEnabled'] ); } } diff --git a/projects/plugins/protect/src/js/routes/settings/index.jsx b/projects/plugins/protect/src/js/routes/settings/index.jsx index 1820a3c9386e2..34e09cea141dd 100644 --- a/projects/plugins/protect/src/js/routes/settings/index.jsx +++ b/projects/plugins/protect/src/js/routes/settings/index.jsx @@ -4,6 +4,8 @@ import { Text, ToggleControl, AdminSectionHero, + Notice, + Button, } from '@automattic/jetpack-components'; import { createInterpolateElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; @@ -42,16 +44,39 @@ const SettingsPage = () => {
- - { __( 'Account protection', 'jetpack-protect' ) } - - + { __( 'Account protection', 'jetpack-protect' ) } + { ! accountProtection.isSupported && ( + + { __( + 'This feature has been disabled by your site administrator or hosting provider.', + 'jetpack-protect' + ) } + + } + actions={ [ + , + ] } + /> + ) } + { createInterpolateElement( __( 'Enabling this setting enhances account security by detecting compromised passwords and enforcing additional verification when needed. Learn more about how this protects your site.', @@ -62,18 +87,18 @@ const SettingsPage = () => { } ) } - + { __( 'Protect your site with advanced password detection and profile management protection.', 'jetpack-protect' ) } - { ! accountProtection.isEnabled && ( + { ! accountProtection.isEnabled && accountProtection.isSupported && ( { createInterpolateElement( __( - 'Jetpack recommends activating this setting. Please be mindful of the risks.', + 'Jetpack recommends enabling this feature. Learn about the risks.', 'jetpack-protect' ), { diff --git a/projects/plugins/protect/src/js/routes/settings/styles.module.scss b/projects/plugins/protect/src/js/routes/settings/styles.module.scss index 8fd4cb29ea9a2..a3eccb4768f89 100644 --- a/projects/plugins/protect/src/js/routes/settings/styles.module.scss +++ b/projects/plugins/protect/src/js/routes/settings/styles.module.scss @@ -21,6 +21,9 @@ &__content { width: 100%; + display: flex; + flex-direction: column; + gap: calc( var( --spacing-base ) * 2 ); // 16px } &__description,