diff --git a/packages/kbn-avc-banner/src/index.tsx b/packages/kbn-avc-banner/src/index.tsx index 54ded0bfdd49d..2f71b5ddd9679 100644 --- a/packages/kbn-avc-banner/src/index.tsx +++ b/packages/kbn-avc-banner/src/index.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import React from 'react'; +import React, { useMemo } from 'react'; import { css } from '@emotion/css'; import { i18n } from '@kbn/i18n'; import { EuiButton, EuiCallOut, EuiSpacer, useEuiTheme } from '@elastic/eui'; @@ -14,6 +14,13 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import avcBannerBackground from './avc_banner_background.svg'; +// Logic to hide banner at EOY 2024 +export const useIsStillYear2024: () => boolean = () => { + return useMemo(() => { + return new Date().getFullYear() === 2024; + }, []); +}; + export const AVCResultsBanner2024: React.FC<{ onDismiss: () => void }> = ({ onDismiss }) => { const { docLinks } = useKibana().services; const { euiTheme } = useEuiTheme(); diff --git a/packages/kbn-doc-links/src/get_doc_links.ts b/packages/kbn-doc-links/src/get_doc_links.ts index fef52545f8d2f..25c91238a7b6d 100644 --- a/packages/kbn-doc-links/src/get_doc_links.ts +++ b/packages/kbn-doc-links/src/get_doc_links.ts @@ -466,7 +466,7 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D }, securitySolution: { artifactControl: `${SECURITY_SOLUTION_DOCS}artifact-control.html`, - avcResults: `${ELASTIC_WEBSITE_URL}blog/elastic-security-malware-protection-test-av-comparatives`, + avcResults: `${ELASTIC_WEBSITE_URL}blog/elastic-av-comparatives-business-security-test`, trustedApps: `${SECURITY_SOLUTION_DOCS}trusted-apps-ov.html`, eventFilters: `${SECURITY_SOLUTION_DOCS}event-filters.html`, blocklist: `${SECURITY_SOLUTION_DOCS}blocklist.html`, diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/overview.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/overview.tsx index 2859b0ff7d8ae..9fa6df1e9f8ca 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/overview.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/overview.tsx @@ -22,7 +22,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { useKibana } from '@kbn/kibana-react-plugin/public'; -import { AVCResultsBanner2024 } from '@kbn/avc-banner'; +import { AVCResultsBanner2024, useIsStillYear2024 } from '@kbn/avc-banner'; import { isIntegrationPolicyTemplate, @@ -313,7 +313,7 @@ export const OverviewPage: React.FC = memo( {isUnverified && } - {isElasticDefend && showAVCBanner && ( + {useIsStillYear2024() && isElasticDefend && showAVCBanner && ( <> diff --git a/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/onboarding.test.tsx b/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/onboarding.test.tsx index c31b6a01f3372..feb77b0e64ab3 100644 --- a/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/onboarding.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/onboarding.test.tsx @@ -88,6 +88,13 @@ describe('OnboardingComponent', () => { }); describe('AVC 2024 Results banner', () => { + beforeEach(() => { + (useKibana().services.storage.get as jest.Mock).mockReturnValue(true); + }); + afterEach(() => { + jest.clearAllMocks(); + jest.useRealTimers(); + }); it('should render on the page', () => { render(); expect(renderResult.getByTestId('avcResultsBanner')).toBeTruthy(); @@ -97,7 +104,7 @@ describe('OnboardingComponent', () => { render(); expect(renderResult.getByTestId('avcReadTheBlog')).toHaveAttribute( 'href', - 'https://www.elastic.co/blog/elastic-security-malware-protection-test-av-comparatives' + 'https://www.elastic.co/blog/elastic-av-comparatives-business-security-test' ); }); @@ -110,10 +117,23 @@ describe('OnboardingComponent', () => { false ); }); + it('should stay dismissed if it has been closed once', () => { - (useKibana().services.storage.get as jest.Mock).mockReturnValue(false); + (useKibana().services.storage.get as jest.Mock).mockReturnValueOnce(false); render(); expect(renderResult.queryByTestId('avcResultsBanner')).toBeNull(); }); + + it('should not be shown if the current date is January 1, 2025', () => { + jest.useFakeTimers().setSystemTime(new Date('2025-01-01T05:00:00.000Z')); + render(); + expect(renderResult.queryByTestId('avcResultsBanner')).toBeNull(); + jest.useRealTimers(); + }); + it('should be shown if the current date is before January 1, 2025', () => { + jest.useFakeTimers().setSystemTime(new Date('2024-12-31T05:00:00.000Z')); + render(); + expect(renderResult.queryByTestId('avcResultsBanner')).toBeTruthy(); + }); }); }); diff --git a/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/onboarding.tsx b/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/onboarding.tsx index 35754cda785cd..b5ec40b703895 100644 --- a/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/onboarding.tsx +++ b/x-pack/plugins/security_solution/public/common/components/landing_page/onboarding/onboarding.tsx @@ -6,7 +6,7 @@ */ import React, { useCallback, useMemo, useState } from 'react'; -import { AVCResultsBanner2024 } from '@kbn/avc-banner'; +import { AVCResultsBanner2024, useIsStillYear2024 } from '@kbn/avc-banner'; import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template'; import { TogglePanel } from './toggle_panel'; @@ -91,7 +91,7 @@ export const OnboardingComponent: React.FC = ({ return (
- {showAVCBanner && ( + {useIsStillYear2024() && showAVCBanner && (