-
-
- { name }
-
- { description }
-
-
- { badge }
-
+
+ { isOn ? (
+
+
+
+ { __( 'Configure brute force protection', 'jetpack-protect-pkg' ) }
+
+
+ ) : (
+
+ ) }
+
);
}
/**
- * The card badge's intent: neutral when no method is available.
- *
- * @param on - How many methods are on.
- * @param available - How many methods are available.
- * @return The intent.
- */
-function getStatusIntent( on: number, available: number ): CardStatus[ 'intent' ] {
- if ( available === 0 ) {
- return 'none';
- }
- return on === available ? 'stable' : 'medium';
-}
-
-/**
- * The Login protection card: brute force protection, account protection and WordPress.com login.
+ * The Login protection card: blocked logins, and toggles for account protection and WordPress.com login.
*
* @param props - The dashboard context.
* @param props.state - This section's state from PHP.
* @param props.settings - Jetpack settings, for live module state.
- * @param props.openTab - Switches dashboard tabs, for the link to Settings.
+ * @param props.openTab - Switches dashboard tabs, for the links to Settings.
* @return The card, or nothing without the section's state.
*/
export default function LoginProtectionCard( {
@@ -82,69 +102,62 @@ export default function LoginProtectionCard( {
return null;
}
- const live = ( module: string, initial: ModuleState ): ModuleState => ( {
- available: initial.available,
- active: isModuleActive( settings.settings, module, initial.active ),
- } );
- const bruteForce = live( 'protect', login.bruteForce );
- const accountProtection = live( 'account-protection', login.accountProtection );
- // The module can stay active after the owner disconnects, but WordPress.com login doesn't run then.
- const sso = live( 'sso', { ...login.sso, available: login.sso.available && login.ssoUsable } );
-
- const methods = [ bruteForce, accountProtection, sso ];
- const on = methods.filter( method => method.available && method.active ).length;
- const available = methods.filter( method => method.available ).length;
+ // Settings load on the Settings tab; until then the toggles show the page-load state.
+ const data = {
+ ...settings,
+ settings: {
+ protect: login.bruteForce.active,
+ 'account-protection': login.accountProtection.active,
+ sso: login.sso.active,
+ ...settings.settings,
+ },
+ };
+ const ssoOn = Boolean( data.settings.sso ) && getSsoBlocker( login ) === null;
return (