Skip to content

Commit d5271bb

Browse files
[AI4DSOC] Fix link to the new integrations page
1 parent f684ea4 commit d5271bb

4 files changed

Lines changed: 75 additions & 10 deletions

File tree

x-pack/solutions/security/plugins/security_solution/public/detections/components/alert_summary/integrations/integration_section.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';
1111
import type { PackageListItem } from '@kbn/fleet-plugin/common';
1212
import { useIntegrationsLastActivity } from '../../../hooks/alert_summary/use_integrations_last_activity';
1313
import { IntegrationCard } from './integration_card';
14-
import { useAddIntegrationsUrl } from '../../../../common/hooks/use_add_integrations_url';
14+
import { useNavigateToIntegrationsPage } from '../../../hooks/alert_summary/use_navigate_to_integrations_page';
1515

1616
const ADD_INTEGRATION = i18n.translate(
1717
'xpack.securitySolution.alertSummary.integrations.addIntegrationButtonLabel',
@@ -36,7 +36,7 @@ export interface IntegrationSectionProps {
3636
* Each integration card is also displaying the last time the sync happened (using streams).
3737
*/
3838
export const IntegrationSection = memo(({ packages }: IntegrationSectionProps) => {
39-
const { onClick: addIntegration } = useAddIntegrationsUrl(); // TODO this link might have to be revisited once the integration work is done
39+
const navigateToIntegrationsPage = useNavigateToIntegrationsPage();
4040
const { isLoading, lastActivities } = useIntegrationsLastActivity({ packages });
4141

4242
return (
@@ -59,7 +59,7 @@ export const IntegrationSection = memo(({ packages }: IntegrationSectionProps) =
5959
<EuiButtonEmpty
6060
data-test-subj={ADD_INTEGRATIONS_BUTTON_TEST_ID}
6161
iconType="plusInCircle"
62-
onClick={addIntegration}
62+
onClick={navigateToIntegrationsPage}
6363
>
6464
{ADD_INTEGRATION}
6565
</EuiButtonEmpty>

x-pack/solutions/security/plugins/security_solution/public/detections/components/alert_summary/landing_page/landing_page.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import {
1919
} from '@elastic/eui';
2020
import type { PackageListItem } from '@kbn/fleet-plugin/common';
2121
import { i18n } from '@kbn/i18n';
22-
import { useAddIntegrationsUrl } from '../../../../common/hooks/use_add_integrations_url';
2322
import { IntegrationCard } from './integration_card';
2423
import imageSrc from './alert_summary.png';
24+
import { useNavigateToIntegrationsPage } from '../../../hooks/alert_summary/use_navigate_to_integrations_page';
2525

2626
const TITLE = i18n.translate('xpack.securitySolution.alertSummary.landingPage.title', {
2727
defaultMessage: 'All your alerts in one place with AI',
@@ -39,10 +39,7 @@ const VIEW_ALL_INTEGRATIONS = i18n.translate(
3939
}
4040
);
4141

42-
const PRIMARY_INTEGRATIONS = [
43-
'splunk', // doesnt yet exist
44-
'google_secops',
45-
];
42+
const PRIMARY_INTEGRATIONS = ['splunk', 'google_secops'];
4643

4744
export const LANDING_PAGE_PROMPT_TEST_ID = 'alert-summary-landing-page-prompt';
4845
export const LANDING_PAGE_IMAGE_TEST_ID = 'alert-summary-landing-page-image';
@@ -63,7 +60,7 @@ export interface LandingPageProps {
6360
*/
6461
export const LandingPage = memo(({ packages }: LandingPageProps) => {
6562
const { euiTheme } = useEuiTheme();
66-
const { onClick: moreIntegrations } = useAddIntegrationsUrl(); // TODO this link might have to be revisited once the integration work is done
63+
const navigateToIntegrationsPage = useNavigateToIntegrationsPage();
6764

6865
// We only want to show the 2 top integrations, Splunk and GoogleSecOps, in that specific order
6966
const primaryPackages = useMemo(
@@ -141,7 +138,7 @@ export const LandingPage = memo(({ packages }: LandingPageProps) => {
141138
<EuiButtonEmpty
142139
data-test-subj={LANDING_PAGE_VIEW_ALL_INTEGRATIONS_BUTTON_TEST_ID}
143140
iconType="plusInCircle"
144-
onClick={moreIntegrations}
141+
onClick={navigateToIntegrationsPage}
145142
>
146143
{VIEW_ALL_INTEGRATIONS}
147144
</EuiButtonEmpty>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { renderHook } from '@testing-library/react';
9+
import {
10+
INTEGRATIONS_URL,
11+
useNavigateToIntegrationsPage,
12+
} from './use_navigate_to_integrations_page';
13+
import { useKibana, useNavigateTo } from '../../../common/lib/kibana';
14+
15+
jest.mock('../../../common/lib/kibana');
16+
17+
describe('useNavigateToIntegrationsPage', () => {
18+
it('should return function', () => {
19+
(useKibana as jest.Mock).mockReturnValue({
20+
services: {
21+
http: {
22+
basePath: {
23+
prepend: jest.fn().mockImplementation((url) => url),
24+
},
25+
},
26+
},
27+
});
28+
const navigateTo = jest.fn();
29+
(useNavigateTo as jest.Mock).mockReturnValue({ navigateTo });
30+
31+
const { result } = renderHook(() => useNavigateToIntegrationsPage());
32+
33+
expect(typeof result.current).toBe('function');
34+
result.current();
35+
expect(navigateTo).toHaveBeenCalledWith({
36+
url: INTEGRATIONS_URL,
37+
});
38+
});
39+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { useCallback } from 'react';
9+
import { useKibana, useNavigateTo } from '../../../common/lib/kibana';
10+
11+
export const INTEGRATIONS_URL = '/app/security/configurations/integrations/browse';
12+
13+
/**
14+
* Hook that returns a callback event to navigate to the AI4DSOC integrations page
15+
*/
16+
export const useNavigateToIntegrationsPage = (): (() => void) => {
17+
const {
18+
services: {
19+
http: {
20+
basePath: { prepend },
21+
},
22+
},
23+
} = useKibana();
24+
const { navigateTo } = useNavigateTo();
25+
26+
return useCallback(() => {
27+
navigateTo({ url: prepend(INTEGRATIONS_URL) });
28+
}, [navigateTo, prepend]);
29+
};

0 commit comments

Comments
 (0)