Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Remove sourcerer browser fields hover actions to help performance #131363

Merged
merged 22 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1ddf8c0
Batch setState calls to make sure all state updates are applied evenly
kqualters-elastic May 2, 2022
959b049
Remove sourcerer hook from useHoverActions and pass needed fields as …
kqualters-elastic May 3, 2022
ccbb9eb
Merge remote-tracking branch 'upstream/main' into browser-fields-hove…
kqualters-elastic May 3, 2022
40465da
Merge remote-tracking branch 'upstream/main' into browser-fields-hove…
kqualters-elastic May 3, 2022
df7aeaf
Update snapshots, remove ReactDOM batching
kqualters-elastic May 3, 2022
57f3f98
Merge remote-tracking branch 'upstream/main' into browser-fields-hove…
kqualters-elastic May 3, 2022
45c13c0
Make row renderers aggregatable where appropriate
kqualters-elastic May 3, 2022
1617ae0
Merge branch 'main' of github.com:elastic/kibana into browser-fields-…
kqualters-elastic May 3, 2022
4214fa3
add pagination to details table
michaelolo24 May 3, 2022
3e171e3
Fix hover actions on host/network details
kqualters-elastic May 3, 2022
6f55873
Remove unneeded props
kqualters-elastic May 3, 2022
45ef2b7
fix table pagination tests
michaelolo24 May 3, 2022
5a09f1a
update test
michaelolo24 May 4, 2022
d2df97d
Merge branch 'main' into browser-fields-hover-actions
kqualters-elastic May 5, 2022
125d9d0
Show top n for authentications and threat indicator match rules
kqualters-elastic May 6, 2022
990e15f
Fix anomaly score, entity, influence, and user id show top N
kqualters-elastic May 9, 2022
db52dd2
Pass props on wrapper and not data provider
kqualters-elastic May 9, 2022
5903ef9
Merge branch 'main' into browser-fields-hover-actions
kqualters-elastic May 12, 2022
530ff2e
Add missing row renderer draggables to use top N props
kqualters-elastic May 12, 2022
dfd636a
Update snapshots
kqualters-elastic May 12, 2022
f20041d
Pr feedback
kqualters-elastic May 12, 2022
0ff6ed5
Merge branch 'main' into browser-fields-hover-actions
May 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const FAILURES_COLUMN: Columns<AuthenticationsEdges, AuthenticationsEdges> = {
operator: IS_OPERATOR,
},
}}
isAggregatable={true}
fieldType={'keyword'}
Copy link
Contributor

@janmonschke janmonschke May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fieldType="keyword" 💅

render={(dataProvider, _, snapshot) =>
snapshot.isDragging ? (
<DragEffects>
Expand Down Expand Up @@ -129,6 +131,8 @@ const LAST_SUCCESSFUL_SOURCE_COLUMN: Columns<AuthenticationsEdges, Authenticatio
render: ({ node }) =>
getRowItemDraggables({
rowItems: node.lastSuccess?.source?.ip || null,
isAggregatable: true,
fieldType: 'ip',
attrName: 'source.ip',
idPrefix: `authentications-table-${node._id}-lastSuccessSource`,
render: (item) => <NetworkDetailsLink ip={item} />,
Expand All @@ -141,6 +145,8 @@ const LAST_SUCCESSFUL_DESTINATION_COLUMN: Columns<AuthenticationsEdges, Authenti
render: ({ node }) =>
getRowItemDraggables({
rowItems: node.lastSuccess?.host?.name ?? null,
isAggregatable: true,
fieldType: 'keyword',
attrName: 'host.name',
idPrefix: `authentications-table-${node._id}-lastSuccessfulDestination`,
render: (item) => <HostDetailsLink hostName={item} />,
Expand All @@ -164,6 +170,8 @@ const LAST_FAILED_SOURCE_COLUMN: Columns<AuthenticationsEdges, AuthenticationsEd
render: ({ node }) =>
getRowItemDraggables({
rowItems: node.lastFailure?.source?.ip || null,
isAggregatable: true,
fieldType: 'ip',
attrName: 'source.ip',
idPrefix: `authentications-table-${node._id}-lastFailureSource`,
render: (item) => <NetworkDetailsLink ip={item} />,
Expand All @@ -179,6 +187,8 @@ const LAST_FAILED_DESTINATION_COLUMN: Columns<AuthenticationsEdges, Authenticati
attrName: 'host.name',
idPrefix: `authentications-table-${node._id}-lastFailureDestination`,
render: (item) => <HostDetailsLink hostName={item} />,
isAggregatable: true,
fieldType: 'ip',
}),
};

Expand All @@ -192,6 +202,8 @@ const getUserColumn = (
getRowItemDraggables({
rowItems: node.stackedValue,
attrName: 'user.name',
isAggregatable: true,
fieldType: 'keyword',
idPrefix: `authentications-table-${node._id}-userName`,
render: (item) => (usersEnabled ? <UserDetailsLink userName={item} /> : <>{item}</>),
}),
Expand All @@ -205,6 +217,8 @@ const HOST_COLUMN: Columns<AuthenticationsEdges, AuthenticationsEdges> = {
getRowItemDraggables({
rowItems: node.stackedValue,
attrName: 'host.name',
isAggregatable: true,
fieldType: 'keyword',
idPrefix: `authentications-table-${node._id}-hostName`,
render: (item) => <HostDetailsLink hostName={item} />,
}),
Expand Down Expand Up @@ -234,6 +248,8 @@ const SUCCESS_COLUMN: Columns<AuthenticationsEdges, AuthenticationsEdges> = {
operator: IS_OPERATOR,
},
}}
isAggregatable={true}
fieldType={'keyword'}
render={(dataProvider, _, snapshot) =>
snapshot.isDragging ? (
<DragEffects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ interface Props {
hideTopN?: boolean;
isDraggable?: boolean;
render: RenderFunctionProp;
isAggregatable?: boolean;
fieldType?: string;
timelineId?: string;
truncate?: boolean;
onFilterAdded?: () => void;
Expand Down Expand Up @@ -131,6 +133,8 @@ const DraggableOnWrapperComponent: React.FC<Props> = ({
hideTopN = false,
onFilterAdded,
render,
fieldType = '',
isAggregatable = false,
timelineId,
truncate,
}) => {
Expand All @@ -154,6 +158,8 @@ const DraggableOnWrapperComponent: React.FC<Props> = ({
hideTopN,
onFilterAdded,
render,
fieldType,
isAggregatable,
timelineId,
truncate,
});
Expand Down Expand Up @@ -313,6 +319,8 @@ const DraggableWrapperComponent: React.FC<Props> = ({
isDraggable = false,
onFilterAdded,
render,
isAggregatable = false,
fieldType = '',
timelineId,
truncate,
}) => {
Expand All @@ -327,6 +335,8 @@ const DraggableWrapperComponent: React.FC<Props> = ({
dataProvider,
hideTopN,
isDraggable,
isAggregatable,
fieldType,
onFilterAdded,
render,
timelineId,
Expand Down Expand Up @@ -372,6 +382,8 @@ const DraggableWrapperComponent: React.FC<Props> = ({
dataProvider={dataProvider}
hideTopN={hideTopN}
onFilterAdded={onFilterAdded}
fieldType={fieldType}
isAggregatable={isAggregatable}
render={render}
timelineId={timelineId}
truncate={truncate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,8 @@ describe('helpers', () => {
test('it returns true for an aggregatable field that is an allowed type', () => {
expect(
allowTopN({
browserField: aggregatableAllowedType,
fieldType: 'keyword',
isAggregatable: true,
fieldName: aggregatableAllowedType.name,
hideTopN: false,
})
Expand All @@ -663,7 +664,8 @@ describe('helpers', () => {
test('it returns true for a allowlisted non-BrowserField', () => {
expect(
allowTopN({
browserField: undefined,
fieldType: 'not right',
isAggregatable: false,
fieldName: 'kibana.alert.rule.name',
hideTopN: false,
})
Expand All @@ -678,7 +680,8 @@ describe('helpers', () => {

expect(
allowTopN({
browserField: nonAggregatableAllowedType,
fieldType: 'keyword',
isAggregatable: false,
fieldName: nonAggregatableAllowedType.name,
hideTopN: false,
})
Expand All @@ -693,31 +696,21 @@ describe('helpers', () => {

expect(
allowTopN({
browserField: aggregatableNotAllowedType,
fieldType: 'text',
isAggregatable: false,
fieldName: aggregatableNotAllowedType.name,
hideTopN: false,
})
).toBe(false);
});

test('it returns false if the BrowserField is missing the aggregatable property', () => {
const missingAggregatable = omit('aggregatable', aggregatableAllowedType);

expect(
allowTopN({
browserField: missingAggregatable,
fieldName: missingAggregatable.name,
hideTopN: false,
})
).toBe(false);
});

test('it returns false if the BrowserField is missing the type property', () => {
const missingType = omit('type', aggregatableAllowedType);

expect(
allowTopN({
browserField: missingType,
fieldType: 'not real',
isAggregatable: false,
fieldName: missingType.name,
hideTopN: false,
})
Expand All @@ -727,7 +720,8 @@ describe('helpers', () => {
test('it returns false for a non-allowlisted field when a BrowserField is not provided', () => {
expect(
allowTopN({
browserField: undefined,
fieldType: 'string',
isAggregatable: false,
fieldName: 'non-allowlisted',
hideTopN: false,
})
Expand All @@ -737,7 +731,8 @@ describe('helpers', () => {
test('it returns false when hideTopN is true', () => {
expect(
allowTopN({
browserField: aggregatableAllowedType,
fieldType: 'keyword',
isAggregatable: true,
fieldName: aggregatableAllowedType.name,
hideTopN: true, // <-- the Top N action shall not be shown for this (otherwise valid) field
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Dispatch } from 'redux';
import { ActionCreator } from 'typescript-fsa';
import { getProviderIdFromDraggable } from '@kbn/securitysolution-t-grid';

import { BrowserField } from '../../containers/source';
import { dragAndDropActions } from '../../store/actions';
import { IdToDataProvider } from '../../store/drag_and_drop/model';
import { addContentToTimeline } from '../../../timelines/components/timeline/data_providers/helpers';
Expand Down Expand Up @@ -90,16 +89,16 @@ export const addProviderToTimeline = ({
};

export const allowTopN = ({
browserField,
isAggregatable,
fieldType,
fieldName,
hideTopN,
}: {
browserField: Partial<BrowserField> | undefined;
fieldName: string;
isAggregatable: boolean;
fieldType: string;
hideTopN: boolean;
}): boolean => {
const isAggregatable = browserField?.aggregatable ?? false;
const fieldType = browserField?.type ?? '';
const isAllowedType = [
'boolean',
'geo-point',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface DefaultDraggableType {
hideTopN?: boolean;
id: string;
isDraggable?: boolean;
fieldType?: string;
isAggregatable?: boolean;
field: string;
value?: string | number | null;
name?: string | null;
Expand Down Expand Up @@ -102,6 +104,8 @@ export const DefaultDraggable = React.memo<DefaultDraggableType>(
id,
isDraggable = true,
field,
fieldType = '',
isAggregatable = false,
value,
name,
children,
Expand Down Expand Up @@ -151,6 +155,8 @@ export const DefaultDraggable = React.memo<DefaultDraggableType>(
return (
<DraggableWrapper
dataProvider={dataProviderProp}
fieldType={fieldType}
isAggregatable={isAggregatable}
hideTopN={hideTopN}
isDraggable={isDraggable}
render={renderCallback}
Expand Down Expand Up @@ -198,6 +204,8 @@ const DraggableBadgeComponent: React.FC<BadgeDraggableType> = ({
value,
iconType,
isDraggable,
isAggregatable,
fieldType,
name,
color = 'hollow',
children,
Expand All @@ -208,6 +216,8 @@ const DraggableBadgeComponent: React.FC<BadgeDraggableType> = ({
<DefaultDraggable
id={`draggable-badge-default-draggable-${contextId}-${eventId}-${field}-${value}`}
isDraggable={isDraggable}
isAggregatable={isAggregatable}
fieldType={fieldType}
field={field}
name={name}
value={value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const StyledEuiInMemoryTable = styled(EuiInMemoryTable as any)`
flex: 1;
overflow: auto;
overflow-x: hidden;

&::-webkit-scrollbar {
height: ${({ theme }) => theme.eui.euiScrollBar};
width: ${({ theme }) => theme.eui.euiScrollBar};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const ActionCell: React.FC<Props> = React.memo(
values,
});

const { aggregatable, type } = fieldFromBrowserField || { aggregatable: false, type: '' };

const [showTopN, setShowTopN] = useState<boolean>(false);
const { timelineId: timelineIdFind } = useContext(TimelineContext);
const [hoverActionsOwnFocus] = useState<boolean>(false);
Expand All @@ -74,6 +76,8 @@ export const ActionCell: React.FC<Props> = React.memo(
dataProvider={actionCellConfig?.dataProvider}
enableOverflowButton={true}
field={data.field}
isAggregatable={aggregatable}
fieldType={type}
hideAddToTimeline={hideAddToTimeline}
isObjectArray={data.isObjectArray}
onFilterAdded={onFilterAdded}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const FieldValueCell = React.memo(
fieldFormat={data.format}
fieldName={data.field}
fieldType={data.type}
isAggregatable={fieldFromBrowserField.aggregatable}
isDraggable={isDraggable}
isObjectArray={data.isObjectArray}
value={value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ interface Props {
draggableId?: DraggableId;
enableOverflowButton?: boolean;
field: string;
fieldType: string;
isAggregatable: boolean;
goGetTimelineId?: (args: boolean) => void;
hideAddToTimeline?: boolean;
hideTopN?: boolean;
Expand Down Expand Up @@ -136,6 +138,8 @@ export const HoverActions: React.FC<Props> = React.memo(
enableOverflowButton = false,
applyWidthAndPadding = true,
field,
fieldType,
isAggregatable,
goGetTimelineId,
isObjectArray,
hideAddToTimeline = false,
Expand Down Expand Up @@ -219,6 +223,8 @@ export const HoverActions: React.FC<Props> = React.memo(
draggableId,
enableOverflowButton: enableOverflowButton && !isCaseView,
field,
fieldType,
isAggregatable,
handleHoverActionClicked,
hideAddToTimeline,
hideTopN,
Expand Down
Loading