Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -45,7 +45,7 @@ export interface UtilityBarActionProps extends LinkIconProps {
}

export const UtilityBarAction = React.memo<UtilityBarActionProps>(
({ children, color, href, iconSide, iconSize, iconType, onClick, popoverContent }) => (
({ children, color, disabled, href, iconSide, iconSize, iconType, onClick, popoverContent }) => (
<BarAction>
{popoverContent ? (
<Popover
Expand All @@ -60,6 +60,7 @@ export const UtilityBarAction = React.memo<UtilityBarActionProps>(
) : (
<LinkIcon
color={color}
disabled={disabled}
href={href}
iconSide={iconSide}
iconSize={iconSize}
Expand Down
12 changes: 10 additions & 2 deletions x-pack/legacy/plugins/siem/public/components/link_icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import styled, { css } from 'styled-components';

interface LinkProps {
color?: LinkAnchorProps['color'];
disabled?: boolean;
href?: string;
iconSide?: 'left' | 'right';
onClick?: Function;
Expand Down Expand Up @@ -51,8 +52,15 @@ export interface LinkIconProps extends LinkProps {
}

export const LinkIcon = React.memo<LinkIconProps>(
({ children, color, href, iconSide = 'left', iconSize = 's', iconType, onClick }) => (
<Link className="siemLinkIcon" color={color} href={href} iconSide={iconSide} onClick={onClick}>
({ children, color, disabled, href, iconSide = 'left', iconSize = 's', iconType, onClick }) => (
<Link
className="siemLinkIcon"
color={color}
disabled={disabled}
href={href}
iconSide={iconSide}
onClick={onClick}
>
<EuiIcon size={iconSize} type={iconType} />
<span className="siemLinkIcon__label">{children}</span>
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ describe('helpers', () => {
description: '',
deletedEventIds: [],
eventIdToNoteIds: {},
eventType: 'raw',
filters: [],
highlightedDropAndProviderId: '',
historyIds: [],
Expand Down Expand Up @@ -329,6 +330,7 @@ describe('helpers', () => {
description: '',
deletedEventIds: [],
eventIdToNoteIds: {},
eventType: 'raw',
filters: [],
highlightedDropAndProviderId: '',
historyIds: [],
Expand Down Expand Up @@ -415,6 +417,7 @@ describe('helpers', () => {
description: '',
deletedEventIds: [],
eventIdToNoteIds: {},
eventType: 'raw',
filters: [],
highlightedDropAndProviderId: '',
historyIds: [],
Expand Down Expand Up @@ -536,6 +539,7 @@ describe('helpers', () => {
description: '',
deletedEventIds: [],
eventIdToNoteIds: {},
eventType: 'raw',
filters: [
{
$state: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const isUntitled = ({ title }: OpenTimelineResult): boolean =>
const omitTypename = (key: string, value: keyof TimelineModel) =>
key === '__typename' ? undefined : value;

const omitTypenameInTimeline = (timeline: TimelineResult): TimelineResult =>
export const omitTypenameInTimeline = (timeline: TimelineResult): TimelineResult =>
JSON.parse(JSON.stringify(timeline), omitTypename);

const parseString = (params: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import { EventsLoading, EventsTd, EventsTdContent, EventsTdGroupActions } from '
import { eventHasNotes, getPinTooltip } from '../helpers';
import * as i18n from '../translations';
import { OnRowSelected } from '../../events';
import { TimelineNonEcsData } from '../../../../graphql/types';
import { Ecs } from '../../../../graphql/types';

export interface TimelineActionProps {
eventId: string;
data: TimelineNonEcsData[];
ecsData: Ecs;
}

export interface TimelineAction {
getAction: ({ eventId, data }: TimelineActionProps) => JSX.Element;
getAction: ({ eventId, ecsData }: TimelineActionProps) => JSX.Element;
width: number;
id: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { useMemo } from 'react';
import uuid from 'uuid';

import { TimelineNonEcsData } from '../../../../graphql/types';
import { TimelineNonEcsData, Ecs } from '../../../../graphql/types';
import { Note } from '../../../../lib/note';
import { AssociateNote, UpdateNote } from '../../../notes/helpers';
import { OnColumnResized, OnPinEvent, OnRowSelected, OnUnPinEvent } from '../../events';
Expand All @@ -26,6 +26,7 @@ interface Props {
columnHeaders: ColumnHeader[];
columnRenderers: ColumnRenderer[];
data: TimelineNonEcsData[];
ecsData: Ecs;
eventIdToNoteIds: Readonly<Record<string, string[]>>;
expanded: boolean;
getNotesByIds: (noteIds: string[]) => Note[];
Expand Down Expand Up @@ -58,6 +59,7 @@ export const EventColumnView = React.memo<Props>(
columnHeaders,
columnRenderers,
data,
ecsData,
eventIdToNoteIds,
expanded,
getNotesByIds,
Expand All @@ -83,11 +85,11 @@ export const EventColumnView = React.memo<Props>(
return (
timelineTypeContext.timelineActions?.map(action => (
<EventsTdContent key={action.id} textAlign="center">
{action.getAction({ eventId: id, data })}
{action.getAction({ eventId: id, ecsData })}
</EventsTdContent>
)) ?? []
);
}, [data, timelineTypeContext.timelineActions]);
}, [ecsData, timelineTypeContext.timelineActions]);

return (
<EventsTrData data-test-subj="event-column-view">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ColumnHeader } from '../column_headers/column_header';
import { ColumnRenderer } from '../renderers/column_renderer';
import { getRowRenderer } from '../renderers/get_row_renderer';
import { RowRenderer } from '../renderers/row_renderer';
import { getEventType } from '../helpers';
import { StatefulEventChild } from './stateful_event_child';

interface Props {
Expand Down Expand Up @@ -215,6 +216,8 @@ const StatefulEventComponent: React.FC<Props> = ({
<EventsTrGroup
className={STATEFUL_EVENT_CSS_CLASS_NAME}
data-test-subj="event"
eventType={getEventType(event.ecs)}
showLeftBorder={!isEventViewer}
ref={c => {
if (c != null) {
divElement.current = c;
Expand All @@ -232,6 +235,7 @@ const StatefulEventComponent: React.FC<Props> = ({
columnHeaders={columnHeaders}
columnRenderers={columnRenderers}
data={event.data}
ecsData={event.ecs}
eventIdToNoteIds={eventIdToNoteIds}
expanded={!!expanded[event._id]}
getNotesByIds={getNotesByIds}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';
import uuid from 'uuid';

import { TimelineNonEcsData } from '../../../../graphql/types';
import { TimelineNonEcsData, Ecs } from '../../../../graphql/types';
import { Note } from '../../../../lib/note';
import { AddNoteToEvent, UpdateNote } from '../../../notes/helpers';
import { NoteCards } from '../../../notes/note_cards';
Expand All @@ -26,6 +26,7 @@ interface Props {
columnHeaders: ColumnHeader[];
columnRenderers: ColumnRenderer[];
data: TimelineNonEcsData[];
ecsData: Ecs;
expanded: boolean;
eventIdToNoteIds: Readonly<Record<string, string[]>>;
isEventViewer?: boolean;
Expand Down Expand Up @@ -61,6 +62,7 @@ export const StatefulEventChild = React.memo<Props>(
columnRenderers,
expanded,
data,
ecsData,
eventIdToNoteIds,
getNotesByIds,
isEventViewer = false,
Expand Down Expand Up @@ -92,6 +94,7 @@ export const StatefulEventChild = React.memo<Props>(
columnHeaders={columnHeaders}
columnRenderers={columnRenderers}
data={data}
ecsData={ecsData}
expanded={expanded}
eventIdToNoteIds={eventIdToNoteIds}
getNotesByIds={getNotesByIds}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { get, isEmpty, noop } from 'lodash/fp';

import { BrowserFields } from '../../../containers/source';
import { Ecs, TimelineItem, TimelineNonEcsData } from '../../../graphql/types';
import { EventType } from '../../../store/timeline/model';
import { OnPinEvent, OnUnPinEvent } from '../events';
import { ColumnHeader } from './column_headers/column_header';
import * as i18n from './translations';
Expand Down Expand Up @@ -126,3 +127,11 @@ export const getEventIdToDataMapping = (
};
}, {});
};

/** Return eventType raw or signal */
export const getEventType = (event: Ecs): Omit<EventType, 'all'> => {
if (!isEmpty(event.signal?.rule?.id)) {
return 'signal';
}
return 'raw';
};
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ const makeMapStateToProps = () => {
const {
columns,
eventIdToNoteIds,
eventType,
isSelectAllChecked,
loadingEventIds,
pinnedEventIds,
Expand All @@ -292,6 +293,7 @@ const makeMapStateToProps = () => {
return {
columnHeaders: memoizedColumnHeaders(columns, browserFields),
eventIdToNoteIds,
eventType,
isSelectAllChecked,
loadingEventIds,
notesById: getNotesByIds(state),
Expand Down
23 changes: 20 additions & 3 deletions x-pack/legacy/plugins/siem/public/components/timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { isEqual } from 'lodash/fp';
import React, { useEffect, useCallback } from 'react';
import React, { useEffect, useCallback, useMemo } from 'react';
import { connect } from 'react-redux';
import { ActionCreator } from 'typescript-fsa';

Expand All @@ -14,7 +14,8 @@ import { esFilters } from '../../../../../../../src/plugins/data/public';
import { WithSource } from '../../containers/source';
import { inputsModel, inputsSelectors, State, timelineSelectors } from '../../store';
import { timelineActions } from '../../store/actions';
import { KqlMode, timelineDefaults, TimelineModel } from '../../store/timeline/model';
import { EventType, KqlMode, timelineDefaults, TimelineModel } from '../../store/timeline/model';
import { useSignalIndex } from '../../containers/detection_engine/signals/use_signal_index';

import { ColumnHeader } from './body/column_headers/column_header';
import { DataProvider, QueryOperator } from './data_providers/data_provider';
Expand All @@ -41,6 +42,7 @@ interface StateReduxProps {
activePage?: number;
columns: ColumnHeader[];
dataProviders?: DataProvider[];
eventType: EventType;
end: number;
filters: esFilters.Filter[];
isLive: boolean;
Expand Down Expand Up @@ -139,6 +141,7 @@ const StatefulTimelineComponent = React.memo<Props>(
columns,
createTimeline,
dataProviders,
eventType,
end,
filters,
flyoutHeaderHeight,
Expand All @@ -163,6 +166,15 @@ const StatefulTimelineComponent = React.memo<Props>(
updateItemsPerPage,
upsertColumn,
}) => {
const [loading, signalIndexExists, signalIndexName] = useSignalIndex();

const indexToAdd = useMemo<string[]>(() => {
if (signalIndexExists && signalIndexName != null && ['signal', 'all'].includes(eventType)) {
return [signalIndexName];
}
return [];
}, [eventType, signalIndexExists, signalIndexName]);

const onDataProviderRemoved: OnDataProviderRemoved = useCallback(
(providerId: string, andProviderId?: string) =>
removeProvider!({ id, providerId, andProviderId }),
Expand Down Expand Up @@ -249,7 +261,7 @@ const StatefulTimelineComponent = React.memo<Props>(
}, []);

return (
<WithSource sourceId="default">
<WithSource sourceId="default" indexToAdd={indexToAdd}>
{({ indexPattern, browserFields }) => (
<Timeline
browserFields={browserFields}
Expand All @@ -261,11 +273,13 @@ const StatefulTimelineComponent = React.memo<Props>(
flyoutHeight={flyoutHeight}
id={id}
indexPattern={indexPattern}
indexToAdd={indexToAdd}
isLive={isLive}
itemsPerPage={itemsPerPage!}
itemsPerPageOptions={itemsPerPageOptions!}
kqlMode={kqlMode}
kqlQueryExpression={kqlQueryExpression}
loadingIndexName={loading}
onChangeDataProviderKqlQuery={onChangeDataProviderKqlQuery}
onChangeDroppableAndProvider={onChangeDroppableAndProvider}
onChangeItemsPerPage={onChangeItemsPerPage}
Expand All @@ -286,6 +300,7 @@ const StatefulTimelineComponent = React.memo<Props>(
(prevProps, nextProps) => {
return (
prevProps.activePage === nextProps.activePage &&
prevProps.eventType === nextProps.eventType &&
prevProps.end === nextProps.end &&
prevProps.flyoutHeaderHeight === nextProps.flyoutHeaderHeight &&
prevProps.flyoutHeight === nextProps.flyoutHeight &&
Expand Down Expand Up @@ -320,6 +335,7 @@ const makeMapStateToProps = () => {
const {
columns,
dataProviders,
eventType,
filters,
itemsPerPage,
itemsPerPageOptions,
Expand All @@ -334,6 +350,7 @@ const makeMapStateToProps = () => {
return {
columns,
dataProviders,
eventType,
end: input.timerange.to,
filters: timelineFilter,
id,
Expand Down
Loading