diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/context/exception_list_details.context.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/context/exception_list_details.context.tsx deleted file mode 100644 index 4d590f6c32107..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/context/exception_list_details.context.tsx +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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, { useState, createContext, useContext, useMemo } from 'react'; -import type { Dispatch } from 'react'; - -import type { ExceptionListItemSchema, ListArray } from '@kbn/securitysolution-io-ts-list-types'; -import type { Pagination } from '@elastic/eui'; -import type { HttpSetup } from '@kbn/core-http-browser'; -import type { IToasts } from '@kbn/core/public'; -import type { RuleReferences } from '@kbn/securitysolution-exception-list-components'; -import { useToasts, useKibana } from '../../../../../common/lib/kibana'; - -interface ExceptionListDetailsContextProps { - exceptionListReferences: RuleReferences; - toasts?: IToasts; - http: HttpSetup | undefined; - exceptions: ExceptionListItemSchema[]; - isLoading: boolean; - pagination: Pagination; - isReadOnly: boolean; - setIsLoading: Dispatch>; - setExceptions: Dispatch>; - setPagination: Dispatch>; - setIsReadOnly: Dispatch>; - setExceptionListReferences: Dispatch>; -} -const defaultState: ExceptionListDetailsContextProps = { - exceptionListReferences: {}, - exceptions: [], - isLoading: false, - pagination: { pageIndex: 0, pageSize: 0, totalItemCount: 0 }, - isReadOnly: false, - http: undefined, - setIsLoading: () => {}, - setExceptions: () => {}, - setPagination: () => null, - setIsReadOnly: () => {}, - setExceptionListReferences: () => {}, -}; - -const ExceptionListDetailsContext = createContext(defaultState); - -interface ExceptionListDetailsProvidersProps { - children: React.ReactNode; -} - -export const ExceptionListDetailsProvider = ({ children }: ExceptionListDetailsProvidersProps) => { - const toasts = useToasts(); - const { services } = useKibana(); - const { http } = services; - - const [isLoading, setIsLoading] = useState(false); - const [exceptions, setExceptions] = useState([]); - const [exceptionListReferences, setExceptionListReferences] = useState([]); - const [pagination, setPagination] = useState({}); - const [isReadOnly, setIsReadOnly] = useState(false); - - const providerValue = useMemo( - () => ({ - http, - isLoading, - pagination, - exceptions, - isReadOnly, - toasts, - exceptionListReferences, - - setExceptions, - setPagination, - setIsLoading, - setIsReadOnly, - setExceptionListReferences, - }), - [exceptionListReferences, exceptions, http, isLoading, isReadOnly, pagination, toasts] - ); - - return ( - - {children} - - ); -}; - -export const useExceptionListDetailsContext = () => { - const exceptionListDetailsContext = useContext(ExceptionListDetailsContext); - - return exceptionListDetailsContext; -}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exception_list_details.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exception_list_details.tsx deleted file mode 100644 index 9bf1716f5a641..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exception_list_details.tsx +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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. - */ -/* eslint-disable react-hooks/exhaustive-deps */ -import React, { useEffect } from 'react'; -import type { FC } from 'react'; - -import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ListHeader } from './list_header/list_header'; - -import { ListWithSearch } from './list_with_search'; -import { useExceptionListDetailsContext } from './context/exception_list_details.context'; - -interface ExceptionListDetailsComponentProps { - isReadOnly?: boolean; - list: ExceptionListSchema; -} - -export const ExceptionListDetailsComponent: FC = ({ - isReadOnly = false, - list, -}) => { - const { name: listName, description: listDescription } = list; - - const { setIsReadOnly } = useExceptionListDetailsContext(); - useEffect(() => { - setIsReadOnly(isReadOnly); - }, []); - return ( - <> - - - - ); -}; - -ExceptionListDetailsComponent.displayName = 'ExceptionListDetailsComponent'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exceptions_utility/exceptions_utility.test.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exceptions_utility/exceptions_utility.test.tsx deleted file mode 100644 index b1171b0458232..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exceptions_utility/exceptions_utility.test.tsx +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 } from '@testing-library/react'; - -// import { ExceptionsUtility } from './exceptions_utility'; - -// TODO : Fix test -describe('ExceptionsUtility', () => { - it('temp until fix', () => { - expect(true).toEqual(true); - }); - // it('it renders correct item counts', () => { - // const wrapper = render( - // - // ); - // expect(wrapper.getByTestId('exceptionsShowing')).toHaveTextContent('Showing 1-50 of 105'); - // }); - // it('it renders last updated message', () => { - // const wrapper = render( - // - // ); - // expect(wrapper.getByTestId('exceptionsViewerLastUpdated')).toHaveTextContent('Updated now'); - // }); -}); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exceptions_utility/exceptions_utility.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exceptions_utility/exceptions_utility.tsx deleted file mode 100644 index e7d6e83c06885..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/exceptions_utility/exceptions_utility.tsx +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 type { FC } from 'react'; -import { FormattedMessage } from '@kbn/i18n-react'; -import type { Pagination } from '@elastic/eui'; -import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; - -import styled from 'styled-components'; -import { - UtilityBar, - UtilityBarSection, - UtilityBarGroup, - UtilityBarText, -} from '../../../../../common/components/utility_bar'; -import { FormattedRelativePreferenceDate } from '../../../../../common/components/formatted_date'; - -const StyledText = styled.span` - font-weight: bold; -`; - -const MyUtilities = styled(EuiFlexGroup)``; - -const StyledCondition = styled.span` - display: inline-block !important; - vertical-align: middle !important; -`; -interface ExceptionsUtilityComponentProps { - showingTextDataTestSubj?: string; - lastUpdatedTextDataTestSubj?: string; - exceptionsTitle?: string; - exceptionsTitleDataTestSubj?: string; - pagination: Pagination; - // Corresponds to last time exception items were fetched - lastUpdated: string | number | null; -} - -const ExceptionsUtilityComponent: FC = ({ - showingTextDataTestSubj, - pagination, - lastUpdated, - - lastUpdatedTextDataTestSubj, - exceptionsTitle, - exceptionsTitleDataTestSubj, -}) => { - const { pageSize, totalItemCount } = pagination; - return ( - - - - - - - {`1-${Math.min(pageSize, totalItemCount)}`}, - partTwo: {`${totalItemCount}`}, - }} - /> - - {exceptionsTitle && ( - - {exceptionsTitle} - - )} - - - - - - - - - - ), - }} - /> - - - - ); -}; - -ExceptionsUtilityComponent.displayName = 'ExceptionsUtilityComponent'; - -export const ExceptionsUtility = React.memo(ExceptionsUtilityComponent); - -ExceptionsUtility.displayName = 'ExceptionsUtility'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/index.tsx deleted file mode 100644 index c46dbca7c5229..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/index.tsx +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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, { memo } from 'react'; -import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ExceptionListDetailsProvider } from './context/exception_list_details.context'; -import { ExceptionListDetailsComponent } from './exception_list_details'; - -export const ExceptionListDetails = memo(({ list }: { list: ExceptionListSchema }) => ( - - - -)); - -ExceptionListDetails.displayName = 'ExceptionListDetails'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/link_anchor/link_anchor.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/link_anchor/link_anchor.tsx deleted file mode 100644 index e7c9a89cb5e2e..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/link_anchor/link_anchor.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 type { FC } from 'react'; -import { SecuritySolutionLinkAnchor } from '../../../../../common/components/links'; -import { SecurityPageName } from '../../../../../../common/constants'; -import { getRuleDetailsTabUrl } from '../../../../../common/components/link_to/redirect_to_detection_engine'; -import { RuleDetailTabs } from '../../../../../detections/pages/detection_engine/rules/details'; - -interface LinkAnchorProps { - referenceName: string; - referenceId: string; -} -// This component should be removed and moved to @kbn/securitysolution-exception-list-components -// once all the building components get moved - -const LinkAnchor: FC = ({ referenceName, referenceId }) => { - return ( - - {referenceName} - - ); -}; - -LinkAnchor.displayName = 'LinkAnchor'; - -export const ListDetailsLinkAnchor = React.memo(LinkAnchor); - -ListDetailsLinkAnchor.displayName = 'ListDetailsLinkAnchor'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_api.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_api.ts deleted file mode 100644 index 92cd20a32b395..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_api.ts +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 type { Pagination } from '@elastic/eui'; -import type { HttpSetup } from '@kbn/core-http-browser'; - -import type { - Pagination as ServerPagination, - ExceptionListSchema, - ListArray, - NamespaceType, -} from '@kbn/securitysolution-io-ts-list-types'; -import { fetchExceptionListsItemsByListIds } from '@kbn/securitysolution-list-api'; -import { transformInput } from '@kbn/securitysolution-list-hooks'; -import type { GetExceptionItemProps } from '@kbn/securitysolution-exception-list-components'; -import { findRuleExceptionReferences } from '../../../../detections/containers/detection_engine/rules'; - -interface FetchItemsProps { - http: HttpSetup | undefined; - listIds: string[]; - namespaceTypes: NamespaceType[]; - pagination: Pagination | undefined; - search?: string; - filter?: string; -} - -export const prepareFetchExceptionItemsParams = ( - exceptions: ListArray | null, - list: ExceptionListSchema | null, - options?: GetExceptionItemProps -) => { - const { pagination, search, filters } = options || {}; - let listIds: string[] = []; - let namespaceTypes: NamespaceType[] = []; - - if (Array.isArray(exceptions) && exceptions.length) { - listIds = exceptions.map((excList) => excList.list_id); - namespaceTypes = exceptions.map((excList) => excList.namespace_type); - } else if (list) { - listIds = [list.list_id]; - namespaceTypes = [list.namespace_type]; - } - - return { - listIds, - namespaceTypes, - pagination, - search, - filters, - }; -}; - -export const fetchListExceptionItems = async ({ - namespaceTypes, - listIds, - http, - pagination, - search, -}: FetchItemsProps) => { - try { - const abortCtrl = new AbortController(); - const { - pageIndex: inputPageIndex, - pageSize: inputPageSize, - totalItemCount: inputTotalItemCount, - } = pagination || {}; - - const { - page: pageIndex, - per_page: pageSize, - total: totalItemCount, - data, - } = await fetchExceptionListsItemsByListIds({ - filter: undefined, - http: http as HttpSetup, - listIds: listIds ?? [], - namespaceTypes: namespaceTypes ?? [], - search, - pagination: { - perPage: inputPageSize, - page: inputPageIndex || 0 + 1, - total: inputTotalItemCount, - } as ServerPagination, - signal: abortCtrl.signal, - }); - - // Please see `x-pack/plugins/lists/public/exceptions/transforms.ts` doc notes - // for context around the temporary `id` - const transformedData = data.map((item) => transformInput(item)); - - return { - data: transformedData, - pagination: { pageIndex: pageIndex - 1, pageSize, totalItemCount }, - }; - } catch (error) { - throw new Error(error); - } -}; - -export const getExceptionItemsReferences = async (list: ExceptionListSchema) => { - try { - const abortCtrl = new AbortController(); - - const { references } = await findRuleExceptionReferences({ - lists: [list].map((listInput) => ({ - id: listInput.id, - listId: listInput.list_id, - namespaceType: listInput.namespace_type, - })), - signal: abortCtrl.signal, - }); - - return references.reduce((acc, result) => { - const [[key, value]] = Object.entries(result); - acc[key] = value; - return acc; - }, {}); - } catch (error) { - throw new Error(error); - } -}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_header/index.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_header/index.ts deleted file mode 100644 index 41258de83decf..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_header/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export * from './list_header'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_header/list_header.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_header/list_header.tsx deleted file mode 100644 index 306cfa3d0d98e..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_header/list_header.tsx +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 type { FC } from 'react'; -import { EuiHorizontalRule, EuiPageHeader, EuiSpacer } from '@elastic/eui'; - -interface ListHeaderComponentProps { - title: string; - description?: string; - listId?: string; -} - -const ListHeaderComponent: FC = ({ title, description, listId }) => { - return ( - <> - - - - - ); -}; - -ListHeaderComponent.displayName = 'ListHeaderComponent'; - -export const ListHeader = React.memo(ListHeaderComponent); - -ListHeader.displayName = 'ListHeader'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/index.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/index.ts deleted file mode 100644 index 509f2374a2a80..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export * from './list_with_search'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/list_with_search.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/list_with_search.tsx deleted file mode 100644 index 6412c7aefc7cd..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/list_with_search.tsx +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 type { FC } from 'react'; -import { EuiPanel } from '@elastic/eui'; - -import type { - ExceptionListTypeEnum, - ExceptionListSchema, -} from '@kbn/securitysolution-io-ts-list-types'; - -import { - SearchBar, - ExceptionItems, - EmptyViewerState, - ViewerStatus, -} from '@kbn/securitysolution-exception-list-components'; -import { FormattedDate } from '../../../../../common/components/formatted_date'; - -import * as i18n from '../translations'; - -import { useListWithSearchComponent } from './use_list_with_search'; -import { ListDetailsLinkAnchor } from '../link_anchor/link_anchor'; -import { getFormattedComments } from '../../../utils/helpers'; -import { ExceptionsUtility } from '../exceptions_utility/exceptions_utility'; - -interface ListWithSearchComponentProps { - list: ExceptionListSchema; -} - -const ListWithSearchComponent: FC = ({ list }) => { - const { - listName, - isReadOnly, - exceptions, - listType, - lastUpdated, - pagination, - emptyViewerTitle, - emptyViewerBody, - viewerStatus, - ruleReferences, - onSearch, - onAddExceptionClick, - onDeleteException, - onEditExceptionItem, - onPaginationChange, - onCreateExceptionListItem, - } = useListWithSearchComponent(list); - - return viewerStatus === ViewerStatus.EMPTY || viewerStatus === ViewerStatus.LOADING ? ( - - ) : ( - - <> - - - - - ); -}; - -ListWithSearchComponent.displayName = 'ListWithSearchComponent'; - -export const ListWithSearch = React.memo(ListWithSearchComponent); - -ListWithSearch.displayName = 'ListWithSearch'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/use_list_with_search.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/use_list_with_search.tsx deleted file mode 100644 index 1150db7738d95..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/list_with_search/use_list_with_search.tsx +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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 { useCallback, useEffect, useMemo, useState } from 'react'; - -import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; - -import type { GetExceptionItemProps } from '@kbn/securitysolution-exception-list-components'; -import { ViewerStatus } from '@kbn/securitysolution-exception-list-components'; -import { - prepareFetchExceptionItemsParams, - fetchListExceptionItems, - getExceptionItemsReferences, -} from '../list_api'; -import * as i18n from '../translations'; -import { useExceptionListDetailsContext } from '../context/exception_list_details.context'; - -export const useListWithSearchComponent = (list: ExceptionListSchema) => { - const { - isReadOnly, - toasts, - http, - pagination, - exceptions, - exceptionListReferences, - setExceptions, - setPagination, - setExceptionListReferences, - } = useExceptionListDetailsContext(); - const [viewerStatus, setViewerStatus] = useState(ViewerStatus.LOADING); - - const [lastUpdated, setLastUpdated] = useState(null); - - const handleErrorStatus = useCallback( - (error) => { - toasts?.addError(error, { - title: i18n.EXCEPTION_ERROR_TITLE, - toastMessage: i18n.EXCEPTION_ERROR_DESCRIPTION, - }); - setViewerStatus(ViewerStatus.ERROR); - }, - [toasts] - ); - const getReferences = useCallback(async () => { - try { - const result = await getExceptionItemsReferences(list); - setExceptionListReferences(result); - } catch (error) { - handleErrorStatus(error); - } - }, [handleErrorStatus, list, setExceptionListReferences]); - - const updateViewer = useCallback( - (paginationResult, dataLength, viewStatus) => { - setPagination(paginationResult); - setLastUpdated(Date.now()); - - if (viewStatus === ViewerStatus.EMPTY_SEARCH) setViewerStatus(!dataLength ? viewStatus : ''); - else setViewerStatus(!dataLength ? ViewerStatus.EMPTY : ''); - }, - [setPagination] - ); - - const fetchItems = useCallback( - async (options?, viewStatus?) => { - try { - const { data, pagination: paginationResult } = await fetchListExceptionItems({ - http, - ...prepareFetchExceptionItemsParams(null, list, options), - }); - setExceptions(data); - getReferences(); - updateViewer(paginationResult, data.length, viewStatus); - } catch (error) { - handleErrorStatus(error); - } - }, - [http, list, setExceptions, getReferences, updateViewer, handleErrorStatus] - ); - - useEffect(() => { - fetchItems(null, ViewerStatus.LOADING); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - const emptyViewerTitle = useMemo(() => { - return viewerStatus === ViewerStatus.EMPTY ? i18n.EXCEPTION_LIST_EMPTY_VIEWER_TITLE : ''; - }, [viewerStatus]); - - const emptyViewerBody = useMemo(() => { - return viewerStatus === ViewerStatus.EMPTY - ? i18n.EXCEPTION_LIST_EMPTY_VIEWER_BODY(list.name) - : ''; - }, [list.name, viewerStatus]); - - // #region Callbacks - const onPaginationChange = useCallback( - async (options) => { - fetchItems(options); - }, - [fetchItems] - ); - const onSearch = useCallback( - async (options?: GetExceptionItemProps) => { - setViewerStatus(ViewerStatus.SEARCHING); - fetchItems(options, ViewerStatus.EMPTY_SEARCH); - }, - [fetchItems] - ); - - const onAddExceptionClick = () => {}; - const onDeleteException = () => {}; - const onEditExceptionItem = () => {}; - const onCreateExceptionListItem = useCallback(() => {}, []); - // #endregion - - return { - listName: list.name, - isReadOnly, - exceptions, - listType: list.type, - lastUpdated, - pagination, - - viewerStatus, - emptyViewerTitle, - emptyViewerBody, - - ruleReferences: exceptionListReferences, - - onSearch, - onAddExceptionClick, - onDeleteException, - onEditExceptionItem, - onPaginationChange, - onCreateExceptionListItem, - }; -}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/translations.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/translations.ts deleted file mode 100644 index 0ad0555586d40..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/pages/exception_list_details/translations.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 { i18n } from '@kbn/i18n'; - -export const EXCEPTION_LIST_EMPTY_VIEWER_TITLE = i18n.translate( - 'xpack.securitySolution.exception.list.empty.viewer_title', - { - defaultMessage: 'Create exceptions to this list', - } -); - -export const EXCEPTION_LIST_EMPTY_VIEWER_BODY = (listName: string) => - i18n.translate('xpack.securitySolution.exception.list.empty.viewer_body', { - values: { listName }, - defaultMessage: - 'There is no exception in your [{listName}]. Create rule exceptions to this list.', - }); - -export const EXCEPTION_LIST_EMPTY_VIEWER_BUTTON = i18n.translate( - 'xpack.securitySolution.exception.list.empty.viewer_button', - { - defaultMessage: 'Create rule exception', - } -); - -export const EXCEPTION_LIST_EMPTY_SEARCH_BAR_BUTTON = i18n.translate( - 'xpack.securitySolution.exception.list.search_bar_button', - { - defaultMessage: 'Add rule exception to list', - } -); - -export const EXCEPTION_LIST_SEARCH_ERROR_TITLE = i18n.translate( - 'xpack.securitySolution.exceptions.list.exceptionItemSearchErrorTitle', - { - defaultMessage: 'Error searching', - } -); - -export const EXCEPTION_LIST_SEARCH_ERROR_BODY = i18n.translate( - 'xpack.securitySolution.exceptions.list.exceptionItemSearchErrorBody', - { - defaultMessage: 'An error occurred searching for exception items. Please try again.', - } -); - -export const EXCEPTION_ERROR_TITLE = i18n.translate( - 'xpack.securitySolution.exceptions.list.exceptionItemsFetchError', - { - defaultMessage: 'Unable to load exception items', - } -); - -export const EXCEPTION_ERROR_DESCRIPTION = i18n.translate( - 'xpack.securitySolution.exceptions.list.exceptionItemsFetchErrorDescription', - { - defaultMessage: - 'There was an error loading the exception items. Contact your administrator for help.', - } -); diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx index 1f8a6021575d5..d7908d0bbce66 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx @@ -19,7 +19,6 @@ import { import type { NamespaceType, ExceptionListFilter } from '@kbn/securitysolution-io-ts-list-types'; import { useApi, useExceptionLists } from '@kbn/securitysolution-list-hooks'; -import { ExceptionListDetails } from '../../../../../../detection_engine/rule_exceptions/pages/exception_list_details'; import { useAppToasts } from '../../../../../../common/hooks/use_app_toasts'; import { AutoDownload } from '../../../../../../common/components/auto_download/auto_download'; import { useKibana } from '../../../../../../common/lib/kibana'; @@ -348,7 +347,6 @@ export const ExceptionListsTable = React.memo(() => { }, [setPagination] ); - const [showDetails, setShowDetails] = useState(false); return ( <> @@ -393,10 +391,6 @@ export const ExceptionListsTable = React.memo(() => { noItemsMessage={emptyPrompt} onChange={handlePaginationChange} pagination={paginationMemo} - onClick={(args) => { - // TODO: need the clickedItem - setShowDetails(!showDetails); - }} /> )} @@ -418,7 +412,6 @@ export const ExceptionListsTable = React.memo(() => { titleText={i18n.REFERENCE_MODAL_TITLE} /> - {showDetails && } ); });