mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Security Solution][RAC] Hide filters on case view (#110090)
This commit is contained in:
parent
c113c237f8
commit
7d66cf9882
3 changed files with 37 additions and 7 deletions
|
@ -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>
|
||||
);
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue