From 027dc558b92b6202a1115709fe6c32f3dfe3b758 Mon Sep 17 00:00:00 2001 From: Bryan Elliott Date: Fri, 19 Jul 2024 14:42:31 -0400 Subject: [PATCH] Protect card: Add the number of Logins Blocked. (#38396) --- .../protect-card/protect-value-section.tsx | 11 ++++++++++- .../add-mj-protect-card-logins-blocked-status | 4 ++++ projects/packages/my-jetpack/global.d.ts | 1 + .../packages/my-jetpack/src/class-initializer.php | 5 ++++- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 projects/packages/my-jetpack/changelog/add-mj-protect-card-logins-blocked-status diff --git a/projects/packages/my-jetpack/_inc/components/product-cards-section/protect-card/protect-value-section.tsx b/projects/packages/my-jetpack/_inc/components/product-cards-section/protect-card/protect-value-section.tsx index f6bfc28c672ff..79a0b50099b2b 100644 --- a/projects/packages/my-jetpack/_inc/components/product-cards-section/protect-card/protect-value-section.tsx +++ b/projects/packages/my-jetpack/_inc/components/product-cards-section/protect-card/protect-value-section.tsx @@ -113,10 +113,19 @@ const ValueSection: FC< {
Logins Blocked
-
0
+
); }; + +const LoginsBlockedStatus = () => { + const { + protect: { wafConfig: wafData }, + } = getMyJetpackWindowInitialState(); + const { blocked_logins: blockedLoginsCount = 0 } = wafData || {}; + + return
{ blockedLoginsCount }
; +}; diff --git a/projects/packages/my-jetpack/changelog/add-mj-protect-card-logins-blocked-status b/projects/packages/my-jetpack/changelog/add-mj-protect-card-logins-blocked-status new file mode 100644 index 0000000000000..482a7c1b0a3f1 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/add-mj-protect-card-logins-blocked-status @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Add the number of logins blocked to the Protect card in My Jetpack. diff --git a/projects/packages/my-jetpack/global.d.ts b/projects/packages/my-jetpack/global.d.ts index 97b490976d2ec..975ad6d57ffef 100644 --- a/projects/packages/my-jetpack/global.d.ts +++ b/projects/packages/my-jetpack/global.d.ts @@ -192,6 +192,7 @@ interface Window { }; wafConfig: { automatic_rules_available: boolean; + blocked_logins: number; bootstrap_path: string; brute_force_protection: boolean; jetpack_waf_automatic_rules: '1' | ''; diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index fc55b644c8fcb..f65b8ab803b3b 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -264,7 +264,10 @@ public static function enqueue_scripts() { 'latestBoostSpeedScores' => $latest_score, 'protect' => array( 'scanData' => $scan_data, - 'wafConfig' => Waf_Runner::get_config(), + 'wafConfig' => array_merge( + Waf_Runner::get_config(), + array( 'blocked_logins' => (int) get_site_option( 'jetpack_protect_blocked_attempts', 0 ) ) + ), ), ) );