Skip to content

Commit

Permalink
Fix method how active standalone plugin is detected.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottprogrammer committed Dec 21, 2024
1 parent 4b89d88 commit 4b584fe
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export function useProtectTooltipCopy(): TooltipContent {
const slug = PRODUCT_SLUGS.PROTECT;
const { detail } = useProduct( slug );
const {
isPluginActive: isProtectPluginActive,
standalonePluginInfo,
hasPaidPlanForProduct: hasProtectPaidPlan,
manageUrl: protectDashboardUrl,
} = detail || {};
const { isStandaloneActive } = standalonePluginInfo || {};
const { recordEvent } = useAnalytics();
const {
plugins,
Expand Down Expand Up @@ -60,11 +61,11 @@ export function useProtectTooltipCopy(): TooltipContent {
}, [ threats ] );

const settingsLink = useMemo( () => {
if ( isProtectPluginActive ) {
if ( isStandaloneActive ) {
return 'admin.php?page=jetpack-protect#/firewall';
}
return isJetpackPluginActive() ? 'admin.php?page=jetpack#/settings' : null;
}, [ isProtectPluginActive ] );
}, [ isStandaloneActive ] );

const trackFirewallSettingsLinkClick = useCallback( () => {
recordEvent( 'jetpack_protect_card_tooltip_content_link_click', {
Expand All @@ -84,7 +85,7 @@ export function useProtectTooltipCopy(): TooltipContent {
} );
}, [ recordEvent, protectDashboardUrl ] );

const isBruteForcePluginsActive = isProtectPluginActive || isJetpackPluginActive();
const isBruteForcePluginsActive = isStandaloneActive || isJetpackPluginActive();

const blockedLoginsTooltip = useMemo( () => {
if ( blockedLoginsCount === 0 ) {
Expand All @@ -107,7 +108,7 @@ export function useProtectTooltipCopy(): TooltipContent {
'Brute Force Protection is disabled and not actively blocking malicious login attempts. Go to <a>%s</a> to activate it.',
'jetpack-my-jetpack'
),
isProtectPluginActive ? 'firewall settings' : 'Jetpack settings'
isStandaloneActive ? 'firewall settings' : 'Jetpack settings'
),
{
a: createElement( 'a', {
Expand Down Expand Up @@ -143,7 +144,7 @@ export function useProtectTooltipCopy(): TooltipContent {
'Brute Force Protection is disabled and not actively blocking malicious login attempts. Go to <a>%s</a> to activate it.',
'jetpack-my-jetpack'
),
isProtectPluginActive ? 'firewall settings' : 'Jetpack settings'
isStandaloneActive ? 'firewall settings' : 'Jetpack settings'
),
{
a: createElement( 'a', {
Expand All @@ -162,7 +163,7 @@ export function useProtectTooltipCopy(): TooltipContent {
blockedLoginsCount,
hasBruteForceProtection,
isBruteForcePluginsActive,
isProtectPluginActive,
isStandaloneActive,
settingsLink,
trackFirewallSettingsLinkClick,
] );
Expand Down Expand Up @@ -206,7 +207,7 @@ export function useProtectTooltipCopy(): TooltipContent {
numThreats
),
criticalThreatCount,
isProtectPluginActive ? 'Protect' : 'Scan'
isStandaloneActive ? 'Protect' : 'Scan'
),
{
a: createElement( 'a', {
Expand All @@ -227,7 +228,7 @@ export function useProtectTooltipCopy(): TooltipContent {
_n( '%d threat', '%d threats', numThreats, 'jetpack-my-jetpack' ),
numThreats
),
isProtectPluginActive ? 'Protect' : 'Scan'
isStandaloneActive ? 'Protect' : 'Scan'
),
{
a: createElement( 'a', {
Expand Down

0 comments on commit 4b584fe

Please sign in to comment.