[Security Solution][RAC] Hide filters on case view (#110090)

This commit is contained in:
Michael Olorunnisola 2021-08-26 09:19:20 -04:00 committed by GitHub
parent c113c237f8
commit 7d66cf9882
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 7 deletions

View file

@ -11,7 +11,7 @@ import { DraggableId } from 'react-beautiful-dnd';
import styled from 'styled-components';
import { i18n } from '@kbn/i18n';
import { ColumnHeaderOptions, DataProvider } from '../../../../common/types/timeline';
import { ColumnHeaderOptions, DataProvider, TimelineId } from '../../../../common/types/timeline';
import { stopPropagationAndPreventDefault } from '../../../../../timelines/public';
import { SHOW_TOP_N_KEYBOARD_SHORTCUT } from './keyboard_shortcut_constants';
import { useHoverActionItems } from './use_hover_action_items';
@ -202,15 +202,18 @@ export const HoverActions: React.FC<Props> = React.memo(
[ownFocus, toggleTopN]
);
const isCaseView = timelineId === TimelineId.casePage;
const { overflowActionItems, allActionItems } = useHoverActionItems({
dataProvider,
dataType,
defaultFocusedButtonRef,
draggableId,
enableOverflowButton,
enableOverflowButton: enableOverflowButton && !isCaseView,
field,
handleHoverActionClicked,
hideTopN,
isCaseView,
isObjectArray,
isOverflowPopoverOpen,
onFilterAdded,
@ -245,7 +248,7 @@ export const HoverActions: React.FC<Props> = React.memo(
{additionalContent != null && <AdditionalContent>{additionalContent}</AdditionalContent>}
{enableOverflowButton ? overflowActionItems : allActionItems}
{enableOverflowButton && !isCaseView ? overflowActionItems : allActionItems}
</StyledHoverActionsContainer>
</EuiFocusTrap>
);

View file

@ -23,6 +23,7 @@ describe('useHoverActionItems', () => {
field: 'signal.rule.name',
handleHoverActionClicked: jest.fn(),
hideTopN: false,
isCaseView: false,
isObjectArray: false,
ownFocus: false,
showTopN: false,
@ -158,4 +159,29 @@ describe('useHoverActionItems', () => {
});
});
});
test('should not have filter in, filter out, or toggle column', async () => {
await act(async () => {
const { result, waitForNextUpdate } = renderHook(() => {
const testProps = {
...defaultProps,
isCaseView: true,
enableOverflowButton: false,
};
return useHoverActionItems(testProps);
});
await waitForNextUpdate();
expect(result.current.allActionItems).toHaveLength(3);
expect(result.current.allActionItems[0].props['data-test-subj']).toEqual(
'hover-actions-add-timeline'
);
expect(result.current.allActionItems[1].props['data-test-subj']).toEqual(
'hover-actions-show-top-n'
);
expect(result.current.allActionItems[2].props['data-test-subj']).toEqual(
'hover-actions-copy-button'
);
});
});
});

View file

@ -32,6 +32,7 @@ export interface UseHoverActionItemsProps {
field: string;
handleHoverActionClicked: () => void;
hideTopN: boolean;
isCaseView: boolean;
isObjectArray: boolean;
isOverflowPopoverOpen?: boolean;
itemsToShow?: number;
@ -60,6 +61,7 @@ export const useHoverActionItems = ({
field,
handleHoverActionClicked,
hideTopN,
isCaseView,
isObjectArray,
isOverflowPopoverOpen,
itemsToShow = 2,
@ -119,9 +121,8 @@ export const useHoverActionItems = ({
* in the case of `EnableOverflowButton`, we only need to hide all the items in the overflow popover as the chart's panel opens in the overflow popover, so non-overflowed actions are not affected.
*/
const showFilters =
values != null && (enableOverflowButton || (!showTopN && !enableOverflowButton));
const shouldDisableColumnToggle = isObjectArray && field !== 'geo_point';
values != null && (enableOverflowButton || (!showTopN && !enableOverflowButton)) && !isCaseView;
const shouldDisableColumnToggle = (isObjectArray && field !== 'geo_point') || isCaseView;
const allItems = useMemo(
() =>
@ -275,7 +276,7 @@ export const useHoverActionItems = ({
() =>
[
...allItems.slice(0, itemsToShow),
...(enableOverflowButton && itemsToShow > 0
...(enableOverflowButton && itemsToShow > 0 && itemsToShow < allItems.length
? [
getOverflowButton({
closePopOver: handleHoverActionClicked,