Skip to content

Commit

Permalink
[Security Solution][RAC] Hide filters on case view (#110090)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelolo24 authored Aug 26, 2021
1 parent c113c23 commit 7d66cf9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('useHoverActionItems', () => {
field: 'signal.rule.name',
handleHoverActionClicked: jest.fn(),
hideTopN: false,
isCaseView: false,
isObjectArray: false,
ownFocus: false,
showTopN: false,
Expand Down Expand Up @@ -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'
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface UseHoverActionItemsProps {
field: string;
handleHoverActionClicked: () => void;
hideTopN: boolean;
isCaseView: boolean;
isObjectArray: boolean;
isOverflowPopoverOpen?: boolean;
itemsToShow?: number;
Expand Down Expand Up @@ -60,6 +61,7 @@ export const useHoverActionItems = ({
field,
handleHoverActionClicked,
hideTopN,
isCaseView,
isObjectArray,
isOverflowPopoverOpen,
itemsToShow = 2,
Expand Down Expand Up @@ -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(
() =>
Expand Down Expand Up @@ -275,7 +276,7 @@ export const useHoverActionItems = ({
() =>
[
...allItems.slice(0, itemsToShow),
...(enableOverflowButton && itemsToShow > 0
...(enableOverflowButton && itemsToShow > 0 && itemsToShow < allItems.length
? [
getOverflowButton({
closePopOver: handleHoverActionClicked,
Expand Down

0 comments on commit 7d66cf9

Please sign in to comment.