Skip to content

Commit

Permalink
Add explanation firewall inactive when not supported (#40880)
Browse files Browse the repository at this point in the history
* Add tooltip text to let users know when firewall is disabled because of host

* changelog

* Show Inactive always if unsupported
  • Loading branch information
CodeyGuyDylan authored Jan 8, 2025
1 parent 1675c72 commit 3dc2652
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function useProtectTooltipCopy(): TooltipContent {
jetpack_waf_automatic_rules: isAutoFirewallEnabled,
blocked_logins: blockedLoginsCount,
brute_force_protection: hasBruteForceProtection,
waf_supported: wafSupported,
} = wafData || {};

const pluginsCount = fromScanPlugins.length || Object.keys( plugins ).length;
Expand Down Expand Up @@ -246,21 +247,26 @@ export function useProtectTooltipCopy(): TooltipContent {
),
},
autoFirewallTooltip:
hasProtectPaidPlan && ! isAutoFirewallEnabled
( hasProtectPaidPlan && ! isAutoFirewallEnabled ) || ! wafSupported
? {
title: __( 'Auto-Firewall: Inactive', 'jetpack-my-jetpack' ),
text: createInterpolateElement(
__(
'You have Auto-Firewall disabled, visit your Protect <a>firewall settings</a> to activate.',
'jetpack-my-jetpack'
),
{
a: createElement( 'a', {
href: settingsLink,
onClick: trackFirewallSettingsLinkClick,
} ),
}
),
text: wafSupported
? createInterpolateElement(
__(
'You have Auto-Firewall disabled, visit your Protect <a>firewall settings</a> to activate.',
'jetpack-my-jetpack'
),
{
a: createElement( 'a', {
href: settingsLink,
onClick: trackFirewallSettingsLinkClick,
} ),
}
)
: __(
'Auto-Firewall is disabled as your hosting provider already includes a built-in firewall with similar rules for your site.',
'jetpack-my-jetpack'
),
}
: {
title: __( 'Auto-Firewall: Inactive', 'jetpack-my-jetpack' ),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Add new WAF status on Protect card for when WAF is unsupported
1 change: 1 addition & 0 deletions projects/packages/my-jetpack/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ interface Window {
jetpack_waf_share_data: '1' | '';
jetpack_waf_share_debug_data: boolean;
standalone_mode: boolean;
waf_supported: boolean;
};
};
videopress: {
Expand Down
10 changes: 8 additions & 2 deletions projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,12 @@ public static function enqueue_scripts() {
$scan_data = Products\Protect::get_protect_data();
self::update_historically_active_jetpack_modules();

$waf_config = array();
$waf_config = array();
$waf_supported = false;

if ( class_exists( 'Automattic\Jetpack\Waf\Waf_Runner' ) ) {
$waf_config = Waf_Runner::get_config();
$waf_config = Waf_Runner::get_config();
$waf_supported = Waf_Runner::is_supported_environment();
}

wp_localize_script(
Expand Down Expand Up @@ -297,6 +300,9 @@ public static function enqueue_scripts() {
'scanData' => $scan_data,
'wafConfig' => array_merge(
$waf_config,
array(
'waf_supported' => $waf_supported,
),
array( 'blocked_logins' => (int) get_site_option( 'jetpack_protect_blocked_attempts', 0 ) )
),
),
Expand Down

0 comments on commit 3dc2652

Please sign in to comment.