Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][AVC banner] Hide AVC banner on January 1, 2025 #187929

Merged
merged 19 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/kbn-avc-banner/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@
* 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';
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();
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -313,7 +313,7 @@ export const OverviewPage: React.FC<Props> = memo(
</SideBar>
<EuiFlexItem grow={9} className="eui-textBreakWord">
{isUnverified && <UnverifiedCallout />}
{isElasticDefend && showAVCBanner && (
{useIsStillYear2024() && isElasticDefend && showAVCBanner && (
<>
<AVCResultsBanner2024 onDismiss={onBannerDismiss} />
<EuiSpacer size="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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'
);
});

Expand All @@ -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();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -91,7 +91,7 @@ export const OnboardingComponent: React.FC<OnboardingProps> = ({

return (
<div className={wrapperStyles}>
{showAVCBanner && (
{useIsStillYear2024() && showAVCBanner && (
<KibanaPageTemplate.Section paddingSize="none" className={bannerStyles}>
<AVCResultsBanner2024 onDismiss={onBannerDismiss} />
</KibanaPageTemplate.Section>
Expand Down
Loading