Add back button for specific link integrations (#121522) (#121623)

This commit is contained in:
Esteban Beltran 2021-12-20 13:57:07 +01:00 committed by GitHub
parent 1ef87700b1
commit 2b66871c3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,10 +7,10 @@
import { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
import { i18n } from '@kbn/i18n';
import React, { useCallback, useEffect, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { EuiButton, EuiText, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { useHistory } from 'react-router-dom';
import { useHistory, useLocation } from 'react-router-dom';
import { ExceptionItem } from '../../../../common/components/exceptions/viewer/exception_item';
import { getCurrentLocation } from '../store/selector';
import {
@ -18,8 +18,9 @@ import {
useHostIsolationExceptionsNavigateCallback,
useHostIsolationExceptionsSelector,
} from './hooks';
import { BackToExternalAppButton } from '../../../components/back_to_external_app_button';
import { PaginatedContent, PaginatedContentProps } from '../../../components/paginated_content';
import { Immutable } from '../../../../../common/endpoint/types';
import { Immutable, ListPageRouteState } from '../../../../../common/endpoint/types';
import { AdministrationListPage } from '../../../components/administration_list_page';
import { SearchExceptions } from '../../../components/search_exceptions';
import { ArtifactEntryCard, ArtifactEntryCardProps } from '../../../components/artifact_entry_card';
@ -45,6 +46,7 @@ type HostIsolationExceptionPaginatedContent = PaginatedContentProps<
export const HostIsolationExceptionsList = () => {
const history = useHistory();
const privileges = useUserPrivileges().endpointPrivileges;
const { state: routeState } = useLocation<ListPageRouteState | undefined>();
const location = useHostIsolationExceptionsSelector(getCurrentLocation);
const navigateCallback = useHostIsolationExceptionsNavigateCallback();
@ -117,6 +119,13 @@ export const HostIsolationExceptionsList = () => {
[navigateCallback]
);
const backButton = useMemo(() => {
if (routeState && routeState.onBackButtonNavigateTo) {
return <BackToExternalAppButton {...routeState} />;
}
return null;
}, [routeState]);
const handleAddButtonClick = useCallback(
() =>
navigateCallback({
@ -144,6 +153,7 @@ export const HostIsolationExceptionsList = () => {
return (
<AdministrationListPage
headerBackComponent={backButton}
title={
<FormattedMessage
id="xpack.securitySolution.hostIsolationExceptions.list.pageTitle"