-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cloud Posture] Adding CSP 3P support callout for Wiz integration (#1…
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...sections/epm/screens/detail/components/cloud_posture_third_party_support_callout.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import useLocalStorage from 'react-use/lib/useLocalStorage'; | ||
|
||
import type { PackageInfo } from '../../../../../../../../common'; | ||
|
||
import { CloudPostureThirdPartySupportCallout } from './cloud_posture_third_party_support_callout'; | ||
|
||
jest.mock('react-use/lib/useLocalStorage'); | ||
|
||
describe('CloudPostureThirdPartySupportCallout', () => { | ||
const mockPackageInfo = { name: 'wiz' } as PackageInfo; | ||
|
||
beforeEach(() => { | ||
(useLocalStorage as jest.Mock).mockClear(); | ||
}); | ||
|
||
it('renders callout when package is wiz and callout is not dismissed', () => { | ||
(useLocalStorage as jest.Mock).mockReturnValue([false, jest.fn()]); | ||
|
||
render(<CloudPostureThirdPartySupportCallout packageInfo={mockPackageInfo} />); | ||
|
||
expect(screen.getByText(/New! Starting from version 1.9/)).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render callout when package is not wiz', () => { | ||
const nonWizPackageInfo = { name: 'other' } as PackageInfo; | ||
render(<CloudPostureThirdPartySupportCallout packageInfo={nonWizPackageInfo} />); | ||
|
||
expect(screen.queryByText(/New! Starting from version 1.9/)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render callout when it has been dismissed', () => { | ||
(useLocalStorage as jest.Mock).mockReturnValue([true, jest.fn()]); | ||
|
||
render(<CloudPostureThirdPartySupportCallout packageInfo={mockPackageInfo} />); | ||
|
||
expect(screen.queryByText(/New! Starting from version 1.9/)).not.toBeInTheDocument(); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
...ions/sections/epm/screens/detail/components/cloud_posture_third_party_support_callout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import useLocalStorage from 'react-use/lib/useLocalStorage'; | ||
import { EuiCallOut, EuiSpacer } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import type { PackageInfo } from '../../../../../../../../common'; | ||
|
||
const LS_CLOUD_POSTURE_3P_SUPPORT_WIZ_INTEGRATIONS_CALLOUT_KEY = | ||
'fleet:cloudSecurityPosture:thirdPartySupport:wizIntegrationsCallout'; | ||
|
||
export const CloudPostureThirdPartySupportCallout = ({ | ||
packageInfo, | ||
}: { | ||
packageInfo: PackageInfo; | ||
}) => { | ||
const [userHasDismissedWizCallout, setUserHasDismissedWizCallout] = useLocalStorage( | ||
LS_CLOUD_POSTURE_3P_SUPPORT_WIZ_INTEGRATIONS_CALLOUT_KEY | ||
); | ||
|
||
if (packageInfo.name !== 'wiz' || userHasDismissedWizCallout) return null; | ||
|
||
return ( | ||
<> | ||
<EuiCallOut | ||
onDismiss={() => setUserHasDismissedWizCallout(true)} | ||
iconType="cheer" | ||
title={i18n.translate('xpack.fleet.epm.wizIntegration.newFeaturesCallout', { | ||
defaultMessage: | ||
'New! Starting from version 1.9, ingest vulnerability and misconfiguration findings from Wiz into Elastic. Leverage out-of-the-box contextual investigation and threat-hunting workflows.', | ||
})} | ||
/> | ||
<EuiSpacer size="s" /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters