Skip to content

Commit bdfed38

Browse files
committed
Init
1 parent 47e50f8 commit bdfed38

File tree

35 files changed

+409
-349
lines changed

35 files changed

+409
-349
lines changed

x-pack/plugins/security_solution/public/alerts/components/alerts_table/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { useKibana } from '../../../common/lib/kibana';
2121
import { inputsSelectors, State, inputsModel } from '../../../common/store';
2222
import { timelineActions, timelineSelectors } from '../../../timelines/store/timeline';
2323
import { TimelineModel } from '../../../timelines/store/timeline/model';
24-
import { timelineDefaults } from '../../../timelines/store/timeline/defaults';
2524
import { useManageTimeline } from '../../../timelines/components/manage_timeline';
2625
import { useApolloClient } from '../../../common/utils/apollo_context';
2726

@@ -376,7 +375,7 @@ const makeMapStateToProps = () => {
376375
const getGlobalInputs = inputsSelectors.globalSelector();
377376
const mapStateToProps = (state: State, ownProps: OwnProps) => {
378377
const { timelineId } = ownProps;
379-
const timeline: TimelineModel = getTimeline(state, timelineId) ?? timelineDefaults;
378+
const timeline: TimelineModel = getTimeline(state, timelineId);
380379
const { deletedEventIds, isSelectAllChecked, loadingEventIds, selectedEventIds } = timeline;
381380

382381
const globalInputs: inputsModel.InputsRange = getGlobalInputs(state);
@@ -394,30 +393,31 @@ const makeMapStateToProps = () => {
394393
};
395394

396395
const mapDispatchToProps = (dispatch: Dispatch) => ({
397-
clearSelected: ({ id }: { id: string }) => dispatch(timelineActions.clearSelected({ id })),
396+
clearSelected: ({ id }: { id: TimelineIdLiteral }) =>
397+
dispatch(timelineActions.clearSelected({ id })),
398398
setEventsLoading: ({
399399
id,
400400
eventIds,
401401
isLoading,
402402
}: {
403-
id: string;
403+
id: TimelineIdLiteral;
404404
eventIds: string[];
405405
isLoading: boolean;
406406
}) => dispatch(timelineActions.setEventsLoading({ id, eventIds, isLoading })),
407-
clearEventsLoading: ({ id }: { id: string }) =>
407+
clearEventsLoading: ({ id }: { id: TimelineIdLiteral }) =>
408408
dispatch(timelineActions.clearEventsLoading({ id })),
409409
setEventsDeleted: ({
410410
id,
411411
eventIds,
412412
isDeleted,
413413
}: {
414-
id: string;
414+
id: TimelineIdLiteral;
415415
eventIds: string[];
416416
isDeleted: boolean;
417417
}) => dispatch(timelineActions.setEventsDeleted({ id, eventIds, isDeleted })),
418-
clearEventsDeleted: ({ id }: { id: string }) =>
418+
clearEventsDeleted: ({ id }: { id: TimelineIdLiteral }) =>
419419
dispatch(timelineActions.clearEventsDeleted({ id })),
420-
updateTimelineIsLoading: ({ id, isLoading }: { id: string; isLoading: boolean }) =>
420+
updateTimelineIsLoading: ({ id, isLoading }: { id: TimelineIdLiteral; isLoading: boolean }) =>
421421
dispatch(timelineActions.updateIsLoading({ id, isLoading })),
422422
updateTimeline: dispatchUpdateTimeline(dispatch),
423423
});

x-pack/plugins/security_solution/public/alerts/constants.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

x-pack/plugins/security_solution/public/cases/components/user_action_tree/user_action_markdown.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import React, { useCallback } from 'react';
99
import styled, { css } from 'styled-components';
1010

1111
import { useDispatch } from 'react-redux';
12+
import { TimelineIdLiteral } from '../../../../common/types/timeline';
1213
import * as i18n from '../case_view/translations';
1314
import { Markdown } from '../../../common/components/markdown';
1415
import { Form, useForm, UseField } from '../../../shared_imports';
@@ -60,15 +61,15 @@ export const UserActionMarkdown = ({
6061
}, [id, onChangeEditable]);
6162

6263
const handleTimelineClick = useCallback(
63-
(timelineId: string) => {
64+
(timelineId: TimelineIdLiteral) => {
6465
queryTimelineById({
6566
apolloClient,
6667
timelineId,
6768
updateIsLoading: ({
6869
id: currentTimelineId,
6970
isLoading,
7071
}: {
71-
id: string;
72+
id: TimelineIdLiteral;
7273
isLoading: boolean;
7374
}) => dispatch(dispatchUpdateIsLoading({ id: currentTimelineId, isLoading })),
7475
updateTimeline: dispatchUpdateTimeline(dispatch),

x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import React, { useCallback, useMemo, useEffect } from 'react';
88
import { connect, ConnectedProps } from 'react-redux';
99
import deepEqual from 'fast-deep-equal';
1010

11+
import { TimelineIdLiteral } from '../../../../common/types/timeline';
1112
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
1213
import { inputsModel, inputsSelectors, State } from '../../store';
1314
import { inputsActions } from '../../store/actions';
@@ -28,7 +29,7 @@ export interface OwnProps {
2829
defaultIndices?: string[];
2930
defaultModel: SubsetTimelineModel;
3031
end: number;
31-
id: string;
32+
id: TimelineIdLiteral;
3233
start: number;
3334
headerFilterGroup?: React.ReactNode;
3435
pageFilters?: Filter[];

x-pack/plugins/security_solution/public/common/components/markdown/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { EuiLink, EuiTableRow, EuiTableRowCell, EuiText, EuiToolTip } from '@ela
1010
import React from 'react';
1111
import ReactMarkdown from 'react-markdown';
1212
import styled, { css } from 'styled-components';
13+
import { TimelineIdLiteral } from '../../../../common/types/timeline';
1314
import * as i18n from './translations';
1415

1516
const TableHeader = styled.thead`
@@ -38,7 +39,7 @@ const REL_NOREFERRER = 'noreferrer';
3839
export const Markdown = React.memo<{
3940
disableLinks?: boolean;
4041
raw?: string;
41-
onClickTimeline?: (timelineId: string) => void;
42+
onClickTimeline?: (timelineId: TimelineIdLiteral) => void;
4243
size?: 'xs' | 's' | 'm';
4344
}>(({ disableLinks = false, onClickTimeline, raw, size = 's' }) => {
4445
const markdownRenderers = {
@@ -63,7 +64,8 @@ export const Markdown = React.memo<{
6364
),
6465
link: ({ children, href }: { children: React.ReactNode[]; href?: string }) => {
6566
if (onClickTimeline != null && href != null && href.indexOf(`timelines?timeline=(id:`) > -1) {
66-
const timelineId = href.split('timelines?timeline=(id:')[1].split("'")[1] ?? '';
67+
const timelineId = (href.split('timelines?timeline=(id:')[1].split("'")[1] ??
68+
'') as TimelineIdLiteral;
6769
return (
6870
<EuiToolTip content={i18n.TIMELINE_ID(timelineId)}>
6971
<EuiLink

x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222

2323
import { OnTimeChangeProps } from '@elastic/eui';
2424

25+
import { TimelineIdLiteral } from '../../../../common/types/timeline';
2526
import { inputsActions } from '../../store/inputs';
2627
import { InputsRange } from '../../store/inputs/model';
2728
import { InputsModelId } from '../../store/inputs/constants';
@@ -309,7 +310,7 @@ interface UpdateReduxSearchBar extends OnTimeChangeProps {
309310
query?: Query;
310311
savedQuery?: SavedQuery;
311312
resetSavedQuery?: boolean;
312-
timelineId?: string;
313+
timelineId?: TimelineIdLiteral;
313314
updateTime: boolean;
314315
}
315316

x-pack/plugins/security_solution/public/common/components/super_date_picker/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import React, { useState, useCallback } from 'react';
1717
import { connect, ConnectedProps } from 'react-redux';
1818
import { Dispatch } from 'redux';
1919

20+
import { TimelineIdLiteral } from '../../../../common/types/timeline';
2021
import { DEFAULT_TIMEPICKER_QUICK_RANGES } from '../../../../common/constants';
2122
import { timelineActions } from '../../../timelines/store/timeline';
2223
import { useUiSetting$ } from '../../lib/kibana';
@@ -48,7 +49,7 @@ interface Range {
4849
interface UpdateReduxTime extends OnTimeChangeProps {
4950
id: InputsModelId;
5051
kql?: inputsModel.GlobalKqlQuery | undefined;
51-
timelineId?: string;
52+
timelineId?: TimelineIdLiteral;
5253
}
5354

5455
interface ReturnUpdateReduxTime {
@@ -67,7 +68,7 @@ export type DispatchUpdateReduxTime = ({
6768
interface OwnProps {
6869
disabled?: boolean;
6970
id: InputsModelId;
70-
timelineId?: string;
71+
timelineId?: TimelineIdLiteral;
7172
}
7273

7374
export type SuperDatePickerProps = OwnProps & PropsFromRedux;

x-pack/plugins/security_solution/public/common/components/top_n/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const state: State = {
8282
...mockGlobalState.timeline,
8383
timelineById: {
8484
[ACTIVE_TIMELINE_REDUX_ID]: {
85-
...mockGlobalState.timeline.timelineById.test,
85+
...mockGlobalState.timeline.timelineById.test!,
8686
id: ACTIVE_TIMELINE_REDUX_ID,
8787
dataProviders: [
8888
{

x-pack/plugins/security_solution/public/common/components/top_n/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import React, { useMemo } from 'react';
88
import { connect, ConnectedProps } from 'react-redux';
99

10+
import { TimelineId } from '../../../../common/types/timeline';
1011
import { GlobalTime } from '../../containers/global_time';
1112
import { BrowserFields, WithSource } from '../../containers/source';
1213
import { useKibana } from '../../lib/kibana';
@@ -23,7 +24,7 @@ import { TopN } from './top_n';
2324
import { useManageTimeline } from '../../../timelines/components/manage_timeline';
2425

2526
/** The currently active timeline always has this Redux ID */
26-
export const ACTIVE_TIMELINE_REDUX_ID = 'timeline-1';
27+
export const ACTIVE_TIMELINE_REDUX_ID = TimelineId.active;
2728

2829
const EMPTY_FILTERS: Filter[] = [];
2930
const EMPTY_QUERY: Query = { query: '', language: 'kuery' };

x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ export const makeMapStateToProps = () => {
122122

123123
const timeline = Object.entries(getTimelines(state)).reduce(
124124
(obj, [timelineId, timelineObj]) => ({
125-
id: timelineObj.savedObjectId != null ? timelineObj.savedObjectId : '',
126-
isOpen: timelineObj.show,
125+
id: timelineObj?.savedObjectId != null ? timelineObj.savedObjectId : '',
126+
isOpen: timelineObj?.show ?? false,
127127
}),
128128
{ id: '', isOpen: false }
129129
);

0 commit comments

Comments
 (0)