diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/api.ts b/x-pack/plugins/security_solution/common/api/timeline/model/api.ts index 10b12aee32f2f..1e40484505d1b 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/api.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/model/api.ts @@ -14,7 +14,36 @@ import type { Maybe } from '../../../search_strategy'; import { Direction } from '../../../search_strategy'; import type { PinnedEvent } from '../pinned_events/pinned_events_route'; import { PinnedEventRuntimeType } from '../pinned_events/pinned_events_route'; -// TODO https://github.com/elastic/security-team/issues/7491 +import { ErrorSchema } from './error_schema'; +import type { DataProviderType } from './components.gen'; +import { + DataProviderTypeEnum, + RowRendererId, + RowRendererIdEnum, + SortFieldTimeline, + SortFieldTimelineEnum, + TemplateTimelineType, + TemplateTimelineTypeEnum, + TimelineStatus, + TimelineStatusEnum, + TimelineType, + TimelineTypeEnum, +} from './components.gen'; + +export { + DataProviderType, + DataProviderTypeEnum, + RowRendererId, + RowRendererIdEnum, + SortFieldTimeline, + SortFieldTimelineEnum, + TemplateTimelineType, + TemplateTimelineTypeEnum, + TimelineStatus, + TimelineStatusEnum, + TimelineType, + TimelineTypeEnum, +}; /** * Outcome is a property of the saved object resolve api @@ -40,8 +69,6 @@ export const SavedObjectResolveAliasPurpose = runtimeTypes.union([ runtimeTypes.literal('savedObjectImport'), ]); -import { ErrorSchema } from './error_schema'; - export const BareNoteSchema = runtimeTypes.intersection([ runtimeTypes.type({ timelineId: runtimeTypes.string, @@ -133,14 +160,9 @@ const SavedDataProviderQueryMatchRuntimeType = runtimeTypes.partial({ queryMatch: unionWithNullType(SavedDataProviderQueryMatchBasicRuntimeType), }); -export enum DataProviderType { - default = 'default', - template = 'template', -} - export const DataProviderTypeLiteralRt = runtimeTypes.union([ - runtimeTypes.literal(DataProviderType.default), - runtimeTypes.literal(DataProviderType.template), + runtimeTypes.literal(DataProviderTypeEnum.default), + runtimeTypes.literal(DataProviderTypeEnum.template), ]); const SavedDataProviderRuntimeType = runtimeTypes.partial({ @@ -251,93 +273,26 @@ export type Sort = runtimeTypes.TypeOf; * Timeline Statuses */ -export enum TimelineStatus { - active = 'active', - draft = 'draft', - immutable = 'immutable', -} - export const TimelineStatusLiteralRt = runtimeTypes.union([ - runtimeTypes.literal(TimelineStatus.active), - runtimeTypes.literal(TimelineStatus.draft), - runtimeTypes.literal(TimelineStatus.immutable), + runtimeTypes.literal(TimelineStatusEnum.active), + runtimeTypes.literal(TimelineStatusEnum.draft), + runtimeTypes.literal(TimelineStatusEnum.immutable), ]); -const TimelineStatusLiteralWithNullRt = unionWithNullType(TimelineStatusLiteralRt); - -export type TimelineStatusLiteralWithNull = runtimeTypes.TypeOf< - typeof TimelineStatusLiteralWithNullRt ->; - -export enum RowRendererId { - /** event.kind: signal */ - alert = 'alert', - /** endpoint alerts (created on the endpoint) */ - alerts = 'alerts', - auditd = 'auditd', - auditd_file = 'auditd_file', - library = 'library', - netflow = 'netflow', - plain = 'plain', - registry = 'registry', - suricata = 'suricata', - system = 'system', - system_dns = 'system_dns', - system_endgame_process = 'system_endgame_process', - system_file = 'system_file', - system_fim = 'system_fim', - system_security_event = 'system_security_event', - system_socket = 'system_socket', - threat_match = 'threat_match', - zeek = 'zeek', -} +export const RowRendererCount = Object.keys(RowRendererIdEnum).length; +export const RowRendererValues = Object.values(RowRendererId.Values); -export const RowRendererCount = Object.keys(RowRendererId).length; - -const RowRendererIdRuntimeType = stringEnum(RowRendererId, 'RowRendererId'); +const RowRendererIdRuntimeType = stringEnum(RowRendererIdEnum, 'RowRendererId'); /** - * Timeline template type - */ - -export enum TemplateTimelineType { - elastic = 'elastic', - custom = 'custom', -} - -export const TemplateTimelineTypeLiteralRt = runtimeTypes.union([ - runtimeTypes.literal(TemplateTimelineType.elastic), - runtimeTypes.literal(TemplateTimelineType.custom), -]); - -export const TemplateTimelineTypeLiteralWithNullRt = unionWithNullType( - TemplateTimelineTypeLiteralRt -); - -export type TemplateTimelineTypeLiteral = runtimeTypes.TypeOf; -export type TemplateTimelineTypeLiteralWithNull = runtimeTypes.TypeOf< - typeof TemplateTimelineTypeLiteralWithNullRt ->; - -/* - * Timeline Types + * Timeline types */ -export enum TimelineType { - default = 'default', - template = 'template', -} - export const TimelineTypeLiteralRt = runtimeTypes.union([ - runtimeTypes.literal(TimelineType.template), - runtimeTypes.literal(TimelineType.default), + runtimeTypes.literal(TimelineTypeEnum.template), + runtimeTypes.literal(TimelineTypeEnum.default), ]); -export const TimelineTypeLiteralWithNullRt = unionWithNullType(TimelineTypeLiteralRt); - -export type TimelineTypeLiteral = runtimeTypes.TypeOf; -export type TimelineTypeLiteralWithNull = runtimeTypes.TypeOf; - /** * This is the response type */ @@ -483,18 +438,11 @@ export const TimelineErrorResponseType = runtimeTypes.union([ export type TimelineErrorResponse = runtimeTypes.TypeOf; export type TimelineResponse = runtimeTypes.TypeOf; -export enum SortFieldTimeline { - title = 'title', - description = 'description', - updated = 'updated', - created = 'created', -} - export const sortFieldTimeline = runtimeTypes.union([ - runtimeTypes.literal(SortFieldTimeline.title), - runtimeTypes.literal(SortFieldTimeline.description), - runtimeTypes.literal(SortFieldTimeline.updated), - runtimeTypes.literal(SortFieldTimeline.created), + runtimeTypes.literal(SortFieldTimelineEnum.title), + runtimeTypes.literal(SortFieldTimelineEnum.description), + runtimeTypes.literal(SortFieldTimelineEnum.updated), + runtimeTypes.literal(SortFieldTimelineEnum.created), ]); export const direction = runtimeTypes.union([ @@ -569,7 +517,6 @@ export const pageInfoTimeline = runtimeTypes.type({ export interface PageInfoTimeline { pageIndex: number; - pageSize: number; } @@ -661,16 +608,16 @@ export interface SerializedFilterQueryResult { filterQuery?: Maybe; } -export interface SerializedKueryQueryResult { - kuery?: Maybe; - serializedQuery?: Maybe; -} - export interface KueryFilterQueryResult { kind?: Maybe; expression?: Maybe; } +export interface SerializedKueryQueryResult { + kuery?: Maybe; + serializedQuery?: Maybe; +} + export interface TimelineResult { columns?: Maybe; created?: Maybe; @@ -717,11 +664,6 @@ export interface SortTimeline { sortOrder: Direction; } -export interface ExportTimelineNotFoundError { - statusCode: number; - message: string; -} - export interface GetAllTimelineVariables { pageInfo: PageInfoTimeline; search?: Maybe; diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts index fdc3ef1e1ed52..f0c8985241c05 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts @@ -14,7 +14,6 @@ * version: not applicable */ -import type { ZodTypeDef } from 'zod'; import { z } from 'zod'; /** @@ -33,6 +32,14 @@ export const DataProviderType = z.enum(['default', 'template']); export type DataProviderTypeEnum = typeof DataProviderType.enum; export const DataProviderTypeEnum = DataProviderType.enum; +/** + * The type of the timeline template. + */ +export type TemplateTimelineType = z.infer; +export const TemplateTimelineType = z.enum(['elastic', 'custom']); +export type TemplateTimelineTypeEnum = typeof TemplateTimelineType.enum; +export const TemplateTimelineTypeEnum = TemplateTimelineType.enum; + export type ColumnHeaderResult = z.infer; export const ColumnHeaderResult = z.object({ aggregatable: z.boolean().optional(), @@ -50,46 +57,33 @@ export const ColumnHeaderResult = z.object({ export type QueryMatchResult = z.infer; export const QueryMatchResult = z.object({ - field: z.string().optional(), - displayField: z.string().optional(), - value: z.string().optional(), - displayValue: z.string().optional(), - operator: z.string().optional(), + field: z.string().nullable().optional(), + displayField: z.string().nullable().optional(), + value: z.string().nullable().optional(), + displayValue: z.string().nullable().optional(), + operator: z.string().nullable().optional(), }); -export interface DataProviderResult { - id?: string; - name?: string; - enabled?: boolean; - excluded?: boolean; - kqlQuery?: string; - queryMatch?: QueryMatchResult; - and?: DataProviderResult[]; - type?: DataProviderType; -} -export interface DataProviderResultInput { - id?: string; - name?: string; - enabled?: boolean; - excluded?: boolean; - kqlQuery?: string; - queryMatch?: QueryMatchResult; - and?: DataProviderResultInput[]; - type?: DataProviderType; -} -export const DataProviderResult: z.ZodType< - DataProviderResult, - ZodTypeDef, - DataProviderResultInput -> = z.object({ - id: z.string().optional(), - name: z.string().optional(), - enabled: z.boolean().optional(), - excluded: z.boolean().optional(), - kqlQuery: z.string().optional(), +export type DataProviderQueryMatch = z.infer; +export const DataProviderQueryMatch = z.object({ + enabled: z.boolean().nullable().optional(), + excluded: z.boolean().nullable().optional(), + id: z.string().nullable().optional(), + kqlQuery: z.string().nullable().optional(), + name: z.string().nullable().optional(), queryMatch: QueryMatchResult.optional(), - and: z.array(z.lazy(() => DataProviderResult)).optional(), - type: DataProviderType.optional(), +}); + +export type DataProviderResult = z.infer; +export const DataProviderResult = z.object({ + and: z.array(DataProviderQueryMatch).nullable().optional(), + enabled: z.boolean().nullable().optional(), + excluded: z.boolean().nullable().optional(), + id: z.string().nullable().optional(), + kqlQuery: z.string().nullable().optional(), + name: z.string().nullable().optional(), + queryMatch: QueryMatchResult.nullable().optional(), + type: DataProviderType.nullable().optional(), }); export type RowRendererId = z.infer; @@ -154,31 +148,33 @@ export const SerializedFilterQueryResult = z.object({ .object({ kuery: z .object({ - kind: z.string().optional(), - expression: z.string().optional(), + kind: z.string().nullable().optional(), + expression: z.string().nullable().optional(), }) + .nullable() .optional(), - serializedQuery: z.string().optional(), + serializedQuery: z.string().nullable().optional(), }) + .nullable() .optional(), }); -export type Sort = z.infer; -export const Sort = z.object({ +export type SortObject = z.infer; +export const SortObject = z.object({ columnId: z.string().nullable().optional(), columnType: z.string().nullable().optional(), sortDirection: z.string().nullable().optional(), }); +export type Sort = z.infer; +export const Sort = z.union([SortObject, z.array(SortObject)]); + export type SavedTimeline = z.infer; export const SavedTimeline = z.object({ - columns: ColumnHeaderResult.nullable().optional(), + columns: z.array(ColumnHeaderResult).nullable().optional(), created: z.number().nullable().optional(), createdBy: z.string().nullable().optional(), - dataProviders: z - .array(z.lazy(() => DataProviderResult)) - .nullable() - .optional(), + dataProviders: z.array(DataProviderResult).nullable().optional(), dataViewId: z.string().nullable().optional(), dateRange: z .object({ @@ -190,9 +186,11 @@ export const SavedTimeline = z.object({ description: z.string().nullable().optional(), eqlOptions: z .object({ - eventCategoryField: z.string().optional(), - tiebreakerField: z.string().optional(), - timestampField: z.string().optional(), + eventCategoryField: z.string().nullable().optional(), + query: z.string().nullable().optional(), + size: z.union([z.string().nullable(), z.number().nullable()]).optional(), + tiebreakerField: z.string().nullable().optional(), + timestampField: z.string().nullable().optional(), }) .nullable() .optional(), diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml index 53146d1cbb4d5..d5d4af4cb1e24 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml @@ -21,12 +21,20 @@ components: # enum default value is temporarily unsupported by the code generator # default: default description: The type of data provider to create. Valid values are `default` and `template`. + TemplateTimelineType: + type: string + enum: + - elastic + - custom + description: The type of the timeline template. SavedTimeline: type: object properties: columns: - $ref: '#/components/schemas/ColumnHeaderResult' + type: array nullable: true + items: + $ref: '#/components/schemas/ColumnHeaderResult' created: type: number nullable: true @@ -62,10 +70,22 @@ components: properties: eventCategoryField: type: string + nullable: true + query: + type: string + nullable: true + size: + oneOf: + - type: string + nullable: true + - type: number + nullable: true tiebreakerField: type: string + nullable: true timestampField: type: string + nullable: true eventType: type: string nullable: true @@ -223,35 +243,68 @@ components: properties: field: type: string + nullable: true displayField: type: string + nullable: true value: type: string + nullable: true displayValue: type: string + nullable: true operator: type: string + nullable: true DataProviderResult: type: object properties: + and: + type: array + nullable: true + items: + $ref: '#/components/schemas/DataProviderQueryMatch' + enabled: + type: boolean + nullable: true + excluded: + type: boolean + nullable: true id: type: string + nullable: true + kqlQuery: + type: string + nullable: true name: type: string + nullable: true + queryMatch: + $ref: '#/components/schemas/QueryMatchResult' + nullable: true + type: + $ref: '#/components/schemas/DataProviderType' + nullable: true + DataProviderQueryMatch: + type: object + properties: enabled: type: boolean + nullable: true excluded: type: boolean + nullable: true + id: + type: string + nullable: true kqlQuery: type: string + nullable: true + name: + type: string + nullable: true queryMatch: $ref: '#/components/schemas/QueryMatchResult' - and: - type: array - items: - $ref: '#/components/schemas/DataProviderResult' - type: - $ref: '#/components/schemas/DataProviderType' BareNote: type: object required: [timelineId] @@ -383,16 +436,21 @@ components: properties: filterQuery: type: object + nullable: true properties: kuery: type: object + nullable: true properties: kind: type: string + nullable: true expression: type: string + nullable: true serializedQuery: type: string + nullable: true PinnedEvent: type: object required: [eventId, pinnedEventId, timelineId, version] @@ -418,6 +476,12 @@ components: version: type: string Sort: + oneOf: + - $ref: '#/components/schemas/SortObject' + - type: array + items: + $ref: '#/components/schemas/SortObject' + SortObject: type: object properties: columnId: diff --git a/x-pack/plugins/security_solution/common/search_strategy/timeline/index.ts b/x-pack/plugins/security_solution/common/search_strategy/timeline/index.ts index 49aea54bd74e6..ff9613503e8e3 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/timeline/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/timeline/index.ts @@ -11,7 +11,7 @@ import type { TimelineType, TimelineStatus, RowRendererId, -} from '../../api/timeline/model/api'; +} from '../../api/timeline'; export * from './events'; diff --git a/x-pack/plugins/security_solution/common/types/timeline/store.ts b/x-pack/plugins/security_solution/common/types/timeline/store.ts index 5beb765f3d623..c65705e0c9a74 100644 --- a/x-pack/plugins/security_solution/common/types/timeline/store.ts +++ b/x-pack/plugins/security_solution/common/types/timeline/store.ts @@ -6,7 +6,7 @@ */ import type { Filter } from '@kbn/es-query'; -import type { RowRendererId, TimelineTypeLiteral } from '../../api/timeline/model/api'; +import type { RowRendererId, TimelineType } from '../../api/timeline/model/api'; import type { Direction } from '../../search_strategy'; import type { ColumnHeaderOptions, ColumnId } from '../header_actions'; @@ -52,7 +52,7 @@ export interface TimelinePersistInput { show?: boolean; sort?: SortColumnTimeline[]; showCheckboxes?: boolean; - timelineType?: TimelineTypeLiteral; + timelineType?: TimelineType; templateTimelineId?: string | null; templateTimelineVersion?: number | null; title?: string; diff --git a/x-pack/plugins/security_solution/docs/openapi/ess/security_solution_timeline_api_2023_10_31.bundled.schema.yaml b/x-pack/plugins/security_solution/docs/openapi/ess/security_solution_timeline_api_2023_10_31.bundled.schema.yaml index 65bd6b9517151..e658a2df0284c 100644 --- a/x-pack/plugins/security_solution/docs/openapi/ess/security_solution_timeline_api_2023_10_31.bundled.schema.yaml +++ b/x-pack/plugins/security_solution/docs/openapi/ess/security_solution_timeline_api_2023_10_31.bundled.schema.yaml @@ -1028,27 +1028,55 @@ components: type: boolean type: type: string + DataProviderQueryMatch: + type: object + properties: + enabled: + nullable: true + type: boolean + excluded: + nullable: true + type: boolean + id: + nullable: true + type: string + kqlQuery: + nullable: true + type: string + name: + nullable: true + type: string + queryMatch: + $ref: '#/components/schemas/QueryMatchResult' DataProviderResult: type: object properties: and: items: - $ref: '#/components/schemas/DataProviderResult' + $ref: '#/components/schemas/DataProviderQueryMatch' + nullable: true type: array enabled: + nullable: true type: boolean excluded: + nullable: true type: boolean id: + nullable: true type: string kqlQuery: + nullable: true type: string name: + nullable: true type: string queryMatch: $ref: '#/components/schemas/QueryMatchResult' + nullable: true type: $ref: '#/components/schemas/DataProviderType' + nullable: true DataProviderType: description: >- The type of data provider to create. Valid values are `default` and @@ -1235,14 +1263,19 @@ components: type: object properties: displayField: + nullable: true type: string displayValue: + nullable: true type: string field: + nullable: true type: string operator: + nullable: true type: string value: + nullable: true type: string Readable: type: object @@ -1295,8 +1328,10 @@ components: type: object properties: columns: - $ref: '#/components/schemas/ColumnHeaderResult' + items: + $ref: '#/components/schemas/ColumnHeaderResult' nullable: true + type: array created: nullable: true type: number @@ -1331,10 +1366,22 @@ components: type: object properties: eventCategoryField: + nullable: true + type: string + query: + nullable: true type: string + size: + oneOf: + - nullable: true + type: string + - nullable: true + type: number tiebreakerField: + nullable: true type: string timestampField: + nullable: true type: string eventType: nullable: true @@ -1403,18 +1450,37 @@ components: type: object properties: filterQuery: + nullable: true type: object properties: kuery: + nullable: true type: object properties: expression: + nullable: true type: string kind: + nullable: true type: string serializedQuery: + nullable: true type: string Sort: + oneOf: + - $ref: '#/components/schemas/SortObject' + - items: + $ref: '#/components/schemas/SortObject' + type: array + SortFieldTimeline: + description: The field to sort the timelines by. + enum: + - title + - description + - updated + - created + type: string + SortObject: type: object properties: columnId: @@ -1426,14 +1492,6 @@ components: sortDirection: nullable: true type: string - SortFieldTimeline: - description: The field to sort the timelines by. - enum: - - title - - description - - updated - - created - type: string TimelineResponse: allOf: - $ref: '#/components/schemas/SavedTimeline' diff --git a/x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_timeline_api_2023_10_31.bundled.schema.yaml b/x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_timeline_api_2023_10_31.bundled.schema.yaml index 5a9ecaa0e78b9..d3b079e0551ab 100644 --- a/x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_timeline_api_2023_10_31.bundled.schema.yaml +++ b/x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_timeline_api_2023_10_31.bundled.schema.yaml @@ -1028,27 +1028,55 @@ components: type: boolean type: type: string + DataProviderQueryMatch: + type: object + properties: + enabled: + nullable: true + type: boolean + excluded: + nullable: true + type: boolean + id: + nullable: true + type: string + kqlQuery: + nullable: true + type: string + name: + nullable: true + type: string + queryMatch: + $ref: '#/components/schemas/QueryMatchResult' DataProviderResult: type: object properties: and: items: - $ref: '#/components/schemas/DataProviderResult' + $ref: '#/components/schemas/DataProviderQueryMatch' + nullable: true type: array enabled: + nullable: true type: boolean excluded: + nullable: true type: boolean id: + nullable: true type: string kqlQuery: + nullable: true type: string name: + nullable: true type: string queryMatch: $ref: '#/components/schemas/QueryMatchResult' + nullable: true type: $ref: '#/components/schemas/DataProviderType' + nullable: true DataProviderType: description: >- The type of data provider to create. Valid values are `default` and @@ -1235,14 +1263,19 @@ components: type: object properties: displayField: + nullable: true type: string displayValue: + nullable: true type: string field: + nullable: true type: string operator: + nullable: true type: string value: + nullable: true type: string Readable: type: object @@ -1295,8 +1328,10 @@ components: type: object properties: columns: - $ref: '#/components/schemas/ColumnHeaderResult' + items: + $ref: '#/components/schemas/ColumnHeaderResult' nullable: true + type: array created: nullable: true type: number @@ -1331,10 +1366,22 @@ components: type: object properties: eventCategoryField: + nullable: true + type: string + query: + nullable: true type: string + size: + oneOf: + - nullable: true + type: string + - nullable: true + type: number tiebreakerField: + nullable: true type: string timestampField: + nullable: true type: string eventType: nullable: true @@ -1403,18 +1450,37 @@ components: type: object properties: filterQuery: + nullable: true type: object properties: kuery: + nullable: true type: object properties: expression: + nullable: true type: string kind: + nullable: true type: string serializedQuery: + nullable: true type: string Sort: + oneOf: + - $ref: '#/components/schemas/SortObject' + - items: + $ref: '#/components/schemas/SortObject' + type: array + SortFieldTimeline: + description: The field to sort the timelines by. + enum: + - title + - description + - updated + - created + type: string + SortObject: type: object properties: columnId: @@ -1426,14 +1492,6 @@ components: sortDirection: nullable: true type: string - SortFieldTimeline: - description: The field to sort the timelines by. - enum: - - title - - description - - updated - - created - type: string TimelineResponse: allOf: - $ref: '#/components/schemas/SavedTimeline' diff --git a/x-pack/plugins/security_solution/public/common/components/drag_and_drop/drag_drop_context_wrapper.tsx b/x-pack/plugins/security_solution/public/common/components/drag_and_drop/drag_drop_context_wrapper.tsx index 437309762732d..9c8989abeeab5 100644 --- a/x-pack/plugins/security_solution/public/common/components/drag_and_drop/drag_drop_context_wrapper.tsx +++ b/x-pack/plugins/security_solution/public/common/components/drag_and_drop/drag_drop_context_wrapper.tsx @@ -26,7 +26,7 @@ import { } from '../../hooks/translations'; import { displaySuccessToast, useStateToaster } from '../toasters'; import { TimelineId } from '../../../../common/types/timeline'; -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; import { addProviderToTimeline, fieldWasDroppedOnTimelineColumns, @@ -117,7 +117,7 @@ export const DragDropContextWrapperComponent: React.FC = ({ browserFields const onAddedToTimeline = useCallback( (fieldOrValue: string) => { const message = - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? ADDED_TO_TIMELINE_TEMPLATE_MESSAGE(fieldOrValue) : ADDED_TO_TIMELINE_MESSAGE(fieldOrValue); displaySuccessToast(message, dispatchToaster); diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/table/investigate_in_timeline_button.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/table/investigate_in_timeline_button.tsx index 2b8581aa22d7e..eb43d61b2f8d4 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/table/investigate_in_timeline_button.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/table/investigate_in_timeline_button.tsx @@ -21,7 +21,7 @@ import { sourcererActions } from '../../../store/actions'; import { SourcererScopeName } from '../../../../sourcerer/store/model'; import type { DataProvider } from '../../../../../common/types'; import { TimelineId } from '../../../../../common/types/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useCreateTimeline } from '../../../../timelines/hooks/use_create_timeline'; import { ACTION_INVESTIGATE_IN_TIMELINE } from '../../../../detections/components/alerts_table/translations'; @@ -58,7 +58,7 @@ export const InvestigateInTimelineButton: FC< const clearTimeline = useCreateTimeline({ timelineId: TimelineId.active, - timelineType: hasTemplateProviders ? TimelineType.template : TimelineType.default, + timelineType: hasTemplateProviders ? TimelineTypeEnum.template : TimelineTypeEnum.default, }); const configureAndOpenTimeline = useCallback(async () => { diff --git a/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.tsx b/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.tsx index 141f04b17e1b2..368fda2500fe1 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.tsx @@ -13,7 +13,7 @@ import type { Filter } from '@kbn/es-query'; import { dataTableActions } from '@kbn/securitysolution-data-table'; import type { TableId } from '@kbn/securitysolution-data-table'; import type { CustomBulkAction } from '../../../../common/types'; -import { RowRendererId } from '../../../../common/api/timeline'; +import { RowRendererValues } from '../../../../common/api/timeline'; import { StatefulEventsViewer } from '../events_viewer'; import { eventsDefaultModel } from '../events_viewer/default_model'; import { MatrixHistogram } from '../matrix_histogram'; @@ -131,7 +131,7 @@ const EventsQueryTabBodyComponent: React.FC = const defaultModel = useMemo( () => ({ ...eventsDefaultModel, - excludedRowRendererIds: showExternalAlerts ? Object.values(RowRendererId) : [], + excludedRowRendererIds: showExternalAlerts ? RowRendererValues : [], }), [showExternalAlerts] ); diff --git a/x-pack/plugins/security_solution/public/common/components/header_actions/add_note_icon_item.test.tsx b/x-pack/plugins/security_solution/public/common/components/header_actions/add_note_icon_item.test.tsx index d3299d0816594..98dfc83e9d3e8 100644 --- a/x-pack/plugins/security_solution/public/common/components/header_actions/add_note_icon_item.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/header_actions/add_note_icon_item.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; import { render, screen, waitFor } from '@testing-library/react'; import type { ComponentProps } from 'react'; import React from 'react'; @@ -35,7 +35,7 @@ const toggleShowNotesMock = jest.fn(); const renderTestComponent = (props: Partial> = {}) => { const localProps: ComponentProps = { - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, eventId: 'event-1', ariaLabel: 'Add Note', toggleShowNotes: toggleShowNotesMock, @@ -79,7 +79,7 @@ describe('AddEventNoteAction', () => { ariaLabel: 'Add Note', 'data-test-subj': 'add-note', isDisabled: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, toggleShowNotes: expect.any(Function), toolTip: '2 Notes available. Click to view them & add more.', eventId: 'event-1', @@ -101,7 +101,7 @@ describe('AddEventNoteAction', () => { ariaLabel: 'Add Note', 'data-test-subj': 'add-note', isDisabled: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, toggleShowNotes: expect.any(Function), toolTip: '1 Note available. Click to view it & add more.', eventId: 'event-2', @@ -123,7 +123,7 @@ describe('AddEventNoteAction', () => { ariaLabel: 'Add Note', 'data-test-subj': 'add-note', isDisabled: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, toggleShowNotes: expect.any(Function), toolTip: 'Add Note', eventId: 'event-3', diff --git a/x-pack/plugins/security_solution/public/common/components/header_actions/add_note_icon_item.tsx b/x-pack/plugins/security_solution/public/common/components/header_actions/add_note_icon_item.tsx index ff9ad479e89c9..f9539b9062331 100644 --- a/x-pack/plugins/security_solution/public/common/components/header_actions/add_note_icon_item.tsx +++ b/x-pack/plugins/security_solution/public/common/components/header_actions/add_note_icon_item.tsx @@ -7,7 +7,7 @@ import React, { useMemo } from 'react'; import { NotesButton } from '../../../timelines/components/timeline/properties/helpers'; -import { TimelineType } from '../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../common/api/timeline'; import { useUserPrivileges } from '../user_privileges'; import * as i18n from './translations'; import { ActionIconItem } from './action_icon_item'; @@ -46,7 +46,7 @@ const AddEventNoteActionComponent: React.FC = ({ timelineType={timelineType} toggleShowNotes={toggleShowNotes} toolTip={ - timelineType === TimelineType.template ? i18n.NOTES_DISABLE_TOOLTIP : NOTES_TOOLTIP + timelineType === TimelineTypeEnum.template ? i18n.NOTES_DISABLE_TOOLTIP : NOTES_TOOLTIP } eventId={eventId} notesCount={notesCount} diff --git a/x-pack/plugins/security_solution/public/common/components/header_actions/pin_event_action.test.tsx b/x-pack/plugins/security_solution/public/common/components/header_actions/pin_event_action.test.tsx index 1e30fdc8868bd..33358264d6417 100644 --- a/x-pack/plugins/security_solution/public/common/components/header_actions/pin_event_action.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/header_actions/pin_event_action.test.tsx @@ -12,7 +12,7 @@ import { PinEventAction } from './pin_event_action'; import { useUserPrivileges } from '../user_privileges'; import { getEndpointPrivilegesInitialStateMock } from '../user_privileges/endpoint/mocks'; import { TestProviders } from '../../mock'; -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; jest.mock('../user_privileges'); const useUserPrivilegesMock = useUserPrivileges as jest.Mock; @@ -36,7 +36,7 @@ describe('PinEventAction', () => { noteIds={[]} onPinClicked={jest.fn} eventIsPinned={false} - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> ); @@ -57,7 +57,7 @@ describe('PinEventAction', () => { noteIds={[]} onPinClicked={jest.fn} eventIsPinned={false} - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> ); diff --git a/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_timelines.tsx b/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_timelines.tsx index 98f47334ceca7..3fa8cd2be11bc 100644 --- a/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_timelines.tsx +++ b/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_timelines.tsx @@ -6,10 +6,10 @@ */ import { isEmpty } from 'lodash/fp'; -import type { TimelineTypeLiteral } from '../../../../common/api/timeline'; +import type { TimelineType } from '../../../../common/api/timeline'; import { appendSearch } from './helpers'; -export const getTimelineTabsUrl = (tabName: TimelineTypeLiteral | 'notes', search?: string) => +export const getTimelineTabsUrl = (tabName: TimelineType | 'notes', search?: string) => `/${tabName}${appendSearch(search)}`; export const getTimelineUrl = (id: string, graphEventId?: string) => diff --git a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/use_insight_data_providers.ts b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/use_insight_data_providers.ts index a1976ea75c255..45a4a9f329bc3 100644 --- a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/use_insight_data_providers.ts +++ b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/use_insight_data_providers.ts @@ -9,7 +9,7 @@ import { useMemo } from 'react'; import type { Filter } from '@kbn/es-query'; import { FILTERS, BooleanRelation, FilterStateStore } from '@kbn/es-query'; import type { QueryOperator, DataProvider } from '@kbn/timelines-plugin/common'; -import { DataProviderType } from '../../../../../../common/api/timeline'; +import { DataProviderTypeEnum } from '../../../../../../common/api/timeline'; import { replaceParamsQuery } from './replace_params_query'; import type { TimelineEventsDetailsItem } from '../../../../../../common/search_strategy'; import { @@ -64,7 +64,7 @@ const dataProviderStub: DataProvider = { name: '', excluded: false, kqlQuery: '', - type: DataProviderType.default, + type: DataProviderTypeEnum.default, queryMatch: { field: '', value: '', @@ -88,7 +88,7 @@ const buildDataProviders = ( name: field, excluded, kqlQuery: '', - type: isTemplate ? DataProviderType.template : DataProviderType.default, + type: isTemplate ? DataProviderTypeEnum.template : DataProviderTypeEnum.default, queryMatch: { field, value: result, @@ -102,7 +102,7 @@ const buildDataProviders = ( name: field, excluded, kqlQuery: '', - type: isTemplate ? DataProviderType.template : DataProviderType.default, + type: isTemplate ? DataProviderTypeEnum.template : DataProviderTypeEnum.default, queryMatch: { field, value: result, diff --git a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/use_insight_query.test.ts b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/use_insight_query.test.ts index 1a7e04ee3b0cc..82474c2d381de 100644 --- a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/use_insight_query.test.ts +++ b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/insight/use_insight_query.test.ts @@ -6,7 +6,7 @@ */ import { renderHook } from '@testing-library/react-hooks'; import type { QueryOperator } from '@kbn/timelines-plugin/common'; -import { DataProviderType } from '../../../../../../common/api/timeline'; +import { DataProviderTypeEnum } from '../../../../../../common/api/timeline'; import { useInsightQuery } from './use_insight_query'; import { TestProviders } from '../../../../mock'; import type { UseInsightQuery, UseInsightQueryResult } from './use_insight_query'; @@ -19,7 +19,7 @@ const mockProvider = { name: 'test', excluded: false, kqlQuery: '', - type: DataProviderType.default, + type: DataProviderTypeEnum.default, queryMatch: { field: 'event.id', value: '*', diff --git a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/timeline/plugin.tsx b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/timeline/plugin.tsx index c11bc6ff26186..8350bf7b3f5d5 100644 --- a/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/timeline/plugin.tsx +++ b/x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/timeline/plugin.tsx @@ -9,7 +9,7 @@ import React, { useCallback, memo } from 'react'; import type { EuiSelectableOption, EuiMarkdownEditorUiPlugin } from '@elastic/eui'; import { EuiModalBody, EuiModalHeader, EuiCodeBlock } from '@elastic/eui'; -import { TimelineType } from '../../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../../common/api/timeline'; import { SelectableTimeline } from '../../../../../timelines/components/timeline/selectable_timeline'; import type { OpenTimelineResult } from '../../../../../timelines/components/open_timeline/types'; import { getTimelineUrl, useFormatUrl } from '../../../link_to'; @@ -66,7 +66,7 @@ const TimelineEditorComponent: React.FC = ({ onClosePopover getSelectableOptions={handleGetSelectableOptions} onTimelineChange={handleTimelineChange} onClosePopover={onClosePopover} - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> diff --git a/x-pack/plugins/security_solution/public/common/hooks/timeline/use_timeline_save_prompt.ts b/x-pack/plugins/security_solution/public/common/hooks/timeline/use_timeline_save_prompt.ts index be0fb1d175118..033c0a8c2a0b7 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/timeline/use_timeline_save_prompt.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/timeline/use_timeline_save_prompt.ts @@ -12,7 +12,7 @@ import { useHistory } from 'react-router-dom'; import { useShowTimelineForGivenPath } from '../../utils/timeline/use_show_timeline_for_path'; import type { TimelineId } from '../../../../common/types'; import { TimelineTabs } from '../../../../common/types'; -import { TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../common/api/timeline'; import { useKibana } from '../../lib/kibana'; import { useDeepEqualSelector } from '../use_selector'; import { APP_ID, APP_PATH } from '../../../../common/constants'; @@ -82,7 +82,7 @@ export const useTimelineSavePrompt = ( if ( !getIsTimelineVisible(relativePath) && - (changed || (timelineStatus === TimelineStatus.draft && updated != null)) + (changed || (timelineStatus === TimelineStatusEnum.draft && updated != null)) ) { confirmSaveTimeline(); } else { @@ -111,7 +111,7 @@ export const useTimelineSavePrompt = ( // Confirm when the user has made any changes to a timeline if ( !(nextAppId ?? '').includes(APP_ID) && - (changed || (timelineStatus === TimelineStatus.draft && updated != null)) + (changed || (timelineStatus === TimelineStatusEnum.draft && updated != null)) ) { return actions.confirm( UNSAVED_TIMELINE_SAVE_PROMPT, diff --git a/x-pack/plugins/security_solution/public/common/lib/kuery/index.ts b/x-pack/plugins/security_solution/public/common/lib/kuery/index.ts index 5018abe6bdf62..b3f98a8483f30 100644 --- a/x-pack/plugins/security_solution/public/common/lib/kuery/index.ts +++ b/x-pack/plugins/security_solution/public/common/lib/kuery/index.ts @@ -17,7 +17,7 @@ import memoizeOne from 'memoize-one'; import { prepareKQLParam } from '../../../../common/utils/kql'; import type { BrowserFields } from '../../../../common/search_strategy'; import type { DataProvider, DataProvidersAnd } from '../../../../common/types'; -import { DataProviderType } from '../../../../common/api/timeline'; +import { DataProviderTypeEnum } from '../../../../common/api/timeline'; import { EXISTS_OPERATOR } from '../../../../common/types/timeline'; export type PrimitiveOrArrayOfPrimitives = @@ -125,7 +125,7 @@ const buildQueryMatch = ( ) => `${dataProvider.excluded ? 'NOT ' : ''}${ dataProvider.queryMatch.operator !== EXISTS_OPERATOR && - dataProvider.type !== DataProviderType.template + dataProvider.type !== DataProviderTypeEnum.template ? checkIfFieldTypeIsNested(dataProvider.queryMatch.field, browserFields) ? convertNestedFieldToQuery( dataProvider.queryMatch.field, diff --git a/x-pack/plugins/security_solution/public/common/mock/global_state.ts b/x-pack/plugins/security_solution/public/common/mock/global_state.ts index ab041adfbd5c1..8642a1eab5560 100644 --- a/x-pack/plugins/security_solution/public/common/mock/global_state.ts +++ b/x-pack/plugins/security_solution/public/common/mock/global_state.ts @@ -34,7 +34,7 @@ import { } from '../../../common/constants'; import { networkModel } from '../../explore/network/store'; import { TimelineTabs, TimelineId } from '../../../common/types/timeline'; -import { TimelineType, TimelineStatus } from '../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../common/api/timeline'; import { mockManagementState } from '../../management/store/reducer'; import type { ManagementState } from '../../management/types'; import { initialSourcererState, SourcererScopeName } from '../../sourcerer/store/model'; @@ -364,7 +364,7 @@ export const mockGlobalState: State = { kqlQuery: { filterQuery: null }, loadingEventIds: [], title: '', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, noteIds: [], @@ -386,7 +386,7 @@ export const mockGlobalState: State = { sortDirection: 'desc', }, ], - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, version: null, selectedEventIds: {}, isSelectAllChecked: false, diff --git a/x-pack/plugins/security_solution/public/common/mock/timeline_results.ts b/x-pack/plugins/security_solution/public/common/mock/timeline_results.ts index 2125c234765cb..427285c5f9233 100644 --- a/x-pack/plugins/security_solution/public/common/mock/timeline_results.ts +++ b/x-pack/plugins/security_solution/public/common/mock/timeline_results.ts @@ -11,7 +11,11 @@ import type { DataTableModel } from '@kbn/securitysolution-data-table'; import { VIEW_SELECTION } from '../../../common/constants'; import type { TimelineResult } from '../../../common/api/timeline'; import { TimelineId, TimelineTabs } from '../../../common/types/timeline'; -import { RowRendererId, TimelineType, TimelineStatus } from '../../../common/api/timeline'; +import { + RowRendererIdEnum, + TimelineTypeEnum, + TimelineStatusEnum, +} from '../../../common/api/timeline'; import type { OpenTimelineResult } from '../../timelines/components/open_timeline/types'; import type { TimelineEventsDetailsItem } from '../../../common/search_strategy'; @@ -128,7 +132,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 1', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -242,7 +246,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 2', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -356,7 +360,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 2', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -470,7 +474,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 3', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -584,7 +588,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 4', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -698,7 +702,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 5', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -812,7 +816,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 6', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -926,7 +930,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 7', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -1040,7 +1044,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 7', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -1154,7 +1158,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 7', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -1268,7 +1272,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 7', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -1382,7 +1386,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 7', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -1496,7 +1500,7 @@ export const mockOpenTimelineQueryResults = { noteIds: ['308783f0-7b6d-11e9-980a-e5349fc014ef', '34ec1690-7b6d-11e9-980a-e5349fc014ef'], pinnedEventIds: ['Wl0W12oB9v5HJNSHb400', '410W12oB9v5HJNSHY4wv', 'ZF0W12oB9v5HJNSHwY6L'], title: 'test 7', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, created: 1558386787614, @@ -1920,9 +1924,9 @@ export const mockTimelineModel: TimelineModel = { sortDirection: Direction.desc, }, ], - status: TimelineStatus.active, + status: TimelineStatusEnum.active, title: 'Test rule', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, version: '1', @@ -2001,7 +2005,7 @@ export const mockGetOneTimelineResult: TimelineResult = { ], kqlMode: 'filter', title: 'Test rule', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, savedQueryId: null, @@ -2051,24 +2055,24 @@ export const defaultTimelineProps: CreateTimelineProps = { eventIdToNoteIds: {}, eventType: 'all', excludedRowRendererIds: [ - RowRendererId.alert, - RowRendererId.alerts, - RowRendererId.auditd, - RowRendererId.auditd_file, - RowRendererId.library, - RowRendererId.netflow, - RowRendererId.plain, - RowRendererId.registry, - RowRendererId.suricata, - RowRendererId.system, - RowRendererId.system_dns, - RowRendererId.system_endgame_process, - RowRendererId.system_file, - RowRendererId.system_fim, - RowRendererId.system_security_event, - RowRendererId.system_socket, - RowRendererId.threat_match, - RowRendererId.zeek, + RowRendererIdEnum.alert, + RowRendererIdEnum.alerts, + RowRendererIdEnum.auditd, + RowRendererIdEnum.auditd_file, + RowRendererIdEnum.library, + RowRendererIdEnum.netflow, + RowRendererIdEnum.plain, + RowRendererIdEnum.registry, + RowRendererIdEnum.suricata, + RowRendererIdEnum.system, + RowRendererIdEnum.system_dns, + RowRendererIdEnum.system_endgame_process, + RowRendererIdEnum.system_file, + RowRendererIdEnum.system_fim, + RowRendererIdEnum.system_security_event, + RowRendererIdEnum.system_socket, + RowRendererIdEnum.threat_match, + RowRendererIdEnum.zeek, ], filters: [], highlightedDropAndProviderId: '', @@ -2104,9 +2108,9 @@ export const defaultTimelineProps: CreateTimelineProps = { sortDirection: Direction.desc, }, ], - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, title: '', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineVersion: null, templateTimelineId: null, version: null, diff --git a/x-pack/plugins/security_solution/public/common/store/store.ts b/x-pack/plugins/security_solution/public/common/store/store.ts index ed20e253db538..c9925f2f0a7e2 100644 --- a/x-pack/plugins/security_solution/public/common/store/store.ts +++ b/x-pack/plugins/security_solution/public/common/store/store.ts @@ -21,7 +21,7 @@ import type { EnhancerOptions } from 'redux-devtools-extension'; import type { Storage } from '@kbn/kibana-utils-plugin/public'; import type { CoreStart } from '@kbn/core/public'; import reduceReducers from 'reduce-reducers'; -import { TimelineType } from '../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../common/api/timeline'; import { TimelineId } from '../../../common/types'; import { initialGroupingState } from './grouping/reducer'; import type { GroupState } from './grouping/types'; @@ -122,7 +122,7 @@ export const createStoreFactory = async ( id: TimelineId.active, timelineById: {}, show: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, columns: [], dataViewId: null, indexNames: [], diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx index 0908083a30a18..3d284b89f0745 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx @@ -33,7 +33,7 @@ import { import type { CreateTimeline, UpdateTimelineLoading } from './types'; import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; import type { DataProvider } from '../../../../common/types/timeline'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../common/api/timeline'; import { TimelineId, TimelineTabs } from '../../../../common/types/timeline'; import type { ISearchStart } from '@kbn/data-plugin/public'; import { searchServiceMock } from '@kbn/data-plugin/public/search/mocks'; @@ -440,9 +440,9 @@ describe('alert actions', () => { sortDirection: 'desc', }, ], - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, title: '', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, version: null, diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx index 8e5a25638788e..fdfe314094be6 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx @@ -52,7 +52,7 @@ import { } from '../../../../common/detection_engine/utils'; import type { TimelineResult } from '../../../../common/api/timeline'; import { TimelineId } from '../../../../common/types/timeline'; -import { TimelineStatus, TimelineType } from '../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../common/api/timeline'; import type { SendAlertToTimelineActionProps, ThresholdAggregationData, @@ -990,7 +990,7 @@ export const sendAlertToTimelineAction = async ({ const { timeline, notes } = formatTimelineResultToModel( timelineTemplate, true, - timelineTemplate.timelineType ?? TimelineType.default + timelineTemplate.timelineType ?? TimelineTypeEnum.default ); const query = replaceTemplateFieldFromQuery( timeline.kqlQuery?.filterQuery?.kuery?.expression ?? '', @@ -1056,9 +1056,9 @@ export const sendAlertToTimelineAction = async ({ ...timeline, excludedRowRendererIds: [], title: '', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, dataProviders, eventType: 'all', filters, diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.test.ts b/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.test.ts index 79c93d0d32ba3..41ebf87834bf8 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.test.ts @@ -5,13 +5,11 @@ * 2.0. */ -import { TimelineType } from '../../../../common/api/timeline'; +import { DataProviderTypeEnum, TimelineTypeEnum } from '../../../../common/api/timeline'; import type { Filter } from '@kbn/es-query'; import { FilterStateStore } from '@kbn/es-query'; import type { DataProvider } from '../../../timelines/components/timeline/data_providers/data_provider'; -import { DataProviderType } from '../../../timelines/components/timeline/data_providers/data_provider'; import { mockDataProviders } from '../../../timelines/components/timeline/data_providers/mock/mock_data_providers'; - import { getStringArray, replaceTemplateFieldFromQuery, @@ -143,7 +141,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( '', mockTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual(''); }); @@ -152,7 +150,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( ' ', mockTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual(''); }); @@ -161,7 +159,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( 'host.name: placeholdertext', mockTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual('host.name: apache'); }); @@ -175,7 +173,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( 'host.name: *', dupTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual('host.name: *'); }); @@ -184,7 +182,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( 'user.id: placeholdertext', mockTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual('user.id: placeholdertext'); }); @@ -195,7 +193,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( '', mockTimelineDetails, - TimelineType.template + TimelineTypeEnum.template ); expect(replacement).toEqual(''); }); @@ -204,7 +202,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( ' ', mockTimelineDetails, - TimelineType.template + TimelineTypeEnum.template ); expect(replacement).toEqual(''); }); @@ -213,7 +211,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( 'host.name: placeholdertext', mockTimelineDetails, - TimelineType.template + TimelineTypeEnum.template ); expect(replacement).toEqual('host.name: placeholdertext'); }); @@ -227,7 +225,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( 'host.name: *', dupTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual('host.name: *'); }); @@ -236,7 +234,7 @@ describe('helpers', () => { const replacement = replaceTemplateFieldFromQuery( 'user.id: placeholdertext', mockTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual('user.id: placeholdertext'); }); @@ -323,7 +321,7 @@ describe('helpers', () => { const replacement = reformatDataProviderWithNewValue( mockDataProvider, mockTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual({ id: 'apache', @@ -339,7 +337,7 @@ describe('helpers', () => { displayValue: undefined, }, and: [], - type: TimelineType.default, + type: TimelineTypeEnum.default, }); }); @@ -357,7 +355,7 @@ describe('helpers', () => { const replacement = reformatDataProviderWithNewValue( mockDataProvider, dupTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual({ id: 'apache', @@ -373,7 +371,7 @@ describe('helpers', () => { displayValue: undefined, }, and: [], - type: TimelineType.default, + type: TimelineTypeEnum.default, }); }); @@ -386,7 +384,7 @@ describe('helpers', () => { const replacement = reformatDataProviderWithNewValue( mockDataProvider, mockTimelineDetails, - TimelineType.default + TimelineTypeEnum.default ); expect(replacement).toEqual({ id: 'my-id', @@ -402,7 +400,7 @@ describe('helpers', () => { displayValue: undefined, }, and: [], - type: TimelineType.default, + type: TimelineTypeEnum.default, }); }); }); @@ -414,11 +412,11 @@ describe('helpers', () => { mockDataProvider.id = 'Braden'; mockDataProvider.name = 'Braden'; mockDataProvider.queryMatch.value = '{host.name}'; - mockDataProvider.type = DataProviderType.template; + mockDataProvider.type = DataProviderTypeEnum.template; const replacement = reformatDataProviderWithNewValue( mockDataProvider, mockTimelineDetails, - TimelineType.template + TimelineTypeEnum.template ); expect(replacement).toEqual({ id: 'apache', @@ -434,7 +432,7 @@ describe('helpers', () => { displayValue: undefined, }, and: [], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }); }); @@ -444,11 +442,11 @@ describe('helpers', () => { mockDataProvider.id = 'Braden'; mockDataProvider.name = 'Braden'; mockDataProvider.queryMatch.value = '{host.name}'; - mockDataProvider.type = DataProviderType.default; + mockDataProvider.type = DataProviderTypeEnum.default; const replacement = reformatDataProviderWithNewValue( mockDataProvider, mockTimelineDetails, - TimelineType.template + TimelineTypeEnum.template ); expect(replacement).toEqual({ id: 'Braden', @@ -464,7 +462,7 @@ describe('helpers', () => { displayValue: undefined, }, and: [], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }); }); @@ -479,11 +477,11 @@ describe('helpers', () => { mockDataProvider.id = 'Braden'; mockDataProvider.name = 'Braden'; mockDataProvider.queryMatch.value = '{host.name}'; - mockDataProvider.type = DataProviderType.template; + mockDataProvider.type = DataProviderTypeEnum.template; const replacement = reformatDataProviderWithNewValue( mockDataProvider, dupTimelineDetails, - TimelineType.template + TimelineTypeEnum.template ); expect(replacement).toEqual({ id: 'apache', @@ -499,7 +497,7 @@ describe('helpers', () => { displayValue: undefined, }, and: [], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }); }); @@ -509,11 +507,11 @@ describe('helpers', () => { mockDataProvider.id = 'my-id'; mockDataProvider.name = 'Rebecca'; mockDataProvider.queryMatch.value = 'Rebecca'; - mockDataProvider.type = DataProviderType.default; + mockDataProvider.type = DataProviderTypeEnum.default; const replacement = reformatDataProviderWithNewValue( mockDataProvider, mockTimelineDetails, - TimelineType.template + TimelineTypeEnum.template ); expect(replacement).toEqual({ id: 'my-id', @@ -529,7 +527,7 @@ describe('helpers', () => { displayValue: undefined, }, and: [], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }); }); }); diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.ts b/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.ts index 7221a9ede2785..6d97a32b5fc38 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.ts +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.ts @@ -11,12 +11,15 @@ import type { Filter, KueryNode } from '@kbn/es-query'; import { FilterStateStore, fromKueryExpression } from '@kbn/es-query'; import type { TimelineEventsDetailsItem } from '../../../../common/search_strategy'; -import { TimelineType } from '../../../../common/api/timeline'; +import { + DataProviderTypeEnum, + type TimelineType, + TimelineTypeEnum, +} from '../../../../common/api/timeline'; import type { DataProvider, DataProvidersAnd, } from '../../../timelines/components/timeline/data_providers/data_provider'; -import { DataProviderType } from '../../../timelines/components/timeline/data_providers/data_provider'; interface FindValueToChangeInQuery { field: string; @@ -114,9 +117,9 @@ export const findValueToChangeInQuery = ( export const replaceTemplateFieldFromQuery = ( query: string, eventData: TimelineEventsDetailsItem[], - timelineType: TimelineType = TimelineType.default + timelineType: TimelineType = TimelineTypeEnum.default ): string => { - if (timelineType === TimelineType.default) { + if (timelineType === TimelineTypeEnum.default) { if (query.trim() !== '') { const valueToChange = findValueToChangeInQuery(fromKueryExpression(query)); return valueToChange.reduce((newQuery, vtc) => { @@ -157,10 +160,10 @@ export const replaceTemplateFieldFromMatchFilters = ( export const reformatDataProviderWithNewValue = ( dataProvider: T, eventData: TimelineEventsDetailsItem[], - timelineType: TimelineType = TimelineType.default + timelineType: TimelineType = TimelineTypeEnum.default ): T => { // Support for legacy "template-like" timeline behavior that is using hardcoded list of templateFields - if (timelineType !== TimelineType.template) { + if (timelineType !== TimelineTypeEnum.template) { if (templateFields.includes(dataProvider.queryMatch.field)) { const newValue = getStringArray(dataProvider.queryMatch.field, eventData); if (newValue.length) { @@ -171,13 +174,13 @@ export const reformatDataProviderWithNewValue = dataProviders.map((dataProvider) => { const newDataProvider = reformatDataProviderWithNewValue(dataProvider, eventData, timelineType); diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_bulk_to_timeline.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_bulk_to_timeline.tsx index dee7d665295b8..8cc2c89b76659 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_bulk_to_timeline.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_add_bulk_to_timeline.tsx @@ -26,7 +26,7 @@ import { timelineActions } from '../../../../timelines/store'; import { useCreateTimeline } from '../../../../timelines/hooks/use_create_timeline'; import { INVESTIGATE_BULK_IN_TIMELINE } from '../translations'; import { TimelineId } from '../../../../../common/types/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { sendBulkEventsToTimelineAction } from '../actions'; import type { CreateTimelineProps } from '../types'; import type { SourcererScopeName } from '../../../../sourcerer/store/model'; @@ -138,7 +138,7 @@ export const useAddBulkToTimelineAction = ({ const clearActiveTimeline = useCreateTimeline({ timelineId: TimelineId.active, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); const updateTimelineIsLoading = useCallback( diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.tsx index 786708263fa74..2056de93a63be 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.tsx @@ -22,7 +22,7 @@ import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_ex import { createHistoryEntry } from '../../../../common/utils/global_query_string/helpers'; import { useKibana } from '../../../../common/lib/kibana'; import { TimelineId } from '../../../../../common/types/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { timelineActions } from '../../../../timelines/store'; import { sendAlertToTimelineAction } from '../actions'; import { useUpdateTimeline } from '../../../../timelines/components/open_timeline/use_update_timeline'; @@ -141,7 +141,7 @@ export const useInvestigateInTimeline = ({ const clearActiveTimeline = useCreateTimeline({ timelineId: TimelineId.active, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); const unifiedComponentsInTimelineDisabled = useIsExperimentalFeatureEnabled( @@ -164,7 +164,8 @@ export const useInvestigateInTimeline = ({ indexNames: timeline.indexNames ?? [], show: true, excludedRowRendererIds: - !unifiedComponentsInTimelineDisabled && timeline.timelineType !== TimelineType.template + !unifiedComponentsInTimelineDisabled && + timeline.timelineType !== TimelineTypeEnum.template ? timeline.excludedRowRendererIds : [], }, diff --git a/x-pack/plugins/security_solution/public/overview/components/detection_response/hooks/use_navigate_to_timeline.tsx b/x-pack/plugins/security_solution/public/overview/components/detection_response/hooks/use_navigate_to_timeline.tsx index b5b6503262217..ee44b775766cc 100644 --- a/x-pack/plugins/security_solution/public/overview/components/detection_response/hooks/use_navigate_to_timeline.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/detection_response/hooks/use_navigate_to_timeline.tsx @@ -16,7 +16,7 @@ import { } from '../../../../common/components/event_details/table/use_action_cell_data_provider'; import type { DataProvider, QueryOperator } from '../../../../../common/types/timeline'; import { TimelineId } from '../../../../../common/types/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useCreateTimeline } from '../../../../timelines/hooks/use_create_timeline'; import { updateProviders } from '../../../../timelines/store/actions'; import { sourcererSelectors } from '../../../../common/store'; @@ -36,7 +36,7 @@ export const useNavigateToTimeline = () => { const clearTimeline = useCreateTimeline({ timelineId: TimelineId.active, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); const navigateToTimeline = useCallback( diff --git a/x-pack/plugins/security_solution/public/overview/components/recent_timelines/index.tsx b/x-pack/plugins/security_solution/public/overview/components/recent_timelines/index.tsx index 7d86ee6a2e5c4..8e6ccb158bfa7 100644 --- a/x-pack/plugins/security_solution/public/overview/components/recent_timelines/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/recent_timelines/index.tsx @@ -9,7 +9,7 @@ import { EuiHorizontalRule, EuiText } from '@elastic/eui'; import React, { useCallback, useMemo, useEffect } from 'react'; import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features'; -import { SortFieldTimeline, TimelineType } from '../../../../common/api/timeline'; +import { SortFieldTimelineEnum, TimelineTypeEnum } from '../../../../common/api/timeline'; import { useGetAllTimeline } from '../../../timelines/containers/all'; import { useQueryTimelineById } from '../../../timelines/components/open_timeline/helpers'; import type { OnOpenTimeline } from '../../../timelines/components/open_timeline/types'; @@ -80,7 +80,7 @@ const StatefulRecentTimelinesComponent: React.FC = ({ filterBy }) => { ); const { fetchAllTimeline, timelines, loading } = useGetAllTimeline(); - const timelineType = TimelineType.default; + const timelineType = TimelineTypeEnum.default; const { timelineStatus } = useTimelineStatus({ timelineType }); useEffect(() => { @@ -91,7 +91,7 @@ const StatefulRecentTimelinesComponent: React.FC = ({ filterBy }) => { }, search: '', sort: { - sortField: SortFieldTimeline.updated, + sortField: SortFieldTimelineEnum.updated, sortOrder: Direction.desc, }, onlyUserFavorite: filterBy === 'favorites', diff --git a/x-pack/plugins/security_solution/public/overview/components/recent_timelines/recent_timelines.tsx b/x-pack/plugins/security_solution/public/overview/components/recent_timelines/recent_timelines.tsx index 92ae01123dab9..5f73a38f86d92 100644 --- a/x-pack/plugins/security_solution/public/overview/components/recent_timelines/recent_timelines.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/recent_timelines/recent_timelines.tsx @@ -15,7 +15,7 @@ import type { OpenTimelineResult, } from '../../../timelines/components/open_timeline/types'; import { HoverPopover } from '../../../common/components/hover_popover'; -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; import { RecentTimelineCounts } from './counts'; import * as i18n from './translations'; @@ -53,14 +53,14 @@ const RecentTimelinesItem = React.memo( hoverContent={ { ...mockGlobalState.timeline.timelineById, [TimelineId.active]: { ...mockGlobalState.timeline.timelineById.test, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }, }, }, @@ -339,7 +339,7 @@ describe('Missing index patterns', () => { ...mockGlobalState.timeline.timelineById, [TimelineId.active]: { ...mockGlobalState.timeline.timelineById.test, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template as TimelineType, }, }, }, @@ -392,7 +392,7 @@ describe('Missing index patterns', () => { activePatterns: ['myFakebeat-*'], }); const state3 = cloneDeep(state2); - state3.timeline.timelineById[TimelineId.active].timelineType = TimelineType.default; + state3.timeline.timelineById[TimelineId.active].timelineType = TimelineTypeEnum.default; store = createMockStore(state3); render( diff --git a/x-pack/plugins/security_solution/public/sourcerer/components/temporary.tsx b/x-pack/plugins/security_solution/public/sourcerer/components/temporary.tsx index 4d8849f9b1b6c..66899affeb4aa 100644 --- a/x-pack/plugins/security_solution/public/sourcerer/components/temporary.tsx +++ b/x-pack/plugins/security_solution/public/sourcerer/components/temporary.tsx @@ -21,7 +21,7 @@ import * as i18n from './translations'; import { Blockquote, ResetButton } from './helpers'; import { UpdateDefaultDataViewModal } from './update_default_data_view_modal'; import { TimelineId } from '../../../common/types'; -import { TimelineType } from '../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../common/api/timeline'; import { timelineSelectors } from '../../timelines/store'; import { useDeepEqualSelector } from '../../common/hooks/use_selector'; import { timelineDefaults } from '../../timelines/store/defaults'; @@ -46,15 +46,15 @@ interface Props { const translations = { deprecated: { title: { - [TimelineType.default]: i18n.CALL_OUT_DEPRECATED_TITLE, - [TimelineType.template]: i18n.CALL_OUT_DEPRECATED_TEMPLATE_TITLE, + [TimelineTypeEnum.default]: i18n.CALL_OUT_DEPRECATED_TITLE, + [TimelineTypeEnum.template]: i18n.CALL_OUT_DEPRECATED_TEMPLATE_TITLE, }, update: i18n.UPDATE_INDEX_PATTERNS, }, missingPatterns: { title: { - [TimelineType.default]: i18n.CALL_OUT_MISSING_PATTERNS_TITLE, - [TimelineType.template]: i18n.CALL_OUT_MISSING_PATTERNS_TEMPLATE_TITLE, + [TimelineTypeEnum.default]: i18n.CALL_OUT_MISSING_PATTERNS_TITLE, + [TimelineTypeEnum.template]: i18n.CALL_OUT_MISSING_PATTERNS_TEMPLATE_TITLE, }, update: i18n.ADD_INDEX_PATTERN, }, diff --git a/x-pack/plugins/security_solution/public/sourcerer/components/utils.tsx b/x-pack/plugins/security_solution/public/sourcerer/components/utils.tsx index a77655bffcf94..1aa2181f050b7 100644 --- a/x-pack/plugins/security_solution/public/sourcerer/components/utils.tsx +++ b/x-pack/plugins/security_solution/public/sourcerer/components/utils.tsx @@ -8,7 +8,7 @@ import { EuiIcon, EuiLink, EuiToolTip } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import React, { useMemo } from 'react'; -import { TimelineType } from '../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../common/api/timeline'; import { Blockquote } from './helpers'; import * as i18n from './translations'; @@ -41,7 +41,7 @@ export const CurrentPatternsMessage = ({ [activePatterns, deadPatterns.length, selectedPatterns, timelineType] ); - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { return ( selectedPatterns.filter((p) => !activePatterns.includes(p)).join(', '), [activePatterns, selectedPatterns] ); - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { return ( void; timelineType: TimelineType; }) => { - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { return ( void; }) => { - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { return ( { @@ -41,7 +41,7 @@ describe('AddToFavoritesButton', () => { it('should render favorite button enabled and unchecked', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, }); const { getByTestId, queryByTestId } = renderAddFavoritesButton(); @@ -57,7 +57,7 @@ describe('AddToFavoritesButton', () => { it('should render favorite button disabled for a draft timeline', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }); const { getByTestId } = renderAddFavoritesButton(); @@ -68,7 +68,7 @@ describe('AddToFavoritesButton', () => { it('should render favorite button disabled for an immutable timeline', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }); const { getByTestId } = renderAddFavoritesButton(); @@ -91,7 +91,7 @@ describe('AddToFavoritesButton', () => { it('should use id for guided tour if prop is true', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, }); const { getByTestId } = renderAddFavoritesButton(true); diff --git a/x-pack/plugins/security_solution/public/timelines/components/add_to_favorites/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/add_to_favorites/index.tsx index 06055802e2fff..c0c89f1e08a2d 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/add_to_favorites/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/add_to_favorites/index.tsx @@ -12,7 +12,7 @@ import { i18n } from '@kbn/i18n'; import type { State } from '../../../common/store'; import { selectTimelineById } from '../../store/selectors'; import { timelineActions } from '../../store'; -import { TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../common/api/timeline'; import { TIMELINE_TOUR_CONFIG_ANCHORS } from '../timeline/tour/step_config'; const ADD_TO_FAVORITES = i18n.translate( @@ -51,7 +51,7 @@ export const AddToFavoritesButton = React.memo( selectTimelineById(state, timelineId) ); - const isTimelineDraftOrImmutable = status !== TimelineStatus.active; + const isTimelineDraftOrImmutable = status !== TimelineStatusEnum.active; const label = isFavorite ? REMOVE_FROM_FAVORITES : ADD_TO_FAVORITES; const handleClick = useCallback( diff --git a/x-pack/plugins/security_solution/public/timelines/components/bottom_bar/add_timeline_button.tsx b/x-pack/plugins/security_solution/public/timelines/components/bottom_bar/add_timeline_button.tsx index 15d8e188370dc..3d6d3677440cb 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/bottom_bar/add_timeline_button.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/bottom_bar/add_timeline_button.tsx @@ -9,7 +9,7 @@ import { EuiButtonEmpty, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiPopover } import React, { useCallback, useMemo, useState } from 'react'; import * as i18n from './translations'; import { useCreateTimeline } from '../../hooks/use_create_timeline'; -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; import { OpenTimelineModal } from '../open_timeline/open_timeline_modal'; import type { ActionTimelineToShow } from '../open_timeline/types'; @@ -39,12 +39,12 @@ export const AddTimelineButton = React.memo(({ const createNewTimeline = useCreateTimeline({ timelineId, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, onClick: togglePopover, }); const createNewTimelineTemplate = useCreateTimeline({ timelineId, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, onClick: togglePopover, }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/helpers.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/helpers.test.tsx index fa1663c6b6364..ada9bfd8e1aeb 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/helpers.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { DataProviderType } from '../../../../common/api/timeline'; +import { DataProviderTypeEnum } from '../../../../common/api/timeline'; import { mockBrowserFields } from '../../../common/containers/source/mock'; import { @@ -144,7 +144,7 @@ describe('helpers', () => { label: 'is', }, ], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }) ).toBe(true); }); @@ -163,7 +163,7 @@ describe('helpers', () => { label: 'is', }, ], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }) ).toBe(false); }); @@ -182,7 +182,7 @@ describe('helpers', () => { label: 'is one of', }, ], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }) ).toBe(false); }); @@ -201,7 +201,7 @@ describe('helpers', () => { label: '', }, ], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }) ).toBe(false); }); @@ -220,7 +220,7 @@ describe('helpers', () => { label: 'invalid-operator', }, ], - type: DataProviderType.default, + type: DataProviderTypeEnum.default, }) ).toBe(false); }); @@ -239,7 +239,7 @@ describe('helpers', () => { label: 'is one of', }, ], - type: DataProviderType.template, + type: DataProviderTypeEnum.template, }) ).toBe(false); }); @@ -258,7 +258,7 @@ describe('helpers', () => { label: 'is not one of', }, ], - type: DataProviderType.template, + type: DataProviderTypeEnum.template, }) ).toBe(false); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/helpers.tsx b/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/helpers.tsx index f215a790414d4..8de2c2f8e849c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/helpers.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/helpers.tsx @@ -9,7 +9,7 @@ import { findIndex } from 'lodash/fp'; import type { EuiComboBoxOptionOption } from '@elastic/eui'; import type { FieldCategory } from '@kbn/timelines-plugin/common/search_strategy'; -import { DataProviderType } from '../../../../common/api/timeline'; +import { type DataProviderType, DataProviderTypeEnum } from '../../../../common/api/timeline'; import type { BrowserFields } from '../../../common/containers/source'; import { getAllFieldsByName } from '../../../common/containers/source'; @@ -83,7 +83,7 @@ export const selectionsAreValid = ({ const fieldIsValid = browserFields && getAllFieldsByName(browserFields)[fieldId] != null; const operatorIsValid = findIndex((o) => o.label === operator, operatorLabels) !== -1; const isOneOfOperatorSelectionWithTemplate = - type === DataProviderType.template && + type === DataProviderTypeEnum.template && (operator === i18n.IS_ONE_OF || operator === i18n.IS_NOT_ONE_OF); return fieldIsValid && operatorIsValid && !isOneOfOperatorSelectionWithTemplate; diff --git a/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/index.test.tsx index edcadfb2d391a..806fb1f5b0410 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/index.test.tsx @@ -12,11 +12,11 @@ import React from 'react'; import { mockBrowserFields } from '../../../common/containers/source/mock'; import { TestProviders } from '../../../common/mock'; import { - DataProviderType, IS_OPERATOR, EXISTS_OPERATOR, IS_ONE_OF_OPERATOR, } from '../timeline/data_providers/data_provider'; +import { DataProviderTypeEnum } from '../../../../common/api/timeline'; import { StatefulEditDataProvider } from '.'; @@ -393,7 +393,7 @@ describe('StatefulEditDataProvider', () => { providerId={`hosts-table-hostName-${value}`} timelineId={timelineId} value={value} - type={DataProviderType.template} + type={DataProviderTypeEnum.template} /> ); diff --git a/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/index.tsx index ff960c4f60997..75a4ae66f4697 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/edit_data_provider/index.tsx @@ -24,7 +24,7 @@ import type { BrowserFields } from '../../../common/containers/source'; import type { PrimitiveOrArrayOfPrimitives } from '../../../common/lib/kuery'; import type { OnDataProviderEdited } from '../timeline/events'; import type { QueryOperator } from '../timeline/data_providers/data_provider'; -import { DataProviderType } from '../timeline/data_providers/data_provider'; +import { type DataProviderType, DataProviderTypeEnum } from '../../../../common/api/timeline'; import { getCategorizedFieldNames, @@ -86,7 +86,7 @@ export const StatefulEditDataProvider = React.memo( providerId, timelineId, value, - type = DataProviderType.default, + type = DataProviderTypeEnum.default, }) => { const [updatedField, setUpdatedField] = useState([{ label: field }]); const [updatedOperator, setUpdatedOperator] = useState( @@ -105,7 +105,7 @@ export const StatefulEditDataProvider = React.memo( const showValueInput = useMemo( () => - type !== DataProviderType.template && + type !== DataProviderTypeEnum.template && updatedOperator.length > 0 && updatedOperator[0].label !== i18n.EXISTS && updatedOperator[0].label !== i18n.DOES_NOT_EXIST && @@ -137,7 +137,7 @@ export const StatefulEditDataProvider = React.memo( (selectedField: EuiComboBoxOptionOption[]) => { setUpdatedField(selectedField); - if (type === DataProviderType.template) { + if (type === DataProviderTypeEnum.template) { setUpdatedValue(`{${selectedField[0].label}}`); } @@ -256,7 +256,7 @@ export const StatefulEditDataProvider = React.memo( )} - {showComboBoxInput && type !== DataProviderType.template && ( + {showComboBoxInput && type !== DataProviderTypeEnum.template && ( @@ -268,7 +268,7 @@ export const StatefulEditDataProvider = React.memo( - {type === DataProviderType.template && showComboBoxInput && ( + {type === DataProviderTypeEnum.template && showComboBoxInput && ( <> (({ timelin diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/new_timeline_button.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/new_timeline_button.test.tsx index 355668f2b952e..e1fdbe8817041 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/new_timeline_button.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/new_timeline_button.test.tsx @@ -13,7 +13,7 @@ import { timelineActions } from '../../../store'; import { defaultHeaders } from '../../timeline/body/column_headers/default_headers'; import { TestProviders } from '../../../../common/mock'; import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; -import { RowRendererId } from '../../../../../common/api/timeline'; +import { RowRendererValues } from '../../../../../common/api/timeline'; import { defaultUdtHeaders } from '../../timeline/unified_components/default_headers'; jest.mock('../../../../common/components/discover_in_timeline/use_discover_in_timeline_context'); @@ -73,7 +73,7 @@ describe('NewTimelineButton', () => { show: true, timelineType: 'default', updated: undefined, - excludedRowRendererIds: [...Object.keys(RowRendererId)], + excludedRowRendererIds: RowRendererValues, }); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/new_timeline_button.tsx b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/new_timeline_button.tsx index acbf2c12595b9..4b9b8ef136ce0 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/new_timeline_button.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/new_timeline_button.tsx @@ -8,7 +8,7 @@ import { EuiButtonEmpty, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '@elastic/eui'; import React, { useMemo, useState, useCallback } from 'react'; import { useCreateTimeline } from '../../../hooks/use_create_timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import * as i18n from './translations'; interface NewTimelineButtonProps { @@ -27,12 +27,12 @@ export const NewTimelineButton = React.memo(({ timelineId }: NewTimelineButtonPr const createNewTimeline = useCreateTimeline({ timelineId, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, onClick: togglePopover, }); const createNewTimelineTemplate = useCreateTimeline({ timelineId, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, onClick: togglePopover, }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/open_timeline_button.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/open_timeline_button.test.tsx index 9ca5f236f23fe..e0a48cebf4209 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/open_timeline_button.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/open_timeline_button.test.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { OpenTimelineButton } from './open_timeline_button'; import { TestProviders } from '../../../../common/mock/test_providers'; import { useParams } from 'react-router-dom'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useStartTransaction } from '../../../../common/lib/apm/use_start_transaction'; import { useSourcererDataView } from '../../../../sourcerer/containers'; import { useTimelineStatus } from '../../open_timeline/use_timeline_status'; @@ -60,7 +60,7 @@ describe('OpenTimelineButton', () => { }); it('should open the modal after clicking on the button', async () => { - (useParams as jest.Mock).mockReturnValue({ tabName: TimelineType.template }); + (useParams as jest.Mock).mockReturnValue({ tabName: TimelineTypeEnum.template }); (useStartTransaction as jest.Mock).mockReturnValue({ startTransaction: jest.fn() }); (useSourcererDataView as jest.Mock).mockReturnValue({ dataViewId: '', selectedPatterns: [] }); (useTimelineStatus as jest.Mock).mockReturnValue({ diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_button.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_button.test.tsx index fa5d22666ff46..2f923a12e3f33 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_button.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_button.test.tsx @@ -10,7 +10,7 @@ import { render, waitFor } from '@testing-library/react'; import { SaveTimelineButton } from './save_timeline_button'; import { mockTimelineModel, TestProviders } from '../../../../common/mock'; import { useUserPrivileges } from '../../../../common/components/user_privileges'; -import { TimelineStatus } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../../common/api/timeline'; import { useCreateTimeline } from '../../../hooks/use_create_timeline'; jest.mock('../../../../common/components/user_privileges'); @@ -49,7 +49,7 @@ describe('SaveTimelineButton', () => { }); mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, isSaving: false, }); (useCreateTimeline as jest.Mock).mockReturnValue({}); @@ -68,7 +68,7 @@ describe('SaveTimelineButton', () => { }); mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, isSaving: false, }); (useCreateTimeline as jest.Mock).mockReturnValue({}); @@ -98,7 +98,7 @@ describe('SaveTimelineButton', () => { (useUserPrivileges as jest.Mock).mockReturnValue({ kibanaSecuritySolutionsPrivileges: { crud: true }, }); - mockGetState.mockReturnValue({ ...mockTimelineModel, status: TimelineStatus.immutable }); + mockGetState.mockReturnValue({ ...mockTimelineModel, status: TimelineStatusEnum.immutable }); const { getByTestId } = renderSaveTimelineButton(); diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_button.tsx b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_button.tsx index 9d332d66fb2f5..f89471e36827f 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_button.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_button.tsx @@ -8,7 +8,7 @@ import React, { useCallback, useState } from 'react'; import { EuiButton, EuiToolTip } from '@elastic/eui'; import { useSelector } from 'react-redux'; -import { TimelineStatus } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../../common/api/timeline'; import { useUserPrivileges } from '../../../../common/components/user_privileges'; import { SaveTimelineModal } from './save_timeline_modal'; import * as i18n from './translations'; @@ -41,8 +41,8 @@ export const SaveTimelineButton = React.memo(({ timelin const { status, isSaving } = useSelector((state: State) => selectTimelineById(state, timelineId)); - const canSaveTimeline = canEditTimelinePrivilege && status !== TimelineStatus.immutable; - const isUnsaved = status === TimelineStatus.draft; + const canSaveTimeline = canEditTimelinePrivilege && status !== TimelineStatusEnum.immutable; + const isUnsaved = status === TimelineStatusEnum.draft; const unauthorizedMessage = canSaveTimeline ? null : i18n.CALL_OUT_UNAUTHORIZED_MSG; return ( diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.test.tsx index 23885c087c24d..c4b6bcb4cf92c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import { mockTimelineModel, TestProviders } from '../../../../common/mock'; -import { TimelineStatus, TimelineType } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { SaveTimelineModal } from './save_timeline_modal'; import * as i18n from './translations'; @@ -73,8 +73,8 @@ describe('SaveTimelineModal', () => { it('should show correct header for save timeline template modal', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.draft, - timelineType: TimelineType.template, + status: TimelineStatusEnum.draft, + timelineType: TimelineTypeEnum.template, }); const { getByTestId } = renderSaveTimelineModal(); @@ -88,7 +88,7 @@ describe('SaveTimelineModal', () => { it('should render all the dom elements of the modal', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }); const { getByTestId, queryByTestId } = renderSaveTimelineModal(); @@ -120,7 +120,7 @@ describe('SaveTimelineModal', () => { it('should show correct header for edit timeline template modal', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, }); const { getByTestId } = renderSaveTimelineModal(); @@ -131,8 +131,8 @@ describe('SaveTimelineModal', () => { it('should show correct header for save timeline template modal', () => { mockGetState.mockReturnValue({ - status: TimelineStatus.active, - timelineType: TimelineType.template, + status: TimelineStatusEnum.active, + timelineType: TimelineTypeEnum.template, }); const { getByTestId } = renderSaveTimelineModal(); @@ -147,9 +147,9 @@ describe('SaveTimelineModal', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, description: 'my description', - status: TimelineStatus.active, + status: TimelineStatusEnum.active, title: 'my timeline', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); const { getByTestId } = renderSaveTimelineModal(); @@ -179,7 +179,7 @@ describe('SaveTimelineModal', () => { it('should show discard timeline in the close button', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }); const { getByTestId } = renderSaveTimelineModal(true); @@ -192,8 +192,8 @@ describe('SaveTimelineModal', () => { it('should show discard timeline template in the close button', () => { mockGetState.mockReturnValue({ ...mockTimelineModel, - timelineType: TimelineType.template, - status: TimelineStatus.draft, + timelineType: TimelineTypeEnum.template, + status: TimelineStatusEnum.draft, }); const { getByTestId } = renderSaveTimelineModal(true); diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.tsx b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.tsx index 42bcbff20f322..67409a91c8542 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/save_timeline_modal.tsx @@ -26,7 +26,7 @@ import type { State } from '../../../../common/store'; import { selectTimelineById } from '../../../store/selectors'; import { getUseField, Field, Form, useForm } from '../../../../shared_imports'; import { TimelineId } from '../../../../../common/types/timeline'; -import { TimelineStatus, TimelineType } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { timelineActions } from '../../../store'; import * as commonI18n from '../../timeline/properties/translations'; import * as i18n from './translations'; @@ -78,13 +78,13 @@ export const SaveTimelineModal = React.memo( [] ); - const isUnsaved = status === TimelineStatus.draft; + const isUnsaved = status === TimelineStatusEnum.draft; const prevIsSaving = usePrevious(isSaving); // Resetting the timeline by replacing the active one with a new empty one const resetTimeline = useCreateTimeline({ timelineId: TimelineId.active, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); const handleSubmit = useCallback( @@ -139,8 +139,8 @@ export const SaveTimelineModal = React.memo( }, [closeSaveTimeline, resetTimeline, showWarning]); const closeModalText = useMemo(() => { - if (status === TimelineStatus.draft && showWarning) { - return timelineType === TimelineType.template + if (status === TimelineStatusEnum.draft && showWarning) { + return timelineType === TimelineTypeEnum.template ? i18n.DISCARD_TIMELINE_TEMPLATE : i18n.DISCARD_TIMELINE; } @@ -149,11 +149,11 @@ export const SaveTimelineModal = React.memo( const modalHeader = useMemo( () => - status === TimelineStatus.draft - ? timelineType === TimelineType.template + status === TimelineStatusEnum.draft + ? timelineType === TimelineTypeEnum.template ? i18n.SAVE_TIMELINE_TEMPLATE : i18n.SAVE_TIMELINE - : timelineType === TimelineType.template + : timelineType === TimelineTypeEnum.template ? i18n.NAME_TIMELINE_TEMPLATE : i18n.SAVE_TIMELINE, [status, timelineType] @@ -161,8 +161,8 @@ export const SaveTimelineModal = React.memo( const saveButtonTitle = useMemo( () => - status === TimelineStatus.draft && showWarning - ? timelineType === TimelineType.template + status === TimelineStatusEnum.draft && showWarning + ? timelineType === TimelineTypeEnum.template ? i18n.SAVE_TIMELINE_TEMPLATE : i18n.SAVE_TIMELINE : i18n.SAVE, @@ -182,7 +182,7 @@ export const SaveTimelineModal = React.memo( disabled: isSaving, spellCheck: true, placeholder: - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? commonI18n.UNTITLED_TEMPLATE : commonI18n.UNTITLED_TIMELINE, }), diff --git a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/translations.ts b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/translations.ts index 0a388fd6cdbfd..9ffc2f2f00ad1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/modal/actions/translations.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/modal/actions/translations.ts @@ -6,8 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { TimelineTypeLiteral } from '../../../../../common/api/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; export const NEW_TIMELINE_BTN = i18n.translate( 'xpack.securitySolution.timeline.modal.newTimelineBtn', @@ -115,10 +114,10 @@ export const CLOSE_MODAL = i18n.translate( } ); -export const UNSAVED_TIMELINE_WARNING = (timelineType: TimelineTypeLiteral) => +export const UNSAVED_TIMELINE_WARNING = (timelineType: TimelineType) => i18n.translate('xpack.securitySolution.timeline.saveTimeline.modal.warning.title', { values: { - timeline: timelineType === TimelineType.template ? 'timeline template' : 'timeline', + timeline: timelineType === TimelineTypeEnum.template ? 'timeline template' : 'timeline', }, defaultMessage: 'You have an unsaved {timeline}. Do you wish to save it?', }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/new_timeline/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/new_timeline/index.test.tsx index d343bb1371742..8e08e4b957d64 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/new_timeline/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/new_timeline/index.test.tsx @@ -11,7 +11,11 @@ import { NewTimelineButton } from '.'; import { TimelineId } from '../../../../common/types'; import { timelineActions } from '../../store'; import { useDiscoverInTimelineContext } from '../../../common/components/discover_in_timeline/use_discover_in_timeline_context'; -import { RowRendererId, TimelineType } from '../../../../common/api/timeline'; +import { + RowRendererValues, + type TimelineType, + TimelineTypeEnum, +} from '../../../../common/api/timeline'; import { TestProviders } from '../../../common/mock'; import { defaultUdtHeaders } from '../timeline/unified_components/default_headers'; @@ -43,7 +47,7 @@ describe('NewTimelineButton', () => { const spy = jest.spyOn(timelineActions, 'createTimeline'); const { getByTestId, queryByTestId, queryByText } = renderNewTimelineButton( - TimelineType.default + TimelineTypeEnum.default ); const button = getByTestId('timelines-page-create-new-timeline'); @@ -62,9 +66,9 @@ describe('NewTimelineButton', () => { id: TimelineId.active, indexNames: selectedPatterns, show: true, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, updated: undefined, - excludedRowRendererIds: [...Object.values(RowRendererId)], + excludedRowRendererIds: RowRendererValues, }); }); }); @@ -73,7 +77,7 @@ describe('NewTimelineButton', () => { const spy = jest.spyOn(timelineActions, 'createTimeline'); const { getByTestId, queryByTestId, queryByText } = renderNewTimelineButton( - TimelineType.template + TimelineTypeEnum.template ); const button = getByTestId('timelines-page-create-new-timeline-template'); @@ -92,7 +96,7 @@ describe('NewTimelineButton', () => { id: TimelineId.active, indexNames: selectedPatterns, show: true, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, updated: undefined, excludedRowRendererIds: [], }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/new_timeline/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/new_timeline/index.tsx index 2bf38ecf3d5fd..a986f532484f2 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/new_timeline/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/new_timeline/index.tsx @@ -10,7 +10,7 @@ import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { TimelineId } from '../../../../common/types'; import { useCreateTimeline } from '../../hooks/use_create_timeline'; -import { TimelineType } from '../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../common/api/timeline'; const NEW_TIMELINE = i18n.translate('xpack.securitySolution.timelines.newTimelineButtonLabel', { defaultMessage: 'Create new Timeline', @@ -41,7 +41,7 @@ export const NewTimelineButton = React.memo(({ type }) = }); const dataTestSubj = `timelines-page-create-new-${ - type === TimelineType.default ? 'timeline' : 'timeline-template' + type === TimelineTypeEnum.default ? 'timeline' : 'timeline-template' }`; const handleCreateNewTimeline = useCallback(async () => { @@ -55,7 +55,7 @@ export const NewTimelineButton = React.memo(({ type }) = onClick={handleCreateNewTimeline} fill > - {type === TimelineType.default ? NEW_TIMELINE : NEW_TEMPLATE_TIMELINE} + {type === TimelineTypeEnum.default ? NEW_TIMELINE : NEW_TEMPLATE_TIMELINE} ); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/notes/note_cards/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/notes/note_cards/index.test.tsx index f5006589310c1..3bf635fe53a8b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/notes/note_cards/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/notes/note_cards/index.test.tsx @@ -10,7 +10,7 @@ import { mount } from 'enzyme'; import '../../../../common/mock/formatted_relative'; import { NoteCards } from '.'; -import { TimelineStatus } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../../common/api/timeline'; import { TestProviders } from '../../../../common/mock'; import type { TimelineResultNote } from '../../open_timeline/types'; import { TimelineId } from '../../../../../common/types'; @@ -58,7 +58,7 @@ describe('NoteCards', () => { getNewNoteId: jest.fn(), notes: [], showAddNote: true, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, toggleShowAddNote: jest.fn(), updateNote: jest.fn(), timelineId: TimelineId.test, diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/__mocks__/index.ts b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/__mocks__/index.ts index 3a8c347e33951..df761c8854f41 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TimelineStatus, TimelineType } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../../common/api/timeline'; export const mockTimeline = { data: { @@ -144,9 +144,9 @@ export const mockTimeline = { noteIds: [], pinnedEventIds: [], pinnedEventsSaveObject: [], - status: TimelineStatus.active, + status: TimelineStatusEnum.active, title: 'my timeline', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, savedQueryId: null, @@ -398,7 +398,7 @@ export const mockTemplate = { noteIds: [], pinnedEventIds: [], pinnedEventsSaveObject: [], - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, title: 'Generic Process Timeline', timelineType: 'template', templateTimelineId: 'cd55e52b-7bce-4887-88e2-f1ece4c75447', diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/constants.ts b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/constants.ts index 9a261c415545a..458246c097e01 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/constants.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/constants.ts @@ -5,5 +5,7 @@ * 2.0. */ -export const DEFAULT_SORT_FIELD = 'updated'; +import { SortFieldTimelineEnum } from '../../../../common/api/timeline'; + +export const DEFAULT_SORT_FIELD = SortFieldTimelineEnum.updated; export const DEFAULT_SORT_DIRECTION = 'desc'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.test.tsx index 287266eeb1065..8b5a72917d9a0 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.test.tsx @@ -12,7 +12,7 @@ import { useParams } from 'react-router-dom'; import { DeleteTimelineModal } from './delete_timeline_modal'; import * as i18n from '../translations'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; jest.mock('react-router-dom', () => { const actual = jest.requireActual('react-router-dom'); @@ -24,7 +24,7 @@ jest.mock('react-router-dom', () => { describe('DeleteTimelineModal', () => { beforeAll(() => { - (useParams as jest.Mock).mockReturnValue({ tabName: TimelineType.default }); + (useParams as jest.Mock).mockReturnValue({ tabName: TimelineTypeEnum.default }); }); test('it renders the expected title when a timeline is selected', () => { @@ -134,7 +134,7 @@ describe('DeleteTimelineModal', () => { describe('DeleteTimelineTemplateModal', () => { beforeAll(() => { - (useParams as jest.Mock).mockReturnValue({ tabName: TimelineType.template }); + (useParams as jest.Mock).mockReturnValue({ tabName: TimelineTypeEnum.template }); }); test('it renders a deletion warning', () => { diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.tsx index b24913428357b..7ab6532db2b57 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.tsx @@ -12,7 +12,7 @@ import { isEmpty } from 'lodash/fp'; import { useParams } from 'react-router-dom'; import * as i18n from '../translations'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; interface Props { title?: string | null; @@ -28,7 +28,7 @@ export const DELETE_TIMELINE_MODAL_WIDTH = 600; // px export const DeleteTimelineModal = React.memo(({ title, closeModal, onDelete }) => { const { tabName } = useParams<{ tabName: TimelineType }>(); const warning = - tabName === TimelineType.template + tabName === TimelineTypeEnum.template ? i18n.DELETE_TIMELINE_TEMPLATE_WARNING : i18n.DELETE_TIMELINE_WARNING; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.test.tsx index 510871651dd1a..42cb673acc7a0 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.test.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { useParams } from 'react-router-dom'; import { DeleteTimelineModalOverlay } from '.'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import * as i18n from '../translations'; import { useAppToasts } from '../../../../common/hooks/use_app_toasts'; @@ -42,7 +42,7 @@ describe('DeleteTimelineModal', () => { }; beforeAll(() => { - (useParams as jest.Mock).mockReturnValue({ tabName: TimelineType.default }); + (useParams as jest.Mock).mockReturnValue({ tabName: TimelineTypeEnum.default }); }); describe('showModalState', () => { @@ -78,7 +78,7 @@ describe('DeleteTimelineModal', () => { }); test('it shows correct toast message on success for deleted templates', async () => { - (useParams as jest.Mock).mockReturnValue({ tabName: TimelineType.template }); + (useParams as jest.Mock).mockReturnValue({ tabName: TimelineTypeEnum.template }); const wrapper = mountWithIntl(); wrapper.find('button[data-test-subj="confirmModalConfirmButton"]').simulate('click'); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.tsx index b76565989fb74..aa85b4c3f1ee9 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.tsx @@ -12,7 +12,7 @@ import { createGlobalStyle } from 'styled-components'; import { useParams } from 'react-router-dom'; import { DeleteTimelineModal, DELETE_TIMELINE_MODAL_WIDTH } from './delete_timeline_modal'; import type { DeleteTimelines } from '../types'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useAppToasts } from '../../../../common/hooks/use_app_toasts'; import * as i18n from '../translations'; @@ -48,7 +48,7 @@ export const DeleteTimelineModalOverlay = React.memo( deleteTimelines(savedObjectIds, savedSearchIds); addSuccess({ title: - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? i18n.SUCCESSFULLY_DELETED_TIMELINE_TEMPLATES(savedObjectIds.length) : i18n.SUCCESSFULLY_DELETED_TIMELINES(savedObjectIds.length), }); @@ -56,7 +56,7 @@ export const DeleteTimelineModalOverlay = React.memo( deleteTimelines(savedObjectIds); addSuccess({ title: - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? i18n.SUCCESSFULLY_DELETED_TIMELINE_TEMPLATES(savedObjectIds.length) : i18n.SUCCESSFULLY_DELETED_TIMELINES(savedObjectIds.length), }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/edit_timeline_batch_actions.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/edit_timeline_batch_actions.tsx index 073e9c486ac6d..ee4ffc9569445 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/edit_timeline_batch_actions.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/edit_timeline_batch_actions.tsx @@ -9,7 +9,7 @@ import type { EuiBasicTable } from '@elastic/eui'; import { EuiContextMenuPanel, EuiContextMenuItem } from '@elastic/eui'; import React, { useCallback, useMemo } from 'react'; -import { TimelineType } from '../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../common/api/timeline'; import * as i18n from './translations'; import type { DeleteTimelines, OpenTimelineResult } from './types'; @@ -21,7 +21,7 @@ export const useEditTimelineBatchActions = ({ deleteTimelines, selectedItems, tableRef, - timelineType = TimelineType.default, + timelineType = TimelineTypeEnum.default, }: { deleteTimelines?: DeleteTimelines; selectedItems?: OpenTimelineResult[]; @@ -108,7 +108,7 @@ export const useEditTimelineBatchActions = ({ onComplete={onCompleteBatchActions.bind(null, closePopover)} title={ selectedItems?.length !== 1 - ? timelineType === TimelineType.template + ? timelineType === TimelineTypeEnum.template ? i18n.SELECTED_TEMPLATES(selectedItems?.length ?? 0) : i18n.SELECTED_TIMELINES(selectedItems?.length ?? 0) : selectedItems[0]?.title ?? '' diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx index 7b2ab90ca7248..3ca9f88422a24 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx @@ -9,7 +9,7 @@ import React, { useCallback, useEffect } from 'react'; import { useParams } from 'react-router-dom'; import * as i18n from '../translations'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useAppToasts } from '../../../../common/hooks/use_app_toasts'; import { exportSelectedTimeline } from '../../../containers/api'; import { downloadBlob } from '../../../../common/utils/download_blob'; @@ -30,7 +30,7 @@ const ExportTimeline: React.FC<{ addSuccess({ title: - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? i18n.SUCCESSFULLY_EXPORTED_TIMELINE_TEMPLATES(exportCount) : i18n.SUCCESSFULLY_EXPORTED_TIMELINES(exportCount), 'data-test-subj': 'addObjectToContainerSuccess', diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.test.ts b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.test.ts index a647c0ed44535..d2151d8bff509 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.test.ts @@ -24,7 +24,7 @@ import { } from './helpers'; import type { OpenTimelineResult } from './types'; import { TimelineId } from '../../../../common/types/timeline'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../common/api/timeline'; import { mockTimeline as mockSelectedTimeline, mockTemplate as mockSelectedTemplate, @@ -325,14 +325,18 @@ describe('helpers', () => { savedObjectId: 'savedObject-1', title: 'Awesome Timeline', version: '1', - status: TimelineStatus.active, - timelineType: TimelineType.default, + status: TimelineStatusEnum.active, + timelineType: TimelineTypeEnum.default, }; - const newTimeline = defaultTimelineToTimelineModel(timeline, false, TimelineType.template); + const newTimeline = defaultTimelineToTimelineModel( + timeline, + false, + TimelineTypeEnum.template + ); expect(newTimeline).toEqual({ ...defaultTimeline, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, columns: defaultUdtHeaders, }); }); @@ -342,11 +346,11 @@ describe('helpers', () => { savedObjectId: 'savedObject-1', title: 'Awesome Template', version: '1', - status: TimelineStatus.active, - timelineType: TimelineType.template, + status: TimelineStatusEnum.active, + timelineType: TimelineTypeEnum.template, }; - const newTimeline = defaultTimelineToTimelineModel(timeline, false, TimelineType.default); + const newTimeline = defaultTimelineToTimelineModel(timeline, false, TimelineTypeEnum.default); expect(newTimeline).toEqual({ ...defaultTimeline, columns: defaultUdtHeaders, @@ -484,21 +488,21 @@ describe('helpers', () => { savedObjectId: 'savedObject-1', title: 'Awesome Timeline', version: '1', - status: TimelineStatus.immutable, - timelineType: TimelineType.template, + status: TimelineStatusEnum.immutable, + timelineType: TimelineTypeEnum.template, }; const newTimeline = defaultTimelineToTimelineModel( timeline, false, - TimelineType.template, + TimelineTypeEnum.template, false ); expect(newTimeline).toEqual({ ...defaultTimeline, dateRange: { end: '2020-10-28T11:37:31.655Z', start: '2020-10-27T11:37:31.655Z' }, - status: TimelineStatus.immutable, - timelineType: TimelineType.template, + status: TimelineStatusEnum.immutable, + timelineType: TimelineTypeEnum.template, title: 'Awesome Timeline', columns: defaultUdtHeaders, excludedRowRendererIds: [], @@ -510,20 +514,20 @@ describe('helpers', () => { savedObjectId: 'savedObject-1', title: 'Awesome Timeline', version: '1', - status: TimelineStatus.active, - timelineType: TimelineType.default, + status: TimelineStatusEnum.active, + timelineType: TimelineTypeEnum.default, }; const newTimeline = defaultTimelineToTimelineModel( timeline, false, - TimelineType.default, + TimelineTypeEnum.default, false ); expect(newTimeline).toEqual({ ...defaultTimeline, dateRange: { end: '2020-07-08T08:20:18.966Z', start: '2020-07-07T08:20:18.966Z' }, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, title: 'Awesome Timeline', columns: defaultUdtHeaders, }); @@ -534,22 +538,22 @@ describe('helpers', () => { savedObjectId: 'savedObject-1', title: 'Awesome Timeline', version: '1', - status: TimelineStatus.active, - timelineType: TimelineType.default, + status: TimelineStatusEnum.active, + timelineType: TimelineTypeEnum.default, }; const newTimeline = defaultTimelineToTimelineModel( timeline, false, - TimelineType.default, + TimelineTypeEnum.default, false ); expect(newTimeline).toEqual({ ...defaultTimeline, dateRange: { end: '2020-07-08T08:20:18.966Z', start: '2020-07-07T08:20:18.966Z' }, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, title: 'Awesome Timeline', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, defaultColumns: defaultUdtHeaders, columns: defaultUdtHeaders, }); @@ -561,23 +565,23 @@ describe('helpers', () => { savedObjectId: 'savedObject-1', title: 'Awesome Timeline', version: '1', - status: TimelineStatus.active, - timelineType: TimelineType.default, + status: TimelineStatusEnum.active, + timelineType: TimelineTypeEnum.default, columns: customColumns, }; const newTimeline = defaultTimelineToTimelineModel( timeline, false, - TimelineType.default, + TimelineTypeEnum.default, false ); expect(newTimeline).toEqual({ ...defaultTimeline, dateRange: { end: '2020-07-08T08:20:18.966Z', start: '2020-07-07T08:20:18.966Z' }, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, title: 'Awesome Timeline', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, defaultColumns: defaultUdtHeaders, columns: customColumns, }); @@ -623,7 +627,7 @@ describe('helpers', () => { duplicate: false, graphEventId: '', timelineId: '', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, onError, onOpenTimeline, openTimeline: true, @@ -682,7 +686,7 @@ describe('helpers', () => { duplicate: false, graphEventId: '', timelineId: '', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, openTimeline: true, }; @@ -754,7 +758,7 @@ describe('helpers', () => { duplicate: false, graphEventId: '', timelineId: '', - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, onOpenTimeline, openTimeline: true, }; @@ -817,7 +821,7 @@ describe('helpers', () => { duplicate: false, graphEventId: '', timelineId: undefined, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, onOpenTimeline, openTimeline: true, unifiedComponentsInTimelineDisabled: false, @@ -853,7 +857,7 @@ describe('helpers', () => { duplicate: false, graphEventId: '', timelineId: TimelineId.active, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, onOpenTimeline: undefined, openTimeline: true, unifiedComponentsInTimelineDisabled: false, @@ -892,7 +896,7 @@ describe('helpers', () => { duplicate: false, graphEventId: '', timelineId: TimelineId.active, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, onOpenTimeline, openTimeline: true, unifiedComponentsInTimelineDisabled: false, diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.ts b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.ts index ec90e8477c72e..2f4ee8c2e1d20 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.ts @@ -23,10 +23,11 @@ import type { Note, } from '../../../../common/api/timeline'; import { - RowRendererId, - DataProviderType, - TimelineStatus, - TimelineType, + DataProviderTypeEnum, + RowRendererValues, + TimelineStatusEnum, + type TimelineType, + TimelineTypeEnum, } from '../../../../common/api/timeline'; import { TimelineId, TimelineTabs } from '../../../../common/types/timeline'; import { useUpdateTimeline } from './use_update_timeline'; @@ -168,22 +169,22 @@ const getTemplateTimelineId = ( targetTimelineType?: TimelineType ) => { if ( - targetTimelineType === TimelineType.default && - timeline.timelineType === TimelineType.template + targetTimelineType === TimelineTypeEnum.default && + timeline.timelineType === TimelineTypeEnum.template ) { return timeline.templateTimelineId; } - return duplicate && timeline.timelineType === TimelineType.template + return duplicate && timeline.timelineType === TimelineTypeEnum.template ? // TODO: MOVE TO THE BACKEND uuidv4() : timeline.templateTimelineId; }; const convertToDefaultField = ({ and, ...dataProvider }: DataProviderResult) => { - if (dataProvider.type === DataProviderType.template) { + if (dataProvider.type === DataProviderTypeEnum.template) { return deepMerge(dataProvider, { - type: DataProviderType.default, + type: DataProviderTypeEnum.default, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion enabled: dataProvider.queryMatch!.operator !== IS_OPERATOR, queryMatch: { @@ -202,7 +203,7 @@ const getDataProviders = ( dataProviders: TimelineResult['dataProviders'], timelineType?: TimelineType ) => { - if (duplicate && dataProviders && timelineType === TimelineType.default) { + if (duplicate && dataProviders && timelineType === TimelineTypeEnum.default) { return dataProviders.map((dataProvider) => ({ ...convertToDefaultField(dataProvider), and: dataProvider.and?.map(convertToDefaultField) ?? [], @@ -229,9 +230,9 @@ export const getTimelineStatus = ( timelineType?: TimelineType ) => { const isCreateTimelineFromAction = timelineType && timeline.timelineType !== timelineType; - if (isCreateTimelineFromAction) return TimelineStatus.draft; + if (isCreateTimelineFromAction) return TimelineStatusEnum.draft; - return duplicate ? TimelineStatus.active : timeline.status; + return duplicate ? TimelineStatusEnum.active : timeline.status; }; export const defaultTimelineToTimelineModel = ( @@ -240,7 +241,7 @@ export const defaultTimelineToTimelineModel = ( timelineType?: TimelineType, unifiedComponentsInTimelineDisabled?: boolean ): TimelineModel => { - const isTemplate = timeline.timelineType === TimelineType.template; + const isTemplate = timeline.timelineType === TimelineTypeEnum.template; const defaultHeadersValue = !unifiedComponentsInTimelineDisabled ? defaultUdtHeaders : defaultHeaders; @@ -253,15 +254,15 @@ export const defaultTimelineToTimelineModel = ( : defaultHeadersValue, defaultColumns: defaultHeadersValue, dateRange: - timeline.status === TimelineStatus.immutable && - timeline.timelineType === TimelineType.template + timeline.status === TimelineStatusEnum.immutable && + timeline.timelineType === TimelineTypeEnum.template ? { start: DEFAULT_FROM_MOMENT.toISOString(), end: DEFAULT_TO_MOMENT.toISOString(), } : timeline.dateRange, dataProviders: getDataProviders(duplicate, timeline.dataProviders, timelineType), - excludedRowRendererIds: isTemplate ? [] : Object.keys(RowRendererId), + excludedRowRendererIds: isTemplate ? [] : RowRendererValues, eventIdToNoteIds: setEventIdToNoteIds(duplicate, timeline.eventIdToNoteIds), filters: timeline.filters != null ? timeline.filters.map(setTimelineFilters) : [], isFavorite: duplicate @@ -365,7 +366,7 @@ export const useQueryTimelineById = () => { initialized: true, savedSearchId: savedSearchId ?? null, excludedRowRendererIds: - !unifiedComponentsInTimelineDisabled && timelineType !== TimelineType.template + !unifiedComponentsInTimelineDisabled && timelineType !== TimelineTypeEnum.template ? timelineDefaults.excludedRowRendererIds : [], }, diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/index.test.tsx index 26a6b69709640..68f6071200ec1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/index.test.tsx @@ -13,7 +13,7 @@ import { useHistory, useParams } from 'react-router-dom'; import '../../../common/mock/formatted_relative'; import { SecurityPageName } from '../../../app/types'; -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; import { TimelineId } from '../../../../common/types'; import { TestProviders, @@ -107,7 +107,7 @@ describe('StatefulOpenTimeline', () => { beforeEach(() => { (useParams as jest.Mock).mockReturnValue({ - tabName: TimelineType.default, + tabName: TimelineTypeEnum.default, pageName: SecurityPageName.timelines, }); useUserPrivilegesMock.mockReturnValue({ @@ -172,12 +172,12 @@ describe('StatefulOpenTimeline', () => { } ); - expect(result.current.timelineType).toBe(TimelineType.default); + expect(result.current.timelineType).toBe(TimelineTypeEnum.default); }); test("should land on correct timelines' tab with url timelines/template", () => { (useParams as jest.Mock).mockReturnValue({ - tabName: TimelineType.template, + tabName: TimelineTypeEnum.template, pageName: SecurityPageName.timelines, }); @@ -188,12 +188,12 @@ describe('StatefulOpenTimeline', () => { } ); - expect(result.current.timelineType).toBe(TimelineType.template); + expect(result.current.timelineType).toBe(TimelineTypeEnum.template); }); test("should land on correct templates' tab after switching tab", async () => { (useParams as jest.Mock).mockReturnValue({ - tabName: TimelineType.template, + tabName: TimelineTypeEnum.template, pageName: SecurityPageName.timelines, }); @@ -209,7 +209,7 @@ describe('StatefulOpenTimeline', () => { ); await waitFor(() => { wrapper - .find(`[data-test-subj="timeline-${TimelineTabsStyle.tab}-${TimelineType.template}"]`) + .find(`[data-test-subj="timeline-${TimelineTabsStyle.tab}-${TimelineTypeEnum.template}"]`) .first() .simulate('click'); @@ -230,7 +230,7 @@ describe('StatefulOpenTimeline', () => { } ); - expect(result.current.timelineType).toBe(TimelineType.default); + expect(result.current.timelineType).toBe(TimelineTypeEnum.default); }); test('should not change url after switching filter', async () => { @@ -252,7 +252,7 @@ describe('StatefulOpenTimeline', () => { await waitFor(() => { wrapper .find( - `[data-test-subj="open-timeline-modal-body-${TimelineTabsStyle.filter}-${TimelineType.template}"]` + `[data-test-subj="open-timeline-modal-body-${TimelineTabsStyle.filter}-${TimelineTypeEnum.template}"]` ) .first() .simulate('click'); @@ -613,7 +613,7 @@ describe('StatefulOpenTimeline', () => { expect( wrapper .find( - `[data-test-subj="open-timeline-modal-body-${TimelineTabsStyle.filter}-${TimelineType.default}"]` + `[data-test-subj="open-timeline-modal-body-${TimelineTabsStyle.filter}-${TimelineTypeEnum.default}"]` ) .exists() ).toEqual(true); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/index.tsx index 18c3255ac848b..ea86d5eaa54fb 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/index.tsx @@ -153,7 +153,7 @@ export const StatefulOpenTimelineComponent = React.memo( /** The requested sort direction of the query results */ const [sortDirection, setSortDirection] = useState<'asc' | 'desc'>(DEFAULT_SORT_DIRECTION); /** The requested field to sort on */ - const [sortField, setSortField] = useState(DEFAULT_SORT_FIELD); + const [sortField, setSortField] = useState(DEFAULT_SORT_FIELD); const getTimeline = useMemo(() => timelineSelectors.getTimelineByIdSelector(), []); const timelineSavedObjectId = useShallowEqualSelector( @@ -194,7 +194,7 @@ export const StatefulOpenTimelineComponent = React.memo( }, search, sort: { - sortField: sortField as SortFieldTimeline, + sortField, sortOrder: sortDirection as Direction, }, onlyUserFavorite: onlyFavorites, @@ -318,7 +318,7 @@ export const StatefulOpenTimelineComponent = React.memo( if (sort != null) { const { field, direction } = sort; setSortDirection(direction); - setSortField(field); + setSortField(field as SortFieldTimeline); } }, []); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.test.tsx index 2ed4300dc7e33..713dff571847b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.test.tsx @@ -17,7 +17,7 @@ import type { TimelinesTableProps } from './timelines_table'; import { mockTimelineResults } from '../../../common/mock/timeline_results'; import { OpenTimeline } from './open_timeline'; import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from './constants'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../common/api/timeline'; import { getMockTheme } from '../../../common/lib/kibana/kibana_react.mock'; import { useUserPrivileges } from '../../../common/components/user_privileges'; @@ -72,8 +72,8 @@ describe('OpenTimeline', () => { sortDirection: DEFAULT_SORT_DIRECTION, sortField: DEFAULT_SORT_FIELD, title, - timelineType: TimelineType.default, - timelineStatus: TimelineStatus.active, + timelineType: TimelineTypeEnum.default, + timelineStatus: TimelineStatusEnum.active, templateTimelineFilter: [
,
], totalSearchResultsCount: mockSearchResults.length, }); @@ -317,7 +317,7 @@ describe('OpenTimeline', () => { test("it should render bulk actions if timelineStatus is active (selecting custom templates' tab)", () => { const defaultProps = { ...getDefaultTestProps(mockResults), - timelineStatus: TimelineStatus.active, + timelineStatus: TimelineStatusEnum.active, }; const wrapper = mountWithIntl( @@ -436,7 +436,7 @@ describe('OpenTimeline', () => { }); const defaultProps = { ...getDefaultTestProps(mockResults), - timelineStatus: TimelineStatus.active, + timelineStatus: TimelineStatusEnum.active, }; const wrapper = mountWithIntl( @@ -455,7 +455,7 @@ describe('OpenTimeline', () => { }); const defaultProps = { ...getDefaultTestProps(mockResults), - timelineStatus: TimelineStatus.active, + timelineStatus: TimelineStatusEnum.active, }; const wrapper = mountWithIntl( @@ -471,7 +471,7 @@ describe('OpenTimeline', () => { test('it should NOT include createFrom, duplicate, createRule, delete in timeline actions when user has read only access', () => { const defaultProps = { ...getDefaultTestProps(mockResults), - timelineStatus: TimelineStatus.active, + timelineStatus: TimelineStatusEnum.active, }; useUserPrivilegesMock.mockReturnValue({ kibanaSecuritySolutionsPrivileges: { crud: false, read: true }, @@ -490,7 +490,7 @@ describe('OpenTimeline', () => { test("it should render selected count if timelineStatus is active (selecting custom templates' tab)", () => { const defaultProps = { ...getDefaultTestProps(mockResults), - timelineStatus: TimelineStatus.active, + timelineStatus: TimelineStatusEnum.active, }; const wrapper = mountWithIntl( @@ -504,7 +504,7 @@ describe('OpenTimeline', () => { test("it should not render bulk actions if timelineStatus is immutable (selecting Elastic templates' tab)", () => { const defaultProps = { ...getDefaultTestProps(mockResults), - timelineStatus: TimelineStatus.immutable, + timelineStatus: TimelineStatusEnum.immutable, }; const wrapper = mountWithIntl( @@ -521,7 +521,7 @@ describe('OpenTimeline', () => { }); const defaultProps = { ...getDefaultTestProps(mockResults), - timelineStatus: TimelineStatus.immutable, + timelineStatus: TimelineStatusEnum.immutable, }; const wrapper = mountWithIntl( @@ -537,7 +537,7 @@ describe('OpenTimeline', () => { test("it should not render selected count if timelineStatus is immutable (selecting Elastic templates' tab)", () => { const defaultProps = { ...getDefaultTestProps(mockResults), - timelineStatus: TimelineStatus.immutable, + timelineStatus: TimelineStatusEnum.immutable, }; const wrapper = mountWithIntl( diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.tsx index 1b20d1643ff3a..524d3bee9640a 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.tsx @@ -10,7 +10,7 @@ import type { EuiBasicTable } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import styled from 'styled-components'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../common/api/timeline'; import { ImportDataModal } from '../../../common/components/import_data_modal'; import { UtilityBarGroup, @@ -65,7 +65,7 @@ export const OpenTimeline = React.memo( setImportDataModalToggle, sortField, tabName, - timelineType = TimelineType.default, + timelineType = TimelineTypeEnum.default, timelineStatus, timelineFilter, templateTimelineFilter, @@ -168,7 +168,7 @@ export const OpenTimeline = React.memo( ...(onCreateRuleFromEql != null ? createRuleFromEql : []), ]; - if (timelineStatus !== TimelineStatus.immutable) { + if (timelineStatus !== TimelineStatusEnum.immutable) { timelineActions.push('export'); timelineActions.push('selectable'); } @@ -176,7 +176,7 @@ export const OpenTimeline = React.memo( if ( onDeleteSelected != null && deleteTimelines != null && - timelineStatus !== TimelineStatus.immutable + timelineStatus !== TimelineStatusEnum.immutable ) { timelineActions.push('delete'); } @@ -184,7 +184,7 @@ export const OpenTimeline = React.memo( return timelineActions; } // user with read access should only see export - if (timelineStatus !== TimelineStatus.immutable) { + if (timelineStatus !== TimelineStatusEnum.immutable) { return ['export', 'selectable']; } return []; @@ -248,15 +248,15 @@ export const OpenTimeline = React.memo( <> {i18n.SHOWING}{' '} - {timelineType === TimelineType.template ? nTemplates : nTimelines} + {timelineType === TimelineTypeEnum.template ? nTemplates : nTimelines} - {timelineStatus !== TimelineStatus.immutable && ( + {timelineStatus !== TimelineStatusEnum.immutable && ( <> - {timelineType === TimelineType.template + {timelineType === TimelineTypeEnum.template ? i18n.SELECTED_TEMPLATES((selectedItems || []).length) : i18n.SELECTED_TIMELINES((selectedItems || []).length)} diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx index 4a817d113c5ca..c4e4b7efbdd1e 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx @@ -16,7 +16,7 @@ import type { TimelinesTableProps } from '../timelines_table'; import { mockTimelineResults } from '../../../../common/mock/timeline_results'; import { OpenTimelineModalBody } from './open_timeline_modal_body'; import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants'; -import { TimelineType, TimelineStatus } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../../common/api/timeline'; import { getMockTheme } from '../../../../common/lib/kibana/kibana_react.mock'; jest.mock('../../../../common/lib/kibana'); @@ -55,8 +55,8 @@ describe('OpenTimelineModal', () => { selectedItems: [], sortDirection: DEFAULT_SORT_DIRECTION, sortField: DEFAULT_SORT_FIELD, - timelineType: TimelineType.default, - timelineStatus: TimelineStatus.active, + timelineType: TimelineTypeEnum.default, + timelineStatus: TimelineStatusEnum.active, templateTimelineFilter: [
], title, totalSearchResultsCount: mockSearchResults.length, diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.test.tsx index e7bda4a5b79b9..ef60552e7c42a 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.test.tsx @@ -10,7 +10,7 @@ import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { SearchRow } from '.'; @@ -32,7 +32,7 @@ describe('SearchRow', () => { onQueryChange={jest.fn()} onToggleOnlyFavorites={jest.fn()} query="" - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> ); @@ -52,7 +52,7 @@ describe('SearchRow', () => { onQueryChange={jest.fn()} onToggleOnlyFavorites={jest.fn()} query="" - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> ); @@ -72,7 +72,7 @@ describe('SearchRow', () => { onQueryChange={jest.fn()} onToggleOnlyFavorites={onToggleOnlyFavorites} query="" - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> ); @@ -90,7 +90,7 @@ describe('SearchRow', () => { onQueryChange={jest.fn()} onToggleOnlyFavorites={jest.fn()} query="" - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> ); @@ -111,7 +111,7 @@ describe('SearchRow', () => { onQueryChange={jest.fn()} onToggleOnlyFavorites={jest.fn()} query="" - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> ); @@ -136,7 +136,7 @@ describe('SearchRow', () => { onQueryChange={onQueryChange} onToggleOnlyFavorites={jest.fn()} query="" - timelineType={TimelineType.default} + timelineType={TimelineTypeEnum.default} /> ); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.tsx index ad198881bfd44..17a12054bfa5d 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.tsx @@ -15,7 +15,7 @@ import { import React, { useMemo } from 'react'; import styled from 'styled-components'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import * as i18n from '../translations'; import type { OpenTimelineProps } from '../types'; @@ -58,7 +58,7 @@ export const SearchRow = React.memo( const searchBox = useMemo( () => ({ placeholder: - timelineType === TimelineType.default + timelineType === TimelineTypeEnum.default ? i18n.SEARCH_PLACEHOLDER : i18n.SEARCH_TEMPLATE_PLACEHOLDER, incremental: false, diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/actions_columns.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/actions_columns.tsx index 8348fc951ac8d..0ad523f34f9fa 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/actions_columns.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/actions_columns.tsx @@ -16,7 +16,7 @@ import type { OnOpenDeleteTimelineModal, } from '../types'; import * as i18n from '../translations'; -import { TimelineStatus, TimelineType } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../../common/api/timeline'; type Action = EuiTableActionsColumnType['actions'][number]; /** @@ -47,7 +47,7 @@ export const getActionsColumns = ({ onClick: ({ savedObjectId }: OpenTimelineResult) => { onOpenTimeline({ duplicate: true, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion timelineId: savedObjectId!, }); @@ -57,7 +57,8 @@ export const getActionsColumns = ({ description: i18n.CREATE_TIMELINE_FROM_TEMPLATE, 'data-test-subj': 'create-from-template', available: (item: OpenTimelineResult) => - item.timelineType === TimelineType.template && actionTimelineToShow.includes('createFrom'), + item.timelineType === TimelineTypeEnum.template && + actionTimelineToShow.includes('createFrom'), } as Action; const createTemplateFromTimeline = { @@ -66,7 +67,7 @@ export const getActionsColumns = ({ onClick: ({ savedObjectId }: OpenTimelineResult) => { onOpenTimeline({ duplicate: true, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion timelineId: savedObjectId!, }); @@ -76,7 +77,8 @@ export const getActionsColumns = ({ description: i18n.CREATE_TEMPLATE_FROM_TIMELINE, 'data-test-subj': 'create-template-from-timeline', available: (item: OpenTimelineResult) => - item.timelineType !== TimelineType.template && actionTimelineToShow.includes('createFrom'), + item.timelineType !== TimelineTypeEnum.template && + actionTimelineToShow.includes('createFrom'), } as Action; const openAsDuplicateColumn = { @@ -93,7 +95,7 @@ export const getActionsColumns = ({ description: i18n.OPEN_AS_DUPLICATE, 'data-test-subj': 'open-duplicate', available: (item: OpenTimelineResult) => - item.timelineType !== TimelineType.template && actionTimelineToShow.includes('duplicate'), + item.timelineType !== TimelineTypeEnum.template && actionTimelineToShow.includes('duplicate'), } as Action; const openAsDuplicateTemplateColumn = { @@ -110,7 +112,7 @@ export const getActionsColumns = ({ description: i18n.OPEN_AS_DUPLICATE_TEMPLATE, 'data-test-subj': 'open-duplicate-template', available: (item: OpenTimelineResult) => - item.timelineType === TimelineType.template && actionTimelineToShow.includes('duplicate'), + item.timelineType === TimelineTypeEnum.template && actionTimelineToShow.includes('duplicate'), } as Action; const exportTimelineAction = { @@ -121,7 +123,7 @@ export const getActionsColumns = ({ if (enableExportTimelineDownloader != null) enableExportTimelineDownloader(selectedTimeline); }, enabled: (timeline: OpenTimelineResult) => { - return timeline.savedObjectId != null && timeline.status !== TimelineStatus.immutable; + return timeline.savedObjectId != null && timeline.status !== TimelineStatusEnum.immutable; }, description: i18n.EXPORT_SELECTED, 'data-test-subj': 'export-timeline', @@ -136,7 +138,7 @@ export const getActionsColumns = ({ if (onOpenDeleteTimelineModal != null) onOpenDeleteTimelineModal(selectedTimeline); }, enabled: ({ savedObjectId, status }: OpenTimelineResult) => - savedObjectId != null && status !== TimelineStatus.immutable, + savedObjectId != null && status !== TimelineStatusEnum.immutable, description: i18n.DELETE_SELECTED, 'data-test-subj': 'delete-timeline', available: () => actionTimelineToShow.includes('delete') && deleteTimelines != null, @@ -153,7 +155,7 @@ export const getActionsColumns = ({ enabled: (timeline: OpenTimelineResult) => onCreateRule != null && timeline.savedObjectId != null && - timeline.status !== TimelineStatus.immutable, + timeline.status !== TimelineStatusEnum.immutable, description: i18n.CREATE_RULE_FROM_TIMELINE, 'data-test-subj': 'create-rule-from-timeline', available: ({ queryType }: OpenTimelineResult) => @@ -174,7 +176,7 @@ export const getActionsColumns = ({ enabled: (timeline: OpenTimelineResult) => onCreateRuleFromEql != null && timeline.savedObjectId != null && - timeline.status !== TimelineStatus.immutable, + timeline.status !== TimelineStatusEnum.immutable, description: i18n.CREATE_RULE_FROM_TIMELINE, 'data-test-subj': 'create-rule-from-eql', available: ({ queryType }: OpenTimelineResult) => diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/common_columns.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/common_columns.tsx index 7c1e0a419683e..05870b128b2d5 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/common_columns.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/common_columns.tsx @@ -17,7 +17,7 @@ import * as i18n from '../translations'; import type { OnOpenTimeline, OnToggleShowNotes, OpenTimelineResult } from '../types'; import { getEmptyTagValue } from '../../../../common/components/empty_value'; import { FormattedRelativePreferenceDate } from '../../../../common/components/formatted_date'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { TimelineId } from '../../../../../common/types'; const LineClampTextContainer = styled.span` @@ -68,7 +68,8 @@ export const getCommonColumns = ({ { dataType: 'string' as EuiTableDataType, field: 'title', - name: timelineType === TimelineType.default ? i18n.TIMELINE_NAME : i18n.TIMELINE_TEMPLATE_NAME, + name: + timelineType === TimelineTypeEnum.default ? i18n.TIMELINE_NAME : i18n.TIMELINE_TEMPLATE_NAME, render: (title: string, timelineResult: OpenTimelineResult) => timelineResult.savedObjectId != null ? ( > => { const columns = { note: { @@ -77,5 +76,5 @@ export const getIconHeaderColumns = ({ }; const templateColumns = [columns.note, columns.favorite]; const defaultColumns = [columns.pinnedEvent, columns.note, columns.favorite]; - return timelineType === TimelineType.template ? templateColumns : defaultColumns; + return timelineType === TimelineTypeEnum.template ? templateColumns : defaultColumns; }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/index.tsx index 1e49028326b5d..0df2170b0697e 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/index.tsx @@ -27,8 +27,11 @@ import { getActionsColumns } from './actions_columns'; import { getCommonColumns } from './common_columns'; import { getExtendedColumns } from './extended_columns'; import { getIconHeaderColumns } from './icon_header_columns'; -import type { TimelineTypeLiteralWithNull } from '../../../../../common/api/timeline'; -import { TimelineStatus, TimelineType } from '../../../../../common/api/timeline'; +import { + TimelineStatusEnum, + type TimelineType, + TimelineTypeEnum, +} from '../../../../../common/api/timeline'; import { useUserPrivileges } from '../../../../common/components/user_privileges'; /** @@ -63,7 +66,7 @@ export const getTimelinesTableColumns = ({ onSelectionChange: OnSelectionChange; onToggleShowNotes: OnToggleShowNotes; showExtendedColumns: boolean; - timelineType: TimelineTypeLiteralWithNull; + timelineType: TimelineType | null; hasCrudAccess: boolean; }): Array> => { return [ @@ -110,7 +113,7 @@ export interface TimelinesTableProps { showExtendedColumns: boolean; sortDirection: 'asc' | 'desc'; sortField: string; - timelineType: TimelineTypeLiteralWithNull; + timelineType: TimelineType | null; tableRef: React.MutableRefObject | null>; totalSearchResultsCount: number; } @@ -171,7 +174,7 @@ export const TimelinesTable = React.memo( return { selectable: (timelineResult: OpenTimelineResult) => timelineResult.savedObjectId != null && - timelineResult.status !== TimelineStatus.immutable, + timelineResult.status !== TimelineStatusEnum.immutable, selectableMessage: (selectable: boolean) => !selectable ? i18n.MISSING_SAVED_OBJECT_ID : '', onSelectionChange, @@ -215,7 +218,7 @@ export const TimelinesTable = React.memo( const noItemsMessage = isLoading || searchResults == null ? i18n.LOADING - : timelineType === TimelineType.template + : timelineType === TimelineTypeEnum.template ? i18n.ZERO_TIMELINE_TEMPLATES_MATCH : i18n.ZERO_TIMELINES_MATCH; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/mocks.ts b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/mocks.ts index 075f4aca49f3f..68055c6c5a17b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/mocks.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/mocks.ts @@ -9,7 +9,7 @@ import { DEFAULT_SEARCH_RESULTS_PER_PAGE } from '../../../pages/timelines_page'; import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants'; import type { OpenTimelineResult } from '../types'; import type { TimelinesTableProps } from '.'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; export const getMockTimelinesTableProps = ( mockOpenTimelineResults: OpenTimelineResult[] @@ -31,7 +31,7 @@ export const getMockTimelinesTableProps = ( showExtendedColumns: true, sortDirection: DEFAULT_SORT_DIRECTION, sortField: DEFAULT_SORT_FIELD, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, totalSearchResultsCount: mockOpenTimelineResults.length, tableRef: { current: null }, }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/types.ts b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/types.ts index 9595d991fbde4..1fb75887d6a75 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/types.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/types.ts @@ -11,11 +11,9 @@ import type { TimelineModel } from '../../store/model'; import type { RowRendererId, SingleTimelineResolveResponse, - TimelineTypeLiteral, - TimelineTypeLiteralWithNull, + TimelineType, TimelineStatus, - TemplateTimelineTypeLiteral, - TimelineStatusLiteralWithNull, + TemplateTimelineType, Note, } from '../../../../common/api/timeline'; @@ -63,7 +61,7 @@ export interface OpenTimelineResult { status?: TimelineStatus | null; title?: string | null; templateTimelineId?: string | null; - timelineType?: TimelineTypeLiteral; + timelineType?: TimelineType; updated?: number | null; updatedBy?: string | null; } @@ -98,7 +96,7 @@ export type OnOpenTimeline = ({ }: { duplicate: boolean; timelineId: string; - timelineType?: TimelineTypeLiteral; + timelineType?: TimelineType; }) => void; export type OnOpenDeleteTimelineModal = (selectedItem: OpenTimelineResult) => void; @@ -195,9 +193,9 @@ export interface OpenTimelineProps { /** the requested field to sort on */ sortField: string; /** this affects timeline's behaviour like editable / duplicatible */ - timelineType: TimelineTypeLiteralWithNull; + timelineType: TimelineType | null; /* active or immutable */ - timelineStatus: TimelineStatusLiteralWithNull; + timelineStatus: TimelineStatus | null; /** when timelineType === template, templatetimelineFilter is a JSX.Element */ templateTimelineFilter: JSX.Element[] | null; /** timeline / timeline template */ @@ -240,13 +238,13 @@ export enum TimelineTabsStyle { export interface TimelineTab { disabled: boolean; href: string; - id: TimelineTypeLiteral; + id: TimelineType; name: string; onClick: (ev: { preventDefault: () => void }) => void; } export interface TemplateTimelineFilter { - id: TemplateTimelineTypeLiteral; + id: TemplateTimelineType; name: string; disabled: boolean; withNext: boolean; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_status.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_status.tsx index a0719b6ac3679..9e39bbf8ece34 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_status.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_status.tsx @@ -9,14 +9,14 @@ import React, { useState, useCallback, useMemo } from 'react'; import { EuiFilterButton } from '@elastic/eui'; import type { - TimelineTypeLiteralWithNull, - TemplateTimelineTypeLiteralWithNull, - TimelineStatusLiteralWithNull, -} from '../../../../common/api/timeline'; -import { + TemplateTimelineType, TimelineStatus, TimelineType, - TemplateTimelineType, +} from '../../../../common/api/timeline'; +import { + TemplateTimelineTypeEnum, + TimelineStatusEnum, + TimelineTypeEnum, } from '../../../../common/api/timeline'; import * as i18n from './translations'; @@ -28,18 +28,18 @@ export const useTimelineStatus = ({ elasticTemplateTimelineCount, customTemplateTimelineCount, }: { - timelineType: TimelineTypeLiteralWithNull; + timelineType: TimelineType | null; elasticTemplateTimelineCount?: number | null; customTemplateTimelineCount?: number | null; }): { - timelineStatus: TimelineStatusLiteralWithNull; - templateTimelineType: TemplateTimelineTypeLiteralWithNull; + timelineStatus: TimelineStatus | null; + templateTimelineType: TemplateTimelineType | null; templateTimelineFilter: JSX.Element[] | null; installPrepackagedTimelines: () => void; } => { - const [selectedTab, setSelectedTab] = useState(null); + const [selectedTab, setSelectedTab] = useState(null); const isTemplateFilterEnabled = useMemo( - () => timelineType === TimelineType.template, + () => timelineType === TimelineTypeEnum.template, [timelineType] ); @@ -52,23 +52,23 @@ export const useTimelineStatus = ({ () => templateTimelineType == null ? null - : templateTimelineType === TemplateTimelineType.elastic - ? TimelineStatus.immutable - : TimelineStatus.active, + : templateTimelineType === TemplateTimelineTypeEnum.elastic + ? TimelineStatusEnum.immutable + : TimelineStatusEnum.active, [templateTimelineType] ); const filters = useMemo( () => [ { - id: TemplateTimelineType.elastic, + id: TemplateTimelineTypeEnum.elastic, name: i18n.FILTER_ELASTIC_TIMELINES, disabled: !isTemplateFilterEnabled, withNext: true, count: elasticTemplateTimelineCount ?? undefined, }, { - id: TemplateTimelineType.custom, + id: TemplateTimelineTypeEnum.custom, name: i18n.FILTER_CUSTOM_TIMELINES, disabled: !isTemplateFilterEnabled, withNext: false, @@ -108,7 +108,7 @@ export const useTimelineStatus = ({ }, [templateTimelineType, filters, isTemplateFilterEnabled, onFilterClicked]); const installPrepackagedTimelines = useCallback(async () => { - if (templateTimelineType !== TemplateTimelineType.custom) { + if (templateTimelineType !== TemplateTimelineTypeEnum.custom) { await installPrepackedTimelines(); } }, [templateTimelineType]); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_types.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_types.tsx index d8943b0f674e7..8002798291cc1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_types.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_timeline_types.tsx @@ -10,8 +10,7 @@ import { useParams } from 'react-router-dom'; import { EuiTabs, EuiTab, EuiSpacer } from '@elastic/eui'; import { noop } from 'lodash/fp'; -import type { TimelineTypeLiteralWithNull } from '../../../../common/api/timeline'; -import { TimelineType } from '../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../common/api/timeline'; import { SecurityPageName } from '../../../app/types'; import { getTimelineTabsUrl, useFormatUrl } from '../../../common/components/link_to'; import * as i18n from './translations'; @@ -25,7 +24,7 @@ export interface UseTimelineTypesArgs { } export interface UseTimelineTypesResult { - timelineType: TimelineTypeLiteralWithNull; + timelineType: TimelineType | null; timelineTabs: JSX.Element; timelineFilters: JSX.Element; } @@ -37,19 +36,19 @@ export const useTimelineTypes = ({ const { formatUrl, search: urlSearch } = useFormatUrl(SecurityPageName.timelines); const { navigateToUrl } = useKibana().services.application; const { tabName } = useParams<{ pageName: SecurityPageName; tabName: string }>(); - const [timelineType, setTimelineTypes] = useState( - tabName === TimelineType.default || tabName === TimelineType.template + const [timelineType, setTimelineTypes] = useState( + tabName === TimelineTypeEnum.default || tabName === TimelineTypeEnum.template ? tabName - : TimelineType.default + : TimelineTypeEnum.default ); const notesEnabled = useIsExperimentalFeatureEnabled('securitySolutionNotesEnabled'); const timelineUrl = useMemo(() => { - return formatUrl(getTimelineTabsUrl(TimelineType.default, urlSearch)); + return formatUrl(getTimelineTabsUrl(TimelineTypeEnum.default, urlSearch)); }, [formatUrl, urlSearch]); const templateUrl = useMemo(() => { - return formatUrl(getTimelineTabsUrl(TimelineType.template, urlSearch)); + return formatUrl(getTimelineTabsUrl(TimelineTypeEnum.template, urlSearch)); }, [formatUrl, urlSearch]); const notesUrl = useMemo(() => { @@ -83,7 +82,7 @@ export const useTimelineTypes = ({ const getFilterOrTabs: (timelineTabsStyle: TimelineTabsStyle) => TimelineTab[] = useCallback( (timelineTabsStyle: TimelineTabsStyle) => [ { - id: TimelineType.default, + id: TimelineTypeEnum.default, name: i18n.TAB_TIMELINES, href: timelineUrl, disabled: false, @@ -91,7 +90,7 @@ export const useTimelineTypes = ({ onClick: timelineTabsStyle === TimelineTabsStyle.tab ? goToTimeline : noop, }, { - id: TimelineType.template, + id: TimelineTypeEnum.template, name: i18n.TAB_TEMPLATES, href: templateUrl, disabled: false, diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_update_timeline.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_update_timeline.tsx index 1be17b4c599d4..2d380e700f7d3 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_update_timeline.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/use_update_timeline.tsx @@ -9,7 +9,7 @@ import { useCallback } from 'react'; import { useDispatch } from 'react-redux'; import { isEmpty } from 'lodash/fp'; import type { Note } from '../../../../common/api/timeline'; -import { TimelineStatus, TimelineType } from '../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../common/api/timeline'; import { createNote } from '../notes/helpers'; import { InputsModelId } from '../../../common/store/inputs/constants'; @@ -65,8 +65,8 @@ export const useUpdateTimeline = () => { ); } if ( - _timeline.status === TimelineStatus.immutable && - _timeline.timelineType === TimelineType.template + _timeline.status === TimelineStatusEnum.immutable && + _timeline.timelineType === TimelineTypeEnum.template ) { dispatch( dispatchSetRelativeRangeDatePicker({ diff --git a/x-pack/plugins/security_solution/public/timelines/components/row_renderer_switch/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/row_renderer_switch/index.test.tsx index 3978c06f2784d..94a4477778f3e 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/row_renderer_switch/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/row_renderer_switch/index.test.tsx @@ -11,13 +11,12 @@ import { createMockStore, mockGlobalState, TestProviders } from '../../../common import { fireEvent, render, waitFor } from '@testing-library/react'; import { RowRendererSwitch } from '.'; import { TimelineId } from '../../../../common/types'; -import { RowRendererId } from '../../../../common/api/timeline'; +import { RowRendererValues } from '../../../../common/api/timeline'; const localState = structuredClone(mockGlobalState); // exclude all row renderers by default -localState.timeline.timelineById[TimelineId.test].excludedRowRendererIds = - Object.values(RowRendererId); +localState.timeline.timelineById[TimelineId.test].excludedRowRendererIds = RowRendererValues; const renderTestComponent = (props?: ComponentProps) => { const store = props?.store ?? createMockStore(localState); @@ -69,7 +68,7 @@ describe('Row Renderer Switch', () => { expect(getByTestId('row-renderer-switch')).toHaveAttribute('aria-checked', 'false'); expect( localStore.getState().timeline.timelineById[TimelineId.test].excludedRowRendererIds - ).toMatchObject(Object.values(RowRendererId)); + ).toMatchObject(RowRendererValues); }); }); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/row_renderer_switch/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/row_renderer_switch/index.tsx index 12a6127a39053..986b417bf806d 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/row_renderer_switch/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/row_renderer_switch/index.tsx @@ -10,7 +10,7 @@ import { EuiToolTip, EuiSwitch, EuiFormRow, useGeneratedHtmlId } from '@elastic/ import React, { useCallback, useMemo } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import styled from 'styled-components'; -import { RowRendererId } from '../../../../common/api/timeline'; +import { RowRendererValues } from '../../../../common/api/timeline'; import type { State } from '../../../common/store'; import { setExcludedRowRendererIds } from '../../store/actions'; import { selectExcludedRowRendererIds } from '../../store/selectors'; @@ -40,7 +40,7 @@ export const RowRendererSwitch = React.memo(function RowRendererSwitch( ); const isAnyRowRendererEnabled = useMemo( - () => Object.values(RowRendererId).some((id) => !excludedRowRendererIds.includes(id)), + () => RowRendererValues.some((id) => !excludedRowRendererIds.includes(id)), [excludedRowRendererIds] ); @@ -48,7 +48,7 @@ export const RowRendererSwitch = React.memo(function RowRendererSwitch( dispatch( setExcludedRowRendererIds({ id: timelineId, - excludedRowRendererIds: Object.values(RowRendererId), + excludedRowRendererIds: RowRendererValues, }) ); }, [dispatch, timelineId]); diff --git a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/catalog/constants.ts b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/catalog/constants.ts index 02e8b4057ee7c..3e6c90e30e5b2 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/catalog/constants.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/catalog/constants.ts @@ -4,26 +4,26 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { RowRendererId } from '../../../../../common/api/timeline'; +import { type RowRendererId, RowRendererIdEnum } from '../../../../../common/api/timeline'; import * as i18n from './translations'; export const eventRendererNames: { [key in RowRendererId]: string } = { - [RowRendererId.alert]: i18n.ALERT_NAME, - [RowRendererId.alerts]: i18n.ALERTS_NAME, - [RowRendererId.auditd]: i18n.AUDITD_NAME, - [RowRendererId.auditd_file]: i18n.AUDITD_FILE_NAME, - [RowRendererId.library]: i18n.LIBRARY_NAME, - [RowRendererId.system_security_event]: i18n.AUTHENTICATION_NAME, - [RowRendererId.system_dns]: i18n.DNS_NAME, - [RowRendererId.netflow]: i18n.FLOW_NAME, - [RowRendererId.system]: i18n.SYSTEM_NAME, - [RowRendererId.system_endgame_process]: i18n.PROCESS, - [RowRendererId.registry]: i18n.REGISTRY_NAME, - [RowRendererId.system_fim]: i18n.FIM_NAME, - [RowRendererId.system_file]: i18n.FILE_NAME, - [RowRendererId.system_socket]: i18n.SOCKET_NAME, - [RowRendererId.suricata]: 'Suricata', - [RowRendererId.threat_match]: i18n.THREAT_MATCH_NAME, - [RowRendererId.zeek]: i18n.ZEEK_NAME, - [RowRendererId.plain]: '', + [RowRendererIdEnum.alert]: i18n.ALERT_NAME, + [RowRendererIdEnum.alerts]: i18n.ALERTS_NAME, + [RowRendererIdEnum.auditd]: i18n.AUDITD_NAME, + [RowRendererIdEnum.auditd_file]: i18n.AUDITD_FILE_NAME, + [RowRendererIdEnum.library]: i18n.LIBRARY_NAME, + [RowRendererIdEnum.system_security_event]: i18n.AUTHENTICATION_NAME, + [RowRendererIdEnum.system_dns]: i18n.DNS_NAME, + [RowRendererIdEnum.netflow]: i18n.FLOW_NAME, + [RowRendererIdEnum.system]: i18n.SYSTEM_NAME, + [RowRendererIdEnum.system_endgame_process]: i18n.PROCESS, + [RowRendererIdEnum.registry]: i18n.REGISTRY_NAME, + [RowRendererIdEnum.system_fim]: i18n.FIM_NAME, + [RowRendererIdEnum.system_file]: i18n.FILE_NAME, + [RowRendererIdEnum.system_socket]: i18n.SOCKET_NAME, + [RowRendererIdEnum.suricata]: 'Suricata', + [RowRendererIdEnum.threat_match]: i18n.THREAT_MATCH_NAME, + [RowRendererIdEnum.zeek]: i18n.ZEEK_NAME, + [RowRendererIdEnum.plain]: '', }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/catalog/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/catalog/index.tsx index 6632c7322e373..f236402fa925b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/catalog/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/catalog/index.tsx @@ -8,7 +8,7 @@ import { EuiLink } from '@elastic/eui'; import React from 'react'; -import { RowRendererId } from '../../../../../common/api/timeline'; +import { type RowRendererId, RowRendererIdEnum } from '../../../../../common/api/timeline'; import { AlertsExample, AuditdExample, @@ -51,15 +51,15 @@ export interface RowRendererOption { export const renderers: RowRendererOption[] = [ { - id: RowRendererId.alerts, - name: eventRendererNames[RowRendererId.alerts], + id: RowRendererIdEnum.alerts, + name: eventRendererNames[RowRendererIdEnum.alerts], description: i18n.ALERTS_DESCRIPTION, example: AlertsExample, searchableDescription: i18n.ALERTS_DESCRIPTION, }, { - id: RowRendererId.auditd, - name: eventRendererNames[RowRendererId.auditd], + id: RowRendererIdEnum.auditd, + name: eventRendererNames[RowRendererIdEnum.auditd], description: ( @@ -72,8 +72,8 @@ export const renderers: RowRendererOption[] = [ searchableDescription: `${i18n.AUDITD_NAME} ${i18n.AUDITD_DESCRIPTION_PART1}`, }, { - id: RowRendererId.auditd_file, - name: eventRendererNames[RowRendererId.auditd_file], + id: RowRendererIdEnum.auditd_file, + name: eventRendererNames[RowRendererIdEnum.auditd_file], description: ( @@ -86,15 +86,15 @@ export const renderers: RowRendererOption[] = [ searchableDescription: `${i18n.AUDITD_FILE_NAME} ${i18n.AUDITD_FILE_DESCRIPTION_PART1}`, }, { - id: RowRendererId.library, - name: eventRendererNames[RowRendererId.library], + id: RowRendererIdEnum.library, + name: eventRendererNames[RowRendererIdEnum.library], description: i18n.LIBRARY_DESCRIPTION, example: LibraryExample, searchableDescription: i18n.LIBRARY_DESCRIPTION, }, { - id: RowRendererId.system_security_event, - name: eventRendererNames[RowRendererId.system_security_event], + id: RowRendererIdEnum.system_security_event, + name: eventRendererNames[RowRendererIdEnum.system_security_event], description: (

{i18n.AUTHENTICATION_DESCRIPTION_PART1}

@@ -106,15 +106,15 @@ export const renderers: RowRendererOption[] = [ searchableDescription: `${i18n.AUTHENTICATION_DESCRIPTION_PART1} ${i18n.AUTHENTICATION_DESCRIPTION_PART2}`, }, { - id: RowRendererId.system_dns, - name: eventRendererNames[RowRendererId.system_dns], + id: RowRendererIdEnum.system_dns, + name: eventRendererNames[RowRendererIdEnum.system_dns], description: i18n.DNS_DESCRIPTION_PART1, example: SystemDnsExample, searchableDescription: i18n.DNS_DESCRIPTION_PART1, }, { - id: RowRendererId.netflow, - name: eventRendererNames[RowRendererId.netflow], + id: RowRendererIdEnum.netflow, + name: eventRendererNames[RowRendererIdEnum.netflow], description: (

{i18n.FLOW_DESCRIPTION_PART1}

@@ -126,8 +126,8 @@ export const renderers: RowRendererOption[] = [ searchableDescription: `${i18n.FLOW_DESCRIPTION_PART1} ${i18n.FLOW_DESCRIPTION_PART2}`, }, { - id: RowRendererId.system, - name: eventRendererNames[RowRendererId.system], + id: RowRendererIdEnum.system, + name: eventRendererNames[RowRendererIdEnum.system], description: (

@@ -145,8 +145,8 @@ export const renderers: RowRendererOption[] = [ searchableDescription: `${i18n.SYSTEM_DESCRIPTION_PART1} ${i18n.SYSTEM_NAME} ${i18n.SYSTEM_DESCRIPTION_PART2} ${i18n.SYSTEM_DESCRIPTION_PART3}`, }, { - id: RowRendererId.system_endgame_process, - name: eventRendererNames[RowRendererId.system_endgame_process], + id: RowRendererIdEnum.system_endgame_process, + name: eventRendererNames[RowRendererIdEnum.system_endgame_process], description: (

{i18n.PROCESS_DESCRIPTION_PART1}

@@ -158,29 +158,29 @@ export const renderers: RowRendererOption[] = [ searchableDescription: `${i18n.PROCESS_DESCRIPTION_PART1} ${i18n.PROCESS_DESCRIPTION_PART2}`, }, { - id: RowRendererId.registry, - name: eventRendererNames[RowRendererId.registry], + id: RowRendererIdEnum.registry, + name: eventRendererNames[RowRendererIdEnum.registry], description: i18n.REGISTRY_DESCRIPTION, example: RegistryExample, searchableDescription: i18n.REGISTRY_DESCRIPTION, }, { - id: RowRendererId.system_fim, - name: eventRendererNames[RowRendererId.system_fim], + id: RowRendererIdEnum.system_fim, + name: eventRendererNames[RowRendererIdEnum.system_fim], description: i18n.FIM_DESCRIPTION_PART1, example: SystemFimExample, searchableDescription: i18n.FIM_DESCRIPTION_PART1, }, { - id: RowRendererId.system_file, - name: eventRendererNames[RowRendererId.system_file], + id: RowRendererIdEnum.system_file, + name: eventRendererNames[RowRendererIdEnum.system_file], description: i18n.FILE_DESCRIPTION_PART1, example: SystemFileExample, searchableDescription: i18n.FILE_DESCRIPTION_PART1, }, { - id: RowRendererId.system_socket, - name: eventRendererNames[RowRendererId.system_socket], + id: RowRendererIdEnum.system_socket, + name: eventRendererNames[RowRendererIdEnum.system_socket], description: (

{i18n.SOCKET_DESCRIPTION_PART1}

@@ -192,8 +192,8 @@ export const renderers: RowRendererOption[] = [ searchableDescription: `${i18n.SOCKET_DESCRIPTION_PART1} ${i18n.SOCKET_DESCRIPTION_PART2}`, }, { - id: RowRendererId.suricata, - name: eventRendererNames[RowRendererId.suricata], + id: RowRendererIdEnum.suricata, + name: eventRendererNames[RowRendererIdEnum.suricata], description: (

{i18n.SURICATA_DESCRIPTION_PART1}{' '} @@ -207,15 +207,15 @@ export const renderers: RowRendererOption[] = [ searchableDescription: `${i18n.SURICATA_DESCRIPTION_PART1} ${i18n.SURICATA_NAME} ${i18n.SURICATA_DESCRIPTION_PART2}`, }, { - id: RowRendererId.threat_match, - name: eventRendererNames[RowRendererId.threat_match], + id: RowRendererIdEnum.threat_match, + name: eventRendererNames[RowRendererIdEnum.threat_match], description: i18n.THREAT_MATCH_DESCRIPTION, example: ThreatMatchExample, searchableDescription: `${i18n.THREAT_MATCH_NAME} ${i18n.THREAT_MATCH_DESCRIPTION}`, }, { - id: RowRendererId.zeek, - name: eventRendererNames[RowRendererId.zeek], + id: RowRendererIdEnum.zeek, + name: eventRendererNames[RowRendererIdEnum.zeek], description: (

{i18n.ZEEK_DESCRIPTION_PART1}{' '} diff --git a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/index.tsx index be33b84ca5f0c..776d1279ae715 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/row_renderers_browser/index.tsx @@ -23,7 +23,7 @@ import { useDispatch } from 'react-redux'; import styled from 'styled-components'; import type { State } from '../../../common/store'; -import { RowRendererId } from '../../../../common/api/timeline'; +import { RowRendererValues } from '../../../../common/api/timeline'; import { useDeepEqualSelector } from '../../../common/hooks/use_selector'; import { setExcludedRowRendererIds as dispatchSetExcludedRowRendererIds } from '../../store/actions'; import { timelineSelectors } from '../../store'; @@ -94,7 +94,7 @@ const StatefulRowRenderersBrowserComponent: React.FC setShow(false), []); const handleDisableAll = useCallback(() => { - setExcludedRowRendererIds(Object.values(RowRendererId)); + setExcludedRowRendererIds(RowRendererValues); }, [setExcludedRowRendererIds]); const handleEnableAll = useCallback(() => { diff --git a/x-pack/plugins/security_solution/public/timelines/components/save_status/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/save_status/index.test.tsx index 395f09bc273f3..3422774127a69 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/save_status/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/save_status/index.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import { TimelineSaveStatus } from '.'; -import { TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../common/api/timeline'; import { useDeepEqualSelector } from '../../../common/hooks/use_selector'; import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; import { TimelineId } from '../../../../common/types'; @@ -26,7 +26,7 @@ const renderTimelineSaveStatus = () => { describe('TimelineSaveStatus', () => { it('should render unsaved status if draft timeline', () => { (useDeepEqualSelector as jest.Mock).mockReturnValue({ - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }); const { getByTestId, getByText } = renderTimelineSaveStatus(); @@ -61,7 +61,7 @@ describe('TimelineSaveStatus', () => { it('should not render any status', () => { (useDeepEqualSelector as jest.Mock).mockReturnValue({ changed: false, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, updated: Date.now(), }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/save_status/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/save_status/index.tsx index 39fc9d963cfd6..606f674fcd595 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/save_status/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/save_status/index.tsx @@ -12,7 +12,7 @@ import { i18n } from '@kbn/i18n'; import { timelineSelectors } from '../../store'; import { timelineDefaults } from '../../store/defaults'; import { useDeepEqualSelector } from '../../../common/hooks/use_selector'; -import { TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../common/api/timeline'; const UNSAVED = i18n.translate('xpack.securitySolution.timeline.saveStatus.unsavedLabel', { defaultMessage: 'Unsaved', @@ -47,7 +47,7 @@ export const TimelineSaveStatus = React.memo(({ timelin pick(['changed', 'status', 'updated'], getTimeline(state, timelineId) ?? timelineDefaults) ); - const isDraft = status === TimelineStatus.draft; + const isDraft = status === TimelineStatusEnum.draft; let statusContent: React.ReactNode; if (isDraft || !updated) { diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/event_column_view.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/event_column_view.test.tsx index 11cc6032242e3..21d74337c4aab 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/event_column_view.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/event_column_view.test.tsx @@ -13,7 +13,7 @@ import { TestProviders } from '../../../../../common/mock'; import { EventColumnView } from './event_column_view'; import { DefaultCellRenderer } from '../../cell_rendering/default_cell_renderer'; import { TimelineId, TimelineTabs } from '../../../../../../common/types/timeline'; -import { TimelineType } from '../../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../../common/api/timeline'; import { useShallowEqualSelector } from '../../../../../common/hooks/use_selector'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; import { getDefaultControlColumn } from '../control_columns'; @@ -79,7 +79,7 @@ jest.mock('../../../../../common/lib/kibana', () => { describe('EventColumnView', () => { useIsExperimentalFeatureEnabledMock.mockReturnValue(false); - (useShallowEqualSelector as jest.Mock).mockReturnValue(TimelineType.default); + (useShallowEqualSelector as jest.Mock).mockReturnValue(TimelineTypeEnum.default); const ACTION_BUTTON_COUNT = 4; const leadingControlColumns = getDefaultControlColumn(ACTION_BUTTON_COUNT); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.test.ts b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.test.ts index 95cfcdf0b0725..2ebbe54b6fac5 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.test.ts @@ -6,7 +6,7 @@ */ import { eventHasNotes, eventIsPinned, getPinOnClick, getPinTooltip } from './helpers'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; describe('helpers', () => { describe('eventHasNotes', () => { @@ -26,7 +26,7 @@ describe('helpers', () => { isAlert: false, isPinned: true, eventHasNotes: true, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }) ).toEqual('This event cannot be unpinned because it has notes'); }); @@ -37,7 +37,7 @@ describe('helpers', () => { isAlert: true, isPinned: true, eventHasNotes: true, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }) ).toEqual('This alert cannot be unpinned because it has notes'); }); @@ -48,7 +48,7 @@ describe('helpers', () => { isAlert: false, isPinned: true, eventHasNotes: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }) ).toEqual('Unpin event'); }); @@ -59,7 +59,7 @@ describe('helpers', () => { isAlert: true, isPinned: true, eventHasNotes: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }) ).toEqual('Unpin alert'); }); @@ -70,7 +70,7 @@ describe('helpers', () => { isAlert: false, isPinned: false, eventHasNotes: true, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }) ).toEqual('This event cannot be unpinned because it has notes'); }); @@ -81,7 +81,7 @@ describe('helpers', () => { isAlert: true, isPinned: false, eventHasNotes: true, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }) ).toEqual('This alert cannot be unpinned because it has notes'); }); @@ -92,7 +92,7 @@ describe('helpers', () => { isAlert: false, isPinned: false, eventHasNotes: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }) ).toEqual('Pin event'); }); @@ -103,7 +103,7 @@ describe('helpers', () => { isAlert: true, isPinned: false, eventHasNotes: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }) ).toEqual('Pin alert'); }); @@ -114,7 +114,7 @@ describe('helpers', () => { isAlert: false, isPinned: false, eventHasNotes: false, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }) ).toEqual('This event may not be pinned while editing a template timeline'); }); @@ -125,7 +125,7 @@ describe('helpers', () => { isAlert: true, isPinned: false, eventHasNotes: false, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }) ).toEqual('This alert may not be pinned while editing a template timeline'); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.tsx index f4f785b92974f..caf864d4b189b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.tsx @@ -10,8 +10,7 @@ import { isEmpty } from 'lodash/fp'; import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; import type { TimelineItem, TimelineNonEcsData } from '../../../../../common/search_strategy'; import type { TimelineEventsType } from '../../../../../common/types/timeline'; -import type { TimelineTypeLiteral } from '../../../../../common/api/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; import type { OnPinEvent, OnUnPinEvent } from '../events'; import * as i18n from './translations'; @@ -27,9 +26,9 @@ export const getPinTooltip = ({ isAlert: boolean; isPinned: boolean; eventHasNotes: boolean; - timelineType: TimelineTypeLiteral; + timelineType: TimelineType; }) => { - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { return i18n.DISABLE_PIN(isAlert); } else if (eventHasNotes) { return i18n.PINNED_WITH_NOTES(isAlert); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/alert_renderer/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/alert_renderer/index.tsx index 0361c7d470215..5d6506bfcaa9b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/alert_renderer/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/alert_renderer/index.tsx @@ -11,7 +11,7 @@ import React from 'react'; import { AlertField } from './alert_field'; import type { RowRenderer } from '../../../../../../../common/types'; -import { RowRendererId } from '../../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../../common/api/timeline'; import { ID, DESTINATION_IP, @@ -52,7 +52,7 @@ export const ALERT_RENDERER_FIELDS = [ ]; export const alertRenderer: RowRenderer = { - id: RowRendererId.alert, + id: RowRendererIdEnum.alert, isInstance: (ecs) => eventKindMatches(get('event.kind', ecs)), renderRow: ({ contextId = DEFAULT_CONTEXT_ID, data, isDraggable, scopeId }) => { const eventId = get(ID, data); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/auditd/generic_row_renderer.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/auditd/generic_row_renderer.tsx index ff3c48454e987..2d527e0ecec3f 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/auditd/generic_row_renderer.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/auditd/generic_row_renderer.tsx @@ -10,7 +10,7 @@ import { get } from 'lodash/fp'; import React from 'react'; import type { RowRenderer } from '../../../../../../../common/types/timeline'; -import { RowRendererId } from '../../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../../common/api/timeline'; import { RowRendererContainer } from '../row_renderer'; import { AuditdGenericDetails } from './generic_details'; @@ -24,7 +24,7 @@ export const createGenericAuditRowRenderer = ({ actionName: string; text: string; }): RowRenderer => ({ - id: RowRendererId.auditd, + id: RowRendererIdEnum.auditd, isInstance: (ecs) => { const module: string | null | undefined = get('event.module[0]', ecs); const action: string | null | undefined = get('event.action[0]', ecs); @@ -57,7 +57,7 @@ export const createGenericFileRowRenderer = ({ text: string; fileIcon?: IconType; }): RowRenderer => ({ - id: RowRendererId.auditd_file, + id: RowRendererIdEnum.auditd_file, isInstance: (ecs) => { const module: string | null | undefined = get('event.module[0]', ecs); const action: string | null | undefined = get('event.action[0]', ecs); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/combine_renderers/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/combine_renderers/index.test.tsx index 75c285d727379..61ab172d74d8c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/combine_renderers/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/combine_renderers/index.test.tsx @@ -7,20 +7,20 @@ import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; import { TimelineId } from '../../../../../../../common/types/timeline'; -import { RowRendererId } from '../../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../../common/api/timeline'; import { combineRenderers } from '.'; describe('combineRenderers', () => { const contextId = 'abcd'; const a = { - id: RowRendererId.netflow, + id: RowRendererIdEnum.netflow, isInstance: jest.fn(), renderRow: jest.fn(), }; const b = { - id: RowRendererId.registry, + id: RowRendererIdEnum.registry, isInstance: jest.fn(), renderRow: jest.fn(), }; @@ -32,7 +32,7 @@ describe('combineRenderers', () => { beforeEach(() => jest.clearAllMocks()); it('returns a renderer with the expected id', () => { - const id = RowRendererId.library; // typically id from 'a', or 'b', but it can be any value + const id = RowRendererIdEnum.library; // typically id from 'a', or 'b', but it can be any value expect(combineRenderers({ a, b, id }).id).toEqual(id); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/cti/threat_match_row_renderer.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/cti/threat_match_row_renderer.tsx index 6d994a7f91a9f..51a6e2b29189c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/cti/threat_match_row_renderer.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/cti/threat_match_row_renderer.tsx @@ -6,12 +6,12 @@ */ import type { RowRenderer } from '../../../../../../../common/types/timeline'; -import { RowRendererId } from '../../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../../common/api/timeline'; import { hasThreatMatchValue } from './helpers'; import { renderThreatMatchRows } from './threat_match_rows'; export const threatMatchRowRenderer: RowRenderer = { - id: RowRendererId.threat_match, + id: RowRendererIdEnum.threat_match, isInstance: hasThreatMatchValue, renderRow: renderThreatMatchRows, }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/netflow/netflow_row_renderer.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/netflow/netflow_row_renderer.tsx index ff56d2a0791f7..097096667171c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/netflow/netflow_row_renderer.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/netflow/netflow_row_renderer.tsx @@ -10,7 +10,7 @@ import React from 'react'; import styled from 'styled-components'; import type { RowRenderer } from '../../../../../../../common/types/timeline'; -import { RowRendererId } from '../../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../../common/api/timeline'; import { asArrayIfExists } from '../../../../../../common/lib/helpers'; import { TLS_CLIENT_CERTIFICATE_FINGERPRINT_SHA1_FIELD_NAME, @@ -85,7 +85,7 @@ export const eventActionMatches = (eventAction: string | object | undefined | nu }; export const netflowRowRenderer: RowRenderer = { - id: RowRendererId.netflow, + id: RowRendererIdEnum.netflow, isInstance: (ecs) => eventCategoryMatches(get(EVENT_CATEGORY_FIELD, ecs)) || eventActionMatches(get(EVENT_ACTION_FIELD, ecs)), diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_row_renderer.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_row_renderer.tsx index b4b5062d80809..6e2d63503dd5a 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_row_renderer.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_row_renderer.tsx @@ -8,14 +8,14 @@ import React from 'react'; import type { RowRenderer } from '../../../../../../common/types/timeline'; -import { RowRendererId } from '../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../common/api/timeline'; const PlainRowRenderer = () => <>; PlainRowRenderer.displayName = 'PlainRowRenderer'; export const plainRowRenderer: RowRenderer = { - id: RowRendererId.plain, + id: RowRendererIdEnum.plain, isInstance: (_) => true, renderRow: PlainRowRenderer, }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/reason_column_renderer.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/reason_column_renderer.test.tsx index 6828fa020fff6..a5cd33efdd5c4 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/reason_column_renderer.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/reason_column_renderer.test.tsx @@ -14,7 +14,7 @@ import { reasonColumnRenderer } from './reason_column_renderer'; import { plainColumnRenderer } from './plain_column_renderer'; import type { ColumnHeaderOptions, RowRenderer } from '../../../../../../common/types'; -import { RowRendererId } from '../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../common/api/timeline'; import { render } from '@testing-library/react'; import { cloneDeep } from 'lodash'; @@ -41,7 +41,7 @@ const field: ColumnHeaderOptions = { const rowRenderers: RowRenderer[] = [ { - id: RowRendererId.alerts, + id: RowRendererIdEnum.alerts, isInstance: (ecs) => ecs === validEcs, renderRow: () => , }, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/suricata/suricata_row_renderer.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/suricata/suricata_row_renderer.tsx index d116a557a3d95..044f945375d61 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/suricata/suricata_row_renderer.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/suricata/suricata_row_renderer.tsx @@ -9,13 +9,13 @@ import { get } from 'lodash/fp'; import React from 'react'; import type { RowRenderer } from '../../../../../../../common/types/timeline'; -import { RowRendererId } from '../../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../../common/api/timeline'; import { RowRendererContainer } from '../row_renderer'; import { SuricataDetails } from './suricata_details'; export const suricataRowRenderer: RowRenderer = { - id: RowRendererId.suricata, + id: RowRendererIdEnum.suricata, isInstance: (ecs) => { const module: string | null | undefined = get('event.module[0]', ecs); return module != null && module.toLowerCase() === 'suricata'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/system/generic_row_renderer.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/system/generic_row_renderer.tsx index e0282ab0b34bc..f9aa64c6d11b4 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/system/generic_row_renderer.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/system/generic_row_renderer.tsx @@ -9,7 +9,7 @@ import { get } from 'lodash/fp'; import React from 'react'; import type { RowRenderer } from '../../../../../../../common/types/timeline'; -import { RowRendererId } from '../../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../../common/api/timeline'; import { DnsRequestEventDetails } from '../dns/dns_request_event_details'; import { EndgameSecurityEventDetails } from '../endgame/endgame_security_event_details'; @@ -28,7 +28,7 @@ export const createGenericSystemRowRenderer = ({ actionName: string; text: string; }): RowRenderer => ({ - id: RowRendererId.system, + id: RowRendererIdEnum.system, isInstance: (ecs) => { const module: string | null | undefined = get('event.module[0]', ecs); const action: string | null | undefined = get('event.action[0]', ecs); @@ -59,7 +59,7 @@ export const createEndgameProcessRowRenderer = ({ actionName: string; text: string; }): RowRenderer => ({ - id: RowRendererId.system_file, + id: RowRendererIdEnum.system_file, isInstance: (ecs) => { const action: string | null | undefined = get('event.action[0]', ecs); const category: string | null | undefined = get('event.category[0]', ecs); @@ -91,7 +91,7 @@ export const createFimRowRenderer = ({ actionName: string; text: string; }): RowRenderer => ({ - id: RowRendererId.system_fim, + id: RowRendererIdEnum.system_fim, isInstance: (ecs) => { const action: string | null | undefined = get('event.action[0]', ecs); const category: string | null | undefined = get('event.category[0]', ecs); @@ -132,7 +132,7 @@ export const createEndpointAlertsRowRenderer = ({ skipRedundantProcessDetails = false, text, }: EndpointAlertCriteria): RowRenderer => ({ - id: RowRendererId.alerts, + id: RowRendererIdEnum.alerts, isInstance: (ecs) => { const action: string[] | null | undefined = get('event.action', ecs); const category: string[] | null | undefined = get('event.category', ecs); @@ -173,7 +173,7 @@ export const createEndpointLibraryRowRenderer = ({ actionName: string; text: string; }): RowRenderer => ({ - id: RowRendererId.library, + id: RowRendererIdEnum.library, isInstance: (ecs) => { const action: string | null | undefined = get('event.action[0]', ecs); const dataset: string | null | undefined = get('event.dataset[0]', ecs); @@ -202,7 +202,7 @@ export const createGenericFileRowRenderer = ({ actionName: string; text: string; }): RowRenderer => ({ - id: RowRendererId.system_file, + id: RowRendererIdEnum.system_file, isInstance: (ecs) => { const module: string | null | undefined = get('event.module[0]', ecs); const action: string | null | undefined = get('event.action[0]', ecs); @@ -233,7 +233,7 @@ export const createSocketRowRenderer = ({ actionName: string; text: string; }): RowRenderer => ({ - id: RowRendererId.system_socket, + id: RowRendererIdEnum.system_socket, isInstance: (ecs) => { const action: string | null | undefined = get('event.action[0]', ecs); return action != null && action.toLowerCase() === actionName; @@ -256,7 +256,7 @@ export const createSecurityEventRowRenderer = ({ }: { actionName: string; }): RowRenderer => ({ - id: RowRendererId.system_security_event, + id: RowRendererIdEnum.system_security_event, isInstance: (ecs) => { const category: string | null | undefined = get('event.category[0]', ecs); const action: string | null | undefined = get('event.action[0]', ecs); @@ -280,7 +280,7 @@ export const createSecurityEventRowRenderer = ({ }); export const createDnsRowRenderer = (): RowRenderer => ({ - id: RowRendererId.system_dns, + id: RowRendererIdEnum.system_dns, isInstance: (ecs) => { const dnsQuestionType: string | null | undefined = get('dns.question.type[0]', ecs); const dnsQuestionName: string | null | undefined = get('dns.question.name[0]', ecs); @@ -305,7 +305,7 @@ export const createEndpointRegistryRowRenderer = ({ actionName: string; text: string; }): RowRenderer => ({ - id: RowRendererId.registry, + id: RowRendererIdEnum.registry, isInstance: (ecs) => { const action: string | null | undefined = get('event.action[0]', ecs); const dataset: string | null | undefined = get('event.dataset[0]', ecs); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/zeek/zeek_row_renderer.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/zeek/zeek_row_renderer.tsx index b93fce554258c..1908bcf6d5bc4 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/zeek/zeek_row_renderer.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/zeek/zeek_row_renderer.tsx @@ -9,13 +9,13 @@ import { get } from 'lodash/fp'; import React from 'react'; import type { RowRenderer } from '../../../../../../../common/types/timeline'; -import { RowRendererId } from '../../../../../../../common/api/timeline'; +import { RowRendererIdEnum } from '../../../../../../../common/api/timeline'; import { RowRendererContainer } from '../row_renderer'; import { ZeekDetails } from './zeek_details'; export const zeekRowRenderer: RowRenderer = { - id: RowRendererId.zeek, + id: RowRendererIdEnum.zeek, isInstance: (ecs) => { const module: string | null | undefined = get('event.module[0]', ecs); return module != null && module.toLowerCase() === 'zeek'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/add_data_provider_popover.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/add_data_provider_popover.tsx index 5903d4bfe3022..d09444edd6c99 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/add_data_provider_popover.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/add_data_provider_popover.tsx @@ -21,11 +21,10 @@ import { v4 as uuidv4 } from 'uuid'; import { useDispatch } from 'react-redux'; import type { BrowserFields } from '../../../../common/containers/source'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { DataProviderTypeEnum, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; import { StatefulEditDataProvider } from '../../edit_data_provider'; import { addContentToTimeline, getDisplayValue } from './helpers'; -import { DataProviderType } from './data_provider'; import { timelineSelectors } from '../../../store'; import { ADD_FIELD_LABEL, ADD_TEMPLATE_FIELD_LABEL } from './translations'; @@ -102,9 +101,9 @@ const AddDataProviderPopoverComponent: React.FC = ( icon: , panel: 1, }, - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? { - disabled: timelineType !== TimelineType.template, + disabled: timelineType !== TimelineTypeEnum.template, name: ADD_TEMPLATE_FIELD_LABEL, icon: , panel: 2, @@ -125,7 +124,7 @@ const AddDataProviderPopoverComponent: React.FC = ( operator=":" timelineId={timelineId} value="" - type={DataProviderType.default} + type={DataProviderTypeEnum.default} providerId={`${timelineId}-${uuidv4()}`} /> ), @@ -143,7 +142,7 @@ const AddDataProviderPopoverComponent: React.FC = ( operator=":" timelineId={timelineId} value="" - type={DataProviderType.template} + type={DataProviderTypeEnum.template} providerId={`${timelineId}-${uuidv4()}`} /> ), @@ -153,7 +152,7 @@ const AddDataProviderPopoverComponent: React.FC = ( ); const button = useMemo(() => { - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { return ( = ( }, [togglePopoverState, timelineType]); const content = useMemo(() => { - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { return ; } @@ -194,7 +193,7 @@ const AddDataProviderPopoverComponent: React.FC = ( operator=":" timelineId={timelineId} value="" - type={DataProviderType.default} + type={DataProviderTypeEnum.default} providerId={`${timelineId}-${uuidv4()}`} /> ); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/data_provider.ts b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/data_provider.ts index 2778874c688e5..4d5e52b7c210d 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/data_provider.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/data_provider.ts @@ -5,7 +5,7 @@ * 2.0. */ import type { QueryType } from '@kbn/elastic-assistant'; - +import type { DataProviderType } from '../../../../../common/api/timeline'; import type { PrimitiveOrArrayOfPrimitives } from '../../../../common/lib/kuery'; /** Represents the Timeline data providers */ @@ -21,11 +21,6 @@ export const IS_ONE_OF_OPERATOR = 'includes'; /** The operator applied to a field */ export type QueryOperator = typeof IS_OPERATOR | typeof EXISTS_OPERATOR | typeof IS_ONE_OF_OPERATOR; -export enum DataProviderType { - default = 'default', - template = 'template', -} - export interface QueryMatch { field: string; displayField?: string; @@ -64,7 +59,7 @@ export interface DataProvider { /** * Returns a DataProviderType */ - type?: DataProviderType.default | DataProviderType.template; + type?: DataProviderType; /** * Array of multiple values for a field */ diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider.tsx index 5b26cff4f6d84..aae5ba7a73fff 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider.tsx @@ -9,8 +9,9 @@ import { noop } from 'lodash/fp'; import React, { useState } from 'react'; import type { DataProvider } from './data_provider'; -import { DataProviderType, IS_OPERATOR } from './data_provider'; +import { IS_OPERATOR } from './data_provider'; import { ProviderItemBadge } from './provider_item_badge'; +import { DataProviderTypeEnum } from '../../../../../common/api/timeline'; interface OwnProps { dataProvider: DataProvider; @@ -35,7 +36,7 @@ export const Provider = React.memo(({ dataProvider }) => { displayValue={String(dataProvider.queryMatch.displayValue ?? dataProvider.queryMatch.value)} val={dataProvider.queryMatch.value} operator={dataProvider.queryMatch.operator || IS_OPERATOR} - type={dataProvider.type || DataProviderType.default} + type={dataProvider.type || DataProviderTypeEnum.default} /> ); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_badge.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_badge.tsx index eccfb1b3eec77..72b2cf5792bfa 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_badge.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_badge.tsx @@ -12,12 +12,17 @@ import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; import type { PrimitiveOrArrayOfPrimitives } from '../../../../common/lib/kuery'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { + type DataProviderType, + DataProviderTypeEnum, + type TimelineType, + TimelineTypeEnum, +} from '../../../../../common/api/timeline'; import { getEmptyString } from '../../../../common/components/empty_value'; import { ProviderContainer } from '../../../../common/components/drag_and_drop/provider_container'; import type { QueryOperator } from './data_provider'; -import { DataProviderType, EXISTS_OPERATOR, IS_ONE_OF_OPERATOR } from './data_provider'; +import { EXISTS_OPERATOR, IS_ONE_OF_OPERATOR } from './data_provider'; import * as i18n from './translations'; @@ -38,7 +43,7 @@ const ProviderBadgeStyled = styled(EuiBadge)` &.globalFilterItem { white-space: nowrap; min-width: ${({ $timelineType }) => - $timelineType === TimelineType.template ? '140px' : 'none'}; + $timelineType === TimelineTypeEnum.template ? '140px' : 'none'}; display: flex; &.globalFilterItem-isDisabled { @@ -83,7 +88,7 @@ const ConvertFieldBadge = styled(ProviderFieldBadge)` `; const TemplateFieldBadgeComponent: React.FC = ({ type, toggleType }) => { - if (type !== DataProviderType.template) { + if (type !== DataProviderTypeEnum.template) { return ( {i18n.CONVERT_TO_TEMPLATE_FIELD} ); @@ -204,7 +209,7 @@ export const ProviderBadge = React.memo( {/* Add a UI feature to let users know the is one of operator doesnt work with timeline templates: https://github.com/elastic/kibana/issues/142437 */} - {timelineType === TimelineType.template && operator !== IS_ONE_OF_OPERATOR && ( + {timelineType === TimelineTypeEnum.template && operator !== IS_ONE_OF_OPERATOR && ( )} diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_item_actions.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_item_actions.tsx index 0da2d6ca7bd88..a5bef9b83551b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_item_actions.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_item_actions.tsx @@ -11,13 +11,18 @@ import type { FC, PropsWithChildren } from 'react'; import React from 'react'; import styled from 'styled-components'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { + type DataProviderType, + DataProviderTypeEnum, + type TimelineType, + TimelineTypeEnum, +} from '../../../../../common/api/timeline'; import type { PrimitiveOrArrayOfPrimitives } from '../../../../common/lib/kuery'; import type { BrowserFields } from '../../../../common/containers/source'; import type { OnDataProviderEdited } from '../events'; import type { QueryOperator } from './data_provider'; -import { DataProviderType, EXISTS_OPERATOR, IS_ONE_OF_OPERATOR } from './data_provider'; +import { EXISTS_OPERATOR, IS_ONE_OF_OPERATOR } from './data_provider'; import { StatefulEditDataProvider } from '../../edit_data_provider'; import * as i18n from './translations'; @@ -137,13 +142,13 @@ export const getProviderActions = ({ name: i18n.FILTER_FOR_FIELD_PRESENT, onClick: onFilterForFieldPresent, }, - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? { className: CONVERT_TO_FIELD_CLASS_NAME, disabled: isLoading || operator === IS_ONE_OF_OPERATOR, icon: 'visText', name: - type === DataProviderType.template + type === DataProviderTypeEnum.template ? i18n.CONVERT_TO_FIELD : i18n.CONVERT_TO_TEMPLATE_FIELD, onClick: toggleType, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_item_badge.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_item_badge.tsx index 871a82a9beb29..5f6f567bf32c7 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_item_badge.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/provider_item_badge.tsx @@ -9,7 +9,11 @@ import { noop } from 'lodash/fp'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { useDispatch } from 'react-redux'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { + type DataProviderType, + DataProviderTypeEnum, + TimelineTypeEnum, +} from '../../../../../common/api/timeline'; import type { BrowserFields } from '../../../../common/containers/source'; import { useDeepEqualSelector, @@ -22,7 +26,6 @@ import type { OnDataProviderEdited } from '../events'; import { ProviderBadge } from './provider_badge'; import { ProviderItemActions } from './provider_item_actions'; import type { DataProvidersAnd, QueryOperator } from './data_provider'; -import { DataProviderType } from './data_provider'; import { dragAndDropActions } from '../../../../common/store/drag_and_drop'; import { timelineDefaults } from '../../../store/defaults'; @@ -71,16 +74,16 @@ export const ProviderItemBadge = React.memo( toggleTypeProvider, displayValue, val, - type = DataProviderType.default, + type = DataProviderTypeEnum.default, wrapperRef, }) => { const getTimeline = useMemo(() => timelineSelectors.getTimelineByIdSelector(), []); const timelineType = useShallowEqualSelector((state) => { if (!timelineId) { - return TimelineType.default; + return TimelineTypeEnum.default; } - return getTimeline(state, timelineId)?.timelineType ?? TimelineType.default; + return getTimeline(state, timelineId)?.timelineType ?? TimelineTypeEnum.default; }); const { isLoading } = useDeepEqualSelector( diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/providers.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/providers.tsx index dd7eb5cf11051..11c13f16275f8 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/providers.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/data_providers/providers.tsx @@ -28,7 +28,8 @@ import { getTimelineProviderDroppableId, } from '../../../../common/components/drag_and_drop/helpers'; import type { DataProvider, DataProvidersAnd } from './data_provider'; -import { DataProviderType, IS_OPERATOR } from './data_provider'; +import { IS_OPERATOR } from './data_provider'; +import { DataProviderTypeEnum } from '../../../../../common/api/timeline'; import { EMPTY_GROUP, flattenIntoAndGroups } from './helpers'; import { ProviderItemBadge } from './provider_item_badge'; @@ -212,9 +213,9 @@ export const DataProvidersGroupItem = React.memo( id: timelineId, providerId: index > 0 ? group[0].id : dataProvider.id, type: - dataProvider.type === DataProviderType.template - ? DataProviderType.default - : DataProviderType.template, + dataProvider.type === DataProviderTypeEnum.template + ? DataProviderTypeEnum.default + : DataProviderTypeEnum.template, andProviderId: index > 0 ? dataProvider.id : undefined, }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx index e5587921e9ff4..f7dad276cb939 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx @@ -7,7 +7,8 @@ import { cloneDeep } from 'lodash/fp'; -import { DataProviderType, EXISTS_OPERATOR, IS_OPERATOR } from './data_providers/data_provider'; +import { EXISTS_OPERATOR, IS_OPERATOR } from './data_providers/data_provider'; +import { DataProviderTypeEnum } from '../../../../common/api/timeline'; import { mockDataProviders } from './data_providers/mock/mock_data_providers'; import { @@ -33,7 +34,7 @@ describe('Build KQL Query', () => { test('Build KQL query with one template data provider', () => { const dataProviders = cloneDeep(mockDataProviders.slice(0, 1)); - dataProviders[0].type = DataProviderType.template; + dataProviders[0].type = DataProviderTypeEnum.template; const kqlQuery = buildGlobalQuery(dataProviders, mockBrowserFields); expect(cleanUpKqlQuery(kqlQuery)).toEqual('name :*'); }); @@ -133,14 +134,14 @@ describe('Build KQL Query', () => { test('Build KQL query with two data provider (first is template)', () => { const dataProviders = cloneDeep(mockDataProviders.slice(0, 2)); - dataProviders[0].type = DataProviderType.template; + dataProviders[0].type = DataProviderTypeEnum.template; const kqlQuery = buildGlobalQuery(dataProviders, mockBrowserFields); expect(cleanUpKqlQuery(kqlQuery)).toEqual('(name :*) or (name : "Provider 2")'); }); test('Build KQL query with two data provider (second is template)', () => { const dataProviders = cloneDeep(mockDataProviders.slice(0, 2)); - dataProviders[1].type = DataProviderType.template; + dataProviders[1].type = DataProviderTypeEnum.template; const kqlQuery = buildGlobalQuery(dataProviders, mockBrowserFields); expect(cleanUpKqlQuery(kqlQuery)).toEqual('(name : "Provider 1") or (name :*)'); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.tsx index 82ea7bac73fad..04f08f203ec7f 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.tsx @@ -28,12 +28,8 @@ import { type PrimitiveOrArrayOfPrimitives, } from '../../../common/lib/kuery'; import type { DataProvider, DataProvidersAnd } from './data_providers/data_provider'; -import { - DataProviderType, - EXISTS_OPERATOR, - IS_ONE_OF_OPERATOR, - IS_OPERATOR, -} from './data_providers/data_provider'; +import { EXISTS_OPERATOR, IS_ONE_OF_OPERATOR, IS_OPERATOR } from './data_providers/data_provider'; +import { type DataProviderType, DataProviderTypeEnum } from '../../../../common/api/timeline'; import { EVENTS_TABLE_CLASS_NAME } from './styles'; const buildQueryMatch = ( @@ -211,7 +207,7 @@ export const handleIsOperator = ({ }) => { if (!isPrimitiveArray(value)) { return `${isExcluded}${ - type !== DataProviderType.template + type !== DataProviderTypeEnum.template ? buildIsQueryMatch({ browserFields, field, isFieldTypeNested, value }) : buildExistsQueryMatch({ browserFields, field, isFieldTypeNested }) }`; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/index.tsx index 817dd576511a5..f502c1b8884aa 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/index.tsx @@ -21,7 +21,7 @@ import type { CellValueElementProps } from './cell_rendering'; import { SourcererScopeName } from '../../../sourcerer/store/model'; import { TimelineModalHeader } from '../modal/header'; import type { TimelineId, RowRenderer, TimelineTabs } from '../../../../common/types/timeline'; -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; import { useDeepEqualSelector, useShallowEqualSelector } from '../../../common/hooks/use_selector'; import type { State } from '../../../common/store'; import { EVENTS_COUNT_BUTTON_CLASS_NAME, onTimelineTabKeyPressed } from './helpers'; @@ -237,7 +237,7 @@ const StatefulTimelineComponent: React.FC = ({ > - {timelineType === TimelineType.template && ( + {timelineType === TimelineTypeEnum.template && ( {i18n.TIMELINE_TEMPLATE} diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/pin/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/pin/index.test.tsx index 589005c0b21a2..570d5f184e9b1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/pin/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/pin/index.test.tsx @@ -8,7 +8,7 @@ import { mount } from 'enzyme'; import React from 'react'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { getDefaultAriaLabel, getPinIcon, Pin } from '.'; @@ -133,7 +133,7 @@ describe('pin', () => { test('the button is disabled for an event when allowUnpinning is true, and timelineType is `template`', () => { const isAlert = false; const allowUnpinning = true; - const timelineType = TimelineType.template; + const timelineType = TimelineTypeEnum.template; const wrapper = mount( { test('the button is disabled for an alert when allowUnpinning is true, and timelineType is `template`', () => { const isAlert = true; const allowUnpinning = true; - const timelineType = TimelineType.template; + const timelineType = TimelineTypeEnum.template; const wrapper = mount( { test('the button is disabled for an event when allowUnpinning is false, and timelineType is `template`', () => { const isAlert = false; const allowUnpinning = false; - const timelineType = TimelineType.template; + const timelineType = TimelineTypeEnum.template; const wrapper = mount( { test('the button is disabled for an alert when allowUnpinning is false, and timelineType is `template`', () => { const isAlert = true; const allowUnpinning = false; - const timelineType = TimelineType.template; + const timelineType = TimelineTypeEnum.template; const wrapper = mount( void; pinned: boolean; } @@ -48,7 +47,7 @@ export const getDefaultAriaLabel = ({ export const Pin = React.memo( ({ ariaLabel, allowUnpinning, isAlert, isDisabled, onClick = noop, pinned, timelineType }) => { - const isTemplate = timelineType === TimelineType.template; + const isTemplate = timelineType === TimelineTypeEnum.template; const defaultAriaLabel = getDefaultAriaLabel({ isAlert, isTemplate, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.test.tsx index e8508aaf0b4cd..aa8e0ae5cdede 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.test.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; import { NotesButton } from './helpers'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { ThemeProvider } from 'styled-components'; const toggleShowNotesMock = jest.fn(); @@ -21,7 +21,7 @@ const defaultProps: ComponentProps = { toggleShowNotes: toggleShowNotesMock, eventId: 'event-id', notesCount: 1, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, toolTip: 'Sample Tooltip', }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.tsx index 739e07dca1995..e43d89f707a7c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.tsx @@ -9,8 +9,7 @@ import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/e import React, { useCallback } from 'react'; import styled from 'styled-components'; -import type { TimelineTypeLiteral } from '../../../../../common/api/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; import * as i18n from './translations'; @@ -29,7 +28,7 @@ interface SmallNotesButtonProps { ariaLabel?: string; isDisabled?: boolean; toggleShowNotes?: (eventId?: string) => void; - timelineType: TimelineTypeLiteral; + timelineType: TimelineType; eventId?: string; /** * Number of notes. If > 0, then a red dot is shown in the top right corner of the icon. @@ -45,7 +44,7 @@ const NotesButtonContainer = styled(EuiFlexGroup)` const SmallNotesButton = React.memo( ({ ariaLabel = i18n.NOTES, isDisabled, toggleShowNotes, timelineType, eventId, notesCount }) => { - const isTemplate = timelineType === TimelineType.template; + const isTemplate = timelineType === TimelineTypeEnum.template; const onClick = useCallback(() => { if (eventId != null) { toggleShowNotes?.(eventId); @@ -85,7 +84,7 @@ interface NotesButtonProps { isDisabled?: boolean; toggleShowNotes?: () => void | ((eventId: string) => void); toolTip: string; - timelineType: TimelineTypeLiteral; + timelineType: TimelineType; eventId?: string; /** * Number of notes. If > 0, then a red dot is shown in the top right corner of the icon. diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/search_or_filter.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/search_or_filter.tsx index 7fccbd9103ae9..f694c473d8447 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/search_or_filter.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/search_or_filter.tsx @@ -13,7 +13,7 @@ import type { Filter } from '@kbn/es-query'; import type { FilterManager } from '@kbn/data-plugin/public'; import { DataViewPicker } from '../../../../sourcerer/experimental/components/dataview_picker'; import { isExperimentalSourcererEnabled } from '../../../../sourcerer/experimental/is_enabled'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { InputsModelId } from '../../../../common/store/inputs/constants'; import type { KqlMode } from '../../../store/model'; import type { DispatchUpdateReduxTime } from '../../../../common/components/super_date_picker'; @@ -147,7 +147,7 @@ export const SearchOrFilter = React.memo( DataProvider toggle is not needed in template timeline because it is always visible */ - timelineType === TimelineType.default ? ( + timelineType === TimelineTypeEnum.default ? ( void; 'aria-label'?: string; @@ -42,7 +41,7 @@ const SearchTimelineSuperSelectComponent: React.FC { getSelectableOptions: jest.fn().mockReturnValue([]), onClosePopover: jest.fn(), onTimelineChange: jest.fn(), - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }; describe('should render', () => { @@ -53,7 +53,7 @@ describe('SelectableTimeline', () => { }); describe('timeline template', () => { - const templateTimelineProps = { ...props, timelineType: TimelineType.template }; + const templateTimelineProps = { ...props, timelineType: TimelineTypeEnum.template }; beforeAll(() => { wrapper = shallow(); }); @@ -79,12 +79,12 @@ describe('SelectableTimeline', () => { }, search: '', sort: { - sortField: SortFieldTimeline.updated, + sortField: SortFieldTimelineEnum.updated, sortOrder: Direction.desc, }, status: null, onlyUserFavorite: false, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }; beforeAll(() => { mount(); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx index a21a000df762d..71c5b273d9dc1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx @@ -20,11 +20,7 @@ import { isEmpty, debounce } from 'lodash/fp'; import React, { memo, useCallback, useMemo, useState, useEffect, useRef } from 'react'; import styled from 'styled-components'; -import type { - TimelineTypeLiteralWithNull, - TimelineTypeLiteral, -} from '../../../../../common/api/timeline'; -import { SortFieldTimeline } from '../../../../../common/api/timeline'; +import { type TimelineType, SortFieldTimelineEnum } from '../../../../../common/api/timeline'; import { useGetAllTimeline } from '../../../containers/all'; import { isUntitled } from '../../open_timeline/helpers'; @@ -60,7 +56,7 @@ const replaceTitleInOptions = (options: EuiSelectableOption[]): EuiSelectableOpt export interface GetSelectableOptions { timelines: OpenTimelineResult[]; onlyFavorites: boolean; - timelineType?: TimelineTypeLiteralWithNull; + timelineType?: TimelineType | null; searchTimelineValue: string; } @@ -78,7 +74,7 @@ export interface SelectableTimelineProps { timelineId: string | null, graphEventId?: string ) => void; - timelineType: TimelineTypeLiteral; + timelineType: TimelineType; placeholder?: string; } @@ -254,7 +250,7 @@ const SelectableTimelineComponent: React.FC = ({ }, search: searchTimelineValue, sort: { - sortField: SortFieldTimeline.updated, + sortField: SortFieldTimelineEnum.updated, sortOrder: Direction.desc, }, onlyUserFavorite: onlyFavorites, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.test.tsx index a3048347a6b7f..f315fa22a42ba 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../common/mock/test_providers'; import { TabsContent } from '.'; import { TimelineId, TimelineTabs } from '../../../../../common/types/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useEsqlAvailability } from '../../../../common/hooks/esql/use_esql_availability'; import { render, screen, waitFor } from '@testing-library/react'; @@ -40,7 +40,7 @@ describe('Timeline', () => { renderCellValue: () => {}, rowRenderers: [], timelineId: TimelineId.test, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, timelineDescription: '', }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.tsx index 7f5ab6f316a62..2401e0014fd8a 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.tsx @@ -16,7 +16,7 @@ import { useEsqlAvailability } from '../../../../common/hooks/esql/use_esql_avai import type { SessionViewConfig } from '../../../../../common/types'; import type { RowRenderer, TimelineId } from '../../../../../common/types/timeline'; import { TimelineTabs } from '../../../../../common/types/timeline'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useShallowEqualSelector, useDeepEqualSelector, @@ -173,7 +173,7 @@ const ActiveTimelineTab = memo( timelineId={timelineId} /> - {timelineType === TimelineType.default && ( + {timelineType === TimelineTypeEnum.default && ( = ({ {i18n.DISCOVER_ESQL_IN_TIMELINE_TAB} )} - {timelineType === TimelineType.default && ( + {timelineType === TimelineTypeEnum.default && ( = ({ data-test-subj={`timelineTabs-${TimelineTabs.notes}`} onClick={setNotesAsActiveTab} isSelected={activeTab === TimelineTabs.notes} - disabled={timelineType === TimelineType.template} + disabled={timelineType === TimelineTypeEnum.template} key={TimelineTabs.notes} > {i18n.NOTES_TAB} - {showTimeline && numberOfNotes > 0 && timelineType === TimelineType.default && ( + {showTimeline && numberOfNotes > 0 && timelineType === TimelineTypeEnum.default && (

{numberOfNotes}
@@ -408,16 +408,18 @@ const TabsContentComponent: React.FC = ({ {i18n.PINNED_TAB} - {showTimeline && numberOfPinnedEvents > 0 && timelineType === TimelineType.default && ( -
- {numberOfPinnedEvents} -
- )} + {showTimeline && + numberOfPinnedEvents > 0 && + timelineType === TimelineTypeEnum.default && ( +
+ {numberOfPinnedEvents} +
+ )}
)} diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.tsx index 1a836b6a3a392..27d82f01828fe 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.tsx @@ -27,7 +27,7 @@ import { useDeepEqualSelector, useShallowEqualSelector, } from '../../../../../common/hooks/use_selector'; -import { TimelineStatus } from '../../../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../../../common/api/timeline'; import { appSelectors } from '../../../../../common/store/app'; import { AddNote } from '../../../notes/add_note'; import { CREATED_BY, NOTES } from '../../../notes/translations'; @@ -140,7 +140,7 @@ const NotesTabContentComponent: React.FC = ({ timelineId } [] ); const [newNote, setNewNote] = useState(''); - const isImmutable = timelineStatus === TimelineStatus.immutable; + const isImmutable = timelineStatus === TimelineStatusEnum.immutable; const appNotes: TimelineResultNote[] = useDeepEqualSelector(getNotesAsCommentsList); const allTimelineNoteIds = useMemo(() => { diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/header/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/header/index.test.tsx index 526963cd78607..7189c59c1b564 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/header/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/header/index.test.tsx @@ -15,7 +15,7 @@ import { mockDataProviders } from '../../../data_providers/mock/mock_data_provid import { useMountAppended } from '../../../../../../common/utils/use_mount_appended'; import { QueryTabHeader } from '.'; -import { TimelineStatus, TimelineType } from '../../../../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../../../../common/api/timeline'; import { waitFor } from '@testing-library/react'; import { TimelineId, TimelineTabs } from '../../../../../../../common/types'; @@ -46,9 +46,9 @@ describe('Header', () => { onToggleDataProviderType: jest.fn(), show: true, showCallOutUnauthorizedMsg: false, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, timelineId: TimelineId.test, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }; describe('rendering', () => { @@ -122,7 +122,7 @@ describe('Header', () => { ...props, filterManager: new FilterManager(mockUiSettingsForFilterManager), showCallOutUnauthorizedMsg: false, - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }; const wrapper = await getWrapper( @@ -139,7 +139,7 @@ describe('Header', () => { ...props, filterManager: new FilterManager(mockUiSettingsForFilterManager), showCallOutUnauthorizedMsg: false, - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }; const wrapper = await getWrapper( @@ -158,7 +158,7 @@ describe('Header', () => { ...props, filterManager: new FilterManager(mockUiSettingsForFilterManager), showCallOutUnauthorizedMsg: false, - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }; const wrapper = await getWrapper( diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/header/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/header/index.tsx index 069d3c33234b3..b70475787eb65 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/header/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/header/index.tsx @@ -16,8 +16,11 @@ import { useIsExperimentalFeatureEnabled } from '../../../../../../common/hooks/ import { useTimelineEventsCountPortal } from '../../../../../../common/hooks/use_timeline_events_count'; import { useTimelineFullScreen } from '../../../../../../common/containers/use_full_screen'; import { ExitFullScreen } from '../../../../../../common/components/exit_full_screen'; -import type { TimelineStatusLiteralWithNull } from '../../../../../../../common/api/timeline'; -import { TimelineStatus, TimelineType } from '../../../../../../../common/api/timeline'; +import { + type TimelineStatus, + TimelineStatusEnum, + TimelineTypeEnum, +} from '../../../../../../../common/api/timeline'; import type { TimelineTabs } from '../../../../../../../common/types/timeline'; import { timelineSelectors } from '../../../../../store'; import { useDeepEqualSelector } from '../../../../../../common/hooks/use_selector'; @@ -33,7 +36,7 @@ interface Props { show: boolean; showCallOutUnauthorizedMsg: boolean; showEventsCountBadge: boolean; - status: TimelineStatusLiteralWithNull; + status: TimelineStatus | null; timelineId: string; totalCount: number; } @@ -87,7 +90,8 @@ const QueryTabHeaderComponent: React.FC = ({ (state) => getIsDataProviderVisible(state, timelineId) ?? timelineDefaults.isDataProviderVisible ); - const shouldShowQueryBuilder = isDataProviderVisible || timelineType === TimelineType.template; + const shouldShowQueryBuilder = + isDataProviderVisible || timelineType === TimelineTypeEnum.template; return ( @@ -126,7 +130,7 @@ const QueryTabHeaderComponent: React.FC = ({ /> )} - {status === TimelineStatus.immutable && ( + {status === TimelineStatusEnum.immutable && ( { showCallOutUnauthorizedMsg: false, sort, start: startDate, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, timerangeKind: 'absolute', activeTab: TimelineTabs.query, show: true, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tour/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tour/index.test.tsx index c5ae53a66032b..5a46b3b1b561c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tour/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tour/index.test.tsx @@ -17,7 +17,7 @@ import { TestProviders, } from '../../../../common/mock'; import { TimelineTabs } from '../../../../../common/types'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { useKibana as mockUseKibana } from '../../../../common/lib/kibana/__mocks__'; import { useKibana } from '../../../../common/lib/kibana'; @@ -38,7 +38,7 @@ const TestComponent = (props: Partial = {}) => { {Object.values(TIMELINE_TOUR_CONFIG_ANCHORS).map((anchor) => { @@ -103,7 +103,7 @@ describe('Timeline Tour', () => { }); it('should render different tour steps when timeline type is template', async () => { - render(); + render(); await waitFor(() => { expect(screen.getByTestId('timeline-tour-step-1')).toBeVisible(); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tour/step_config.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tour/step_config.tsx index 265f87a61d0bc..719a06de6d457 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tour/step_config.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tour/step_config.tsx @@ -8,7 +8,7 @@ import { EuiText, EuiCode } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import { TimelineTabs } from '../../../../../common/types'; import * as i18n from './translations'; @@ -66,7 +66,7 @@ export const timelineTourSteps = [ anchor: TIMELINE_TOUR_CONFIG_ANCHORS.DATA_VIEW, }, { - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, timelineTab: TimelineTabs.query, title: i18n.TIMELINE_TOUR_DATA_PROVIDER_VISIBILITY_TITLE, content: {i18n.TIMELINE_TOUR_DATA_PROVIDER_VISIBILITY_DESCRIPTION}, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/translations.ts b/x-pack/plugins/security_solution/public/timelines/components/timeline/translations.ts index 2caf4eee6f1c5..f799a0e64a43e 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/translations.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/translations.ts @@ -6,8 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { TimelineTypeLiteral } from '../../../../common/api/timeline'; -import { TimelineType } from '../../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../../common/api/timeline'; export const DEFAULT_TIMELINE_TITLE = i18n.translate( 'xpack.securitySolution.timeline.defaultTimelineTitle', @@ -35,10 +34,10 @@ export const EVENTS_TABLE_ARIA_LABEL = ({ defaultMessage: 'events; Page {activePage} of {totalPages}', }); -export const SEARCH_BOX_TIMELINE_PLACEHOLDER = (timelineType: TimelineTypeLiteral) => +export const SEARCH_BOX_TIMELINE_PLACEHOLDER = (timelineType: TimelineType) => i18n.translate('xpack.securitySolution.timeline.searchBoxPlaceholder', { values: { - timeline: timelineType === TimelineType.template ? 'Timeline template' : 'Timeline', + timeline: timelineType === TimelineTypeEnum.template ? 'Timeline template' : 'Timeline', }, defaultMessage: 'e.g. {timeline} name or description', }); diff --git a/x-pack/plugins/security_solution/public/timelines/containers/all/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/all/index.tsx index 5e88cf8b63cfe..7a2b3eca0f74b 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/all/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/all/index.tsx @@ -18,14 +18,14 @@ import { inputsActions } from '../../../common/store/inputs'; import * as i18n from '../../pages/translations'; import type { - TimelineTypeLiteralWithNull, - TimelineStatusLiteralWithNull, + TimelineType, + TimelineStatus, PageInfoTimeline, TimelineResult, SortTimeline, GetAllTimelineVariables, } from '../../../../common/api/timeline'; -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; import { getAllTimelines } from '../api'; export interface AllTimelinesArgs { @@ -52,8 +52,8 @@ export interface AllTimelinesVariables { pageInfo: PageInfoTimeline; search: string; sort: SortTimeline; - status: TimelineStatusLiteralWithNull; - timelineType: TimelineTypeLiteralWithNull; + status: TimelineStatus | null; + timelineType: TimelineType | null; } export const ALL_TIMELINE_QUERY_ID = 'FETCH_ALL_TIMELINES'; @@ -93,7 +93,7 @@ export const getAllTimeline = memoizeOne( title: timeline.title, updated: timeline.updated, updatedBy: timeline.updatedBy, - timelineType: timeline.timelineType ?? TimelineType.default, + timelineType: timeline.timelineType ?? TimelineTypeEnum.default, templateTimelineId: timeline.templateTimelineId, queryType: getTimelineQueryTypes(timeline), })) diff --git a/x-pack/plugins/security_solution/public/timelines/containers/api.test.ts b/x-pack/plugins/security_solution/public/timelines/containers/api.test.ts index e6238d462e3c3..ba76f857dc34c 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/api.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/containers/api.test.ts @@ -9,7 +9,7 @@ import { createSearchSourceMock } from '@kbn/data-plugin/public/mocks'; import { buildDataViewMock, shallowMockedFields } from '@kbn/discover-utils/src/__mocks__'; import * as api from './api'; import { KibanaServices } from '../../common/lib/kibana'; -import { TimelineType, TimelineStatus } from '../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../common/api/timeline'; import { TIMELINE_DRAFT_URL, TIMELINE_URL, TIMELINE_COPY_URL } from '../../../common/constants'; import type { ImportDataProps } from '../../detection_engine/rule_management/logic/types'; @@ -70,7 +70,7 @@ const timelineData = { filterQuery: null, }, title: '', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineVersion: null, templateTimelineId: null, dateRange: { @@ -84,7 +84,7 @@ const timelineData = { sortDirection: 'desc', }, ], - status: TimelineStatus.active, + status: TimelineStatusEnum.active, savedSearchId: null, }; const mockPatchTimelineResponse = { @@ -105,7 +105,7 @@ describe('persistTimeline', () => { const timelineId = null; const initialDraftTimeline = { ...timelineData, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }; const mockDraftResponse = { data: { @@ -177,7 +177,7 @@ describe('persistTimeline', () => { const timelineId = null; const initialDraftTimeline = { ...timelineData, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }; const version = null; @@ -388,7 +388,7 @@ describe('exportSelectedTimeline', () => { }); describe('getDraftTimeline', () => { - const timelineType = { timelineType: TimelineType.default }; + const timelineType = { timelineType: TimelineTypeEnum.default }; const getMock = jest.fn(); beforeAll(() => { @@ -426,7 +426,7 @@ describe('cleanDraftTimeline', () => { }); test('should pass correct args to KibanaServices - timeline', () => { - const args = { timelineType: TimelineType.default }; + const args = { timelineType: TimelineTypeEnum.default }; api.cleanDraftTimeline(args); @@ -438,7 +438,7 @@ describe('cleanDraftTimeline', () => { test('should pass correct args to KibanaServices - timeline template', () => { const args = { - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, templateTimelineId: 'test-123', templateTimelineVersion: 1, }; diff --git a/x-pack/plugins/security_solution/public/timelines/containers/api.ts b/x-pack/plugins/security_solution/public/timelines/containers/api.ts index 4b1c106230fdd..a6e1f448f5191 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/api.ts +++ b/x-pack/plugins/security_solution/public/timelines/containers/api.ts @@ -25,13 +25,14 @@ import type { } from '../../../common/api/timeline'; import { TimelineResponseType, - TimelineStatus, + TimelineStatusEnum, TimelineErrorResponseType, importTimelineResultSchema, allTimelinesResponse, responseFavoriteTimeline, SingleTimelineResponseType, - TimelineType, + type TimelineType, + TimelineTypeEnum, ResolvedSingleTimelineResponseType, } from '../../../common/api/timeline'; import { @@ -229,7 +230,7 @@ export const persistTimeline = async ({ savedSearch, }: RequestPersistTimeline): Promise => { try { - if (isEmpty(timelineId) && timeline.status === TimelineStatus.draft && timeline) { + if (isEmpty(timelineId) && timeline.status === TimelineStatusEnum.draft && timeline) { const temp: TimelineResponse | TimelineErrorResponse = await cleanDraftTimeline({ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion timelineType: timeline.timelineType!, @@ -239,7 +240,7 @@ export const persistTimeline = async ({ const draftTimeline = decodeTimelineResponse(temp); const templateTimelineInfo = - timeline.timelineType === TimelineType.template + timeline.timelineType === TimelineTypeEnum.template ? { templateTimelineId: draftTimeline.data.persistTimeline.timeline.templateTimelineId ?? @@ -355,7 +356,7 @@ export const cleanDraftTimeline = async ({ }): Promise => { let requestBody; const templateTimelineInfo = - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? { templateTimelineId, templateTimelineVersion, diff --git a/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.test.tsx b/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.test.tsx index 49e16b927c0ca..59a1936465d52 100644 --- a/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { useCreateTimeline } from './use_create_timeline'; import type { TimeRange } from '../../common/store/inputs/model'; -import { RowRendererCount, TimelineType } from '../../../common/api/timeline'; +import { RowRendererCount, TimelineTypeEnum } from '../../../common/api/timeline'; import { TimelineId } from '../../../common/types'; import { useDiscoverInTimelineContext } from '../../common/components/discover_in_timeline/use_discover_in_timeline_context'; import { timelineActions } from '../store'; @@ -41,7 +41,8 @@ describe('useCreateTimeline', () => { it('should return a function', () => { const hookResult = renderHook( - () => useCreateTimeline({ timelineId: TimelineId.test, timelineType: TimelineType.default }), + () => + useCreateTimeline({ timelineId: TimelineId.test, timelineType: TimelineTypeEnum.default }), { wrapper: ({ children }) => {children}, } @@ -57,7 +58,8 @@ describe('useCreateTimeline', () => { const addNotes = jest.spyOn(appActions, 'addNotes'); const hookResult = renderHook( - () => useCreateTimeline({ timelineId: TimelineId.test, timelineType: TimelineType.default }), + () => + useCreateTimeline({ timelineId: TimelineId.test, timelineType: TimelineTypeEnum.default }), { wrapper: ({ children }) => {children}, } @@ -67,7 +69,7 @@ describe('useCreateTimeline', () => { await hookResult.result.current(); expect(createTimeline.mock.calls[0][0].id).toEqual(TimelineId.test); - expect(createTimeline.mock.calls[0][0].timelineType).toEqual(TimelineType.default); + expect(createTimeline.mock.calls[0][0].timelineType).toEqual(TimelineTypeEnum.default); expect(createTimeline.mock.calls[0][0].columns).toEqual(defaultUdtHeaders); expect(createTimeline.mock.calls[0][0].dataViewId).toEqual( mockGlobalState.sourcerer.defaultDataView.id @@ -99,7 +101,7 @@ describe('useCreateTimeline', () => { () => useCreateTimeline({ timelineId: TimelineId.test, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, onClick, }), { @@ -118,7 +120,8 @@ describe('useCreateTimeline', () => { const setAbsoluteRangeDatePicker = jest.spyOn(inputsActions, 'setAbsoluteRangeDatePicker'); const hookResult = renderHook( - () => useCreateTimeline({ timelineId: TimelineId.test, timelineType: TimelineType.default }), + () => + useCreateTimeline({ timelineId: TimelineId.test, timelineType: TimelineTypeEnum.default }), { wrapper: ({ children }) => {children}, } @@ -138,7 +141,8 @@ describe('useCreateTimeline', () => { const setRelativeRangeDatePicker = jest.spyOn(inputsActions, 'setRelativeRangeDatePicker'); const hookResult = renderHook( - () => useCreateTimeline({ timelineId: TimelineId.test, timelineType: TimelineType.default }), + () => + useCreateTimeline({ timelineId: TimelineId.test, timelineType: TimelineTypeEnum.default }), { wrapper: ({ children }) => {children}, } diff --git a/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.tsx b/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.tsx index 31404b54957f7..c7b5252e0897b 100644 --- a/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.tsx +++ b/x-pack/plugins/security_solution/public/timelines/hooks/use_create_timeline.tsx @@ -12,8 +12,7 @@ import { defaultHeaders } from '../components/timeline/body/column_headers/defau import { timelineActions } from '../store'; import { useTimelineFullScreen } from '../../common/containers/use_full_screen'; import { TimelineId } from '../../../common/types/timeline'; -import type { TimelineTypeLiteral } from '../../../common/api/timeline'; -import { TimelineType } from '../../../common/api/timeline'; +import { type TimelineType, TimelineTypeEnum } from '../../../common/api/timeline'; import { useDeepEqualSelector } from '../../common/hooks/use_selector'; import { inputsActions, inputsSelectors } from '../../common/store/inputs'; import { sourcererActions, sourcererSelectors } from '../../sourcerer/store'; @@ -33,7 +32,7 @@ export interface UseCreateTimelineParams { /** * Type of the timeline (default, template) */ - timelineType: TimelineTypeLiteral; + timelineType: TimelineType; /** * Callback to be called when the timeline is created */ @@ -88,7 +87,7 @@ export const useCreateTimeline = ({ timelineType, updated: undefined, excludedRowRendererIds: - !unifiedComponentsInTimelineDisabled && timelineType !== TimelineType.template + !unifiedComponentsInTimelineDisabled && timelineType !== TimelineTypeEnum.template ? timelineDefaults.excludedRowRendererIds : [], }) diff --git a/x-pack/plugins/security_solution/public/timelines/pages/index.tsx b/x-pack/plugins/security_solution/public/timelines/pages/index.tsx index 0fc2c87246a70..c7e8cb9887efe 100644 --- a/x-pack/plugins/security_solution/public/timelines/pages/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/pages/index.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Redirect } from 'react-router-dom'; import { Routes, Route } from '@kbn/shared-ux-router'; -import { TimelineType } from '../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../common/api/timeline'; import { TimelinesPage } from './timelines_page'; @@ -17,8 +17,8 @@ import { appendSearch } from '../../common/components/link_to/helpers'; import { TIMELINES_PATH } from '../../../common/constants'; -const timelinesPagePath = `${TIMELINES_PATH}/:tabName(${TimelineType.default}|${TimelineType.template}|notes)`; -const timelinesDefaultPath = `${TIMELINES_PATH}/${TimelineType.default}`; +const timelinesPagePath = `${TIMELINES_PATH}/:tabName(${TimelineTypeEnum.default}|${TimelineTypeEnum.template}|notes)`; +const timelinesDefaultPath = `${TIMELINES_PATH}/${TimelineTypeEnum.default}`; export const Timelines = React.memo(() => ( diff --git a/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.tsx b/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.tsx index 459c37a4133f8..9d3c05c97b685 100644 --- a/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.tsx +++ b/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.tsx @@ -9,7 +9,7 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { useCallback, useState } from 'react'; import { useParams } from 'react-router-dom'; import { NewTimelineButton } from '../components/new_timeline'; -import { TimelineType } from '../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../common/api/timeline'; import { HeaderPage } from '../../common/components/header_page'; import { SecuritySolutionPageWrapper } from '../../common/components/page_wrapper'; import { useKibana } from '../../common/lib/kibana'; @@ -33,8 +33,8 @@ export const TimelinesPage = React.memo(() => { setImportDataModal(true); }, [setImportDataModal]); - const timelineType: TimelineType = - tabName === TimelineType.default ? TimelineType.default : TimelineType.template; + const timelineType = + tabName === TimelineTypeEnum.default ? TimelineTypeEnum.default : TimelineTypeEnum.template; return ( <> diff --git a/x-pack/plugins/security_solution/public/timelines/store/actions.ts b/x-pack/plugins/security_solution/public/timelines/store/actions.ts index 8c228abc5a292..2517b44d2daae 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/actions.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/actions.ts @@ -12,7 +12,6 @@ import type { SavedSearch } from '@kbn/saved-search-plugin/common'; import type { SessionViewConfig } from '../../../common/types'; import type { DataProvider, - DataProviderType, QueryOperator, } from '../components/timeline/data_providers/data_provider'; @@ -29,7 +28,7 @@ import type { ColumnHeaderOptions, SortColumnTimeline, } from '../../../common/types/timeline'; -import type { RowRendererId } from '../../../common/api/timeline'; +import type { DataProviderType, RowRendererId } from '../../../common/api/timeline'; import type { ResolveTimelineConfig } from '../components/open_timeline/types'; const actionCreator = actionCreatorFactory('x-pack/security_solution/local/timeline'); diff --git a/x-pack/plugins/security_solution/public/timelines/store/defaults.ts b/x-pack/plugins/security_solution/public/timelines/store/defaults.ts index 1dfe5ed6bc1ee..dd9b811e144e8 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/defaults.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/defaults.ts @@ -6,7 +6,11 @@ */ import { TimelineTabs } from '../../../common/types/timeline'; -import { TimelineType, TimelineStatus, RowRendererId } from '../../../common/api/timeline'; +import { + TimelineTypeEnum, + TimelineStatusEnum, + RowRendererIdEnum, +} from '../../../common/api/timeline'; import { defaultHeaders } from '../components/timeline/body/column_headers/default_headers'; import { normalizeTimeRange } from '../../common/utils/normalize_time_range'; @@ -37,24 +41,24 @@ export const timelineDefaults: SubsetTimelineModel & eventType: 'all', eventIdToNoteIds: {}, excludedRowRendererIds: [ - RowRendererId.alert, - RowRendererId.alerts, - RowRendererId.auditd, - RowRendererId.auditd_file, - RowRendererId.library, - RowRendererId.netflow, - RowRendererId.plain, - RowRendererId.registry, - RowRendererId.suricata, - RowRendererId.system, - RowRendererId.system_dns, - RowRendererId.system_endgame_process, - RowRendererId.system_file, - RowRendererId.system_fim, - RowRendererId.system_security_event, - RowRendererId.system_socket, - RowRendererId.threat_match, - RowRendererId.zeek, + RowRendererIdEnum.alert, + RowRendererIdEnum.alerts, + RowRendererIdEnum.auditd, + RowRendererIdEnum.auditd_file, + RowRendererIdEnum.library, + RowRendererIdEnum.netflow, + RowRendererIdEnum.plain, + RowRendererIdEnum.registry, + RowRendererIdEnum.suricata, + RowRendererIdEnum.system, + RowRendererIdEnum.system_dns, + RowRendererIdEnum.system_endgame_process, + RowRendererIdEnum.system_file, + RowRendererIdEnum.system_fim, + RowRendererIdEnum.system_security_event, + RowRendererIdEnum.system_socket, + RowRendererIdEnum.threat_match, + RowRendererIdEnum.zeek, ], highlightedDropAndProviderId: '', historyIds: [], @@ -73,7 +77,7 @@ export const timelineDefaults: SubsetTimelineModel & resolveTimelineConfig: undefined, queryFields: [], title: '', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, noteIds: [], @@ -91,7 +95,7 @@ export const timelineDefaults: SubsetTimelineModel & sortDirection: 'desc', }, ], - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, version: null, deletedEventIds: [], selectedEventIds: {}, diff --git a/x-pack/plugins/security_solution/public/timelines/store/helpers.test.ts b/x-pack/plugins/security_solution/public/timelines/store/helpers.test.ts index a34853eb39f90..4503d1026d7c8 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/helpers.test.ts @@ -8,12 +8,16 @@ import { cloneDeep } from 'lodash/fp'; import type { ColumnHeaderOptions } from '../../../common/types/timeline'; import { TimelineTabs, TimelineId } from '../../../common/types/timeline'; -import { TimelineType, TimelineStatus } from '../../../common/api/timeline'; +import { + DataProviderTypeEnum, + TimelineTypeEnum, + TimelineStatusEnum, +} from '../../../common/api/timeline'; import type { DataProvider, DataProvidersAnd, } from '../components/timeline/data_providers/data_provider'; -import { IS_OPERATOR, DataProviderType } from '../components/timeline/data_providers/data_provider'; +import { IS_OPERATOR } from '../components/timeline/data_providers/data_provider'; import { defaultColumnHeaderType } from '../components/timeline/body/column_headers/default_headers'; import { DEFAULT_COLUMN_MIN_WIDTH, @@ -123,10 +127,10 @@ const basicTimeline: TimelineModel = { sortDirection: Direction.desc, }, ], - status: TimelineStatus.active, + status: TimelineStatusEnum.active, templateTimelineId: null, templateTimelineVersion: null, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, title: '', version: null, savedSearchId: null, @@ -141,7 +145,7 @@ const timelineByIdMock: TimelineById = { const timelineByIdTemplateMock: TimelineById = { foo: { ...basicTimeline, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }, }; @@ -175,8 +179,8 @@ describe('Timeline', () => { id: 'foo', timeline: { ...basicTimeline, - status: TimelineStatus.immutable, - timelineType: TimelineType.template, + status: TimelineStatusEnum.immutable, + timelineType: TimelineTypeEnum.template, }, timelineById: timelineByIdMock, }); @@ -184,8 +188,8 @@ describe('Timeline', () => { expect(update).toEqual({ foo: { ...basicTimeline, - status: TimelineStatus.immutable, - timelineType: TimelineType.template, + status: TimelineStatusEnum.immutable, + timelineType: TimelineTypeEnum.template, dateRange: { start: '2020-10-27T11:37:31.655Z', end: '2020-10-28T11:37:31.655Z', @@ -204,7 +208,7 @@ describe('Timeline', () => { dataViewId: null, indexNames: [], timelineById: timelineByIdMock, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, savedSearchId: null, }); expect(update).not.toBe(timelineByIdMock); @@ -217,7 +221,7 @@ describe('Timeline', () => { dataViewId: null, indexNames: [], timelineById: timelineByIdMock, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, savedSearchId: null, }); expect(update).toEqual({ @@ -236,7 +240,7 @@ describe('Timeline', () => { dataViewId: null, indexNames: [], timelineById: timelineByIdMock, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, savedSearchId: null, }); expect(update).toEqual({ @@ -1218,7 +1222,7 @@ describe('Timeline', () => { const update = updateTimelineProviderType({ id: 'foo', providerId: '123', - type: DataProviderType.template, // value we are updating from default to template + type: DataProviderTypeEnum.template, // value we are updating from default to template timelineById: timelineByIdMock, }); expect(update).toBe(timelineByIdMock); @@ -1228,7 +1232,7 @@ describe('Timeline', () => { const update = updateTimelineProviderType({ id: 'foo', providerId: '123', - type: DataProviderType.template, // value we are updating from default to template + type: DataProviderTypeEnum.template, // value we are updating from default to template timelineById: timelineByIdTemplateMock, }); expect(update).not.toBe(timelineByIdTemplateMock); @@ -1238,7 +1242,7 @@ describe('Timeline', () => { const update = updateTimelineProviderType({ id: 'foo', providerId: '123', - type: DataProviderType.template, // value we are updating from default to template + type: DataProviderTypeEnum.template, // value we are updating from default to template timelineById: timelineByIdTemplateMock, }); expect(update.foo.dataProviders).not.toBe(timelineByIdTemplateMock.foo.dataProviders); @@ -1248,7 +1252,7 @@ describe('Timeline', () => { const update = updateTimelineProviderType({ id: 'foo', providerId: '123', - type: DataProviderType.template, + type: DataProviderTypeEnum.template, timelineById: timelineByIdTemplateMock, }); const expected: TimelineById = { @@ -1263,10 +1267,10 @@ describe('Timeline', () => { value: '{}', operator: IS_OPERATOR, }, - type: DataProviderType.template, + type: DataProviderTypeEnum.template, }, ], - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }, }; @@ -1278,7 +1282,7 @@ describe('Timeline', () => { { ...basicDataProvider, id: '456', - type: DataProviderType.template, + type: DataProviderTypeEnum.template, }, ]; @@ -1292,14 +1296,14 @@ describe('Timeline', () => { const update = updateTimelineProviderType({ id: 'foo', providerId: '123', - type: DataProviderType.template, // value we are updating from default to template + type: DataProviderTypeEnum.template, // value we are updating from default to template timelineById: multiDataProviderMock, }); const expected = [ { ...basicDataProvider, name: '', - type: DataProviderType.template, + type: DataProviderTypeEnum.template, queryMatch: { field: '', value: '{}', @@ -1309,7 +1313,7 @@ describe('Timeline', () => { { ...basicDataProvider, id: '456', - type: DataProviderType.template, + type: DataProviderTypeEnum.template, }, ]; expect(update.foo.dataProviders).toEqual(expected); diff --git a/x-pack/plugins/security_solution/public/timelines/store/helpers.ts b/x-pack/plugins/security_solution/public/timelines/store/helpers.ts index 5b8f9c9c099eb..dca69b8615804 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/helpers.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/helpers.ts @@ -16,11 +16,13 @@ import type { QueryOperator, QueryMatch, } from '../components/timeline/data_providers/data_provider'; +import { IS_OPERATOR, EXISTS_OPERATOR } from '../components/timeline/data_providers/data_provider'; import { - DataProviderType, - IS_OPERATOR, - EXISTS_OPERATOR, -} from '../components/timeline/data_providers/data_provider'; + type DataProviderType, + DataProviderTypeEnum, + TimelineStatusEnum, + TimelineTypeEnum, +} from '../../../common/api/timeline'; import type { ColumnHeaderOptions, TimelineEventsType, @@ -28,9 +30,8 @@ import type { TimelinePersistInput, SortColumnTimeline, } from '../../../common/types/timeline'; -import type { RowRendererId, TimelineTypeLiteral } from '../../../common/api/timeline'; +import type { RowRendererId, TimelineType } from '../../../common/api/timeline'; import { TimelineId } from '../../../common/types/timeline'; -import { TimelineStatus, TimelineType } from '../../../common/api/timeline'; import { normalizeTimeRange } from '../../common/utils/normalize_time_range'; import { getTimelineManageDefaults, timelineDefaults } from './defaults'; import type { KqlMode, TimelineModel } from './model'; @@ -133,8 +134,8 @@ export const addTimelineToStore = ({ initialized: timeline.initialized ?? timelineById[id].initialized, resolveTimelineConfig, dateRange: - timeline.status === TimelineStatus.immutable && - timeline.timelineType === TimelineType.template + timeline.status === TimelineStatusEnum.immutable && + timeline.timelineType === TimelineTypeEnum.template ? { start: DEFAULT_FROM_MOMENT.toISOString(), end: DEFAULT_TO_MOMENT.toISOString(), @@ -146,7 +147,7 @@ export const addTimelineToStore = ({ interface AddNewTimelineParams extends TimelinePersistInput { timelineById: TimelineById; - timelineType: TimelineTypeLiteral; + timelineType: TimelineType; } /** Adds a new `Timeline` to the provided collection of `TimelineById` */ @@ -161,7 +162,7 @@ export const addNewTimeline = ({ const { from: startDateRange, to: endDateRange } = normalizeTimeRange({ from: '', to: '' }); const dateRange = maybeDateRange ?? { start: startDateRange, end: endDateRange }; const templateTimelineInfo = - timelineType === TimelineType.template + timelineType === TimelineTypeEnum.template ? { templateTimelineId: uuidv4(), templateTimelineVersion: 1, @@ -971,14 +972,17 @@ const updateTypeAndProvider = ( ? { ...andProvider, type, - name: type === DataProviderType.template ? `${andProvider.queryMatch.field}` : '', + name: + type === DataProviderTypeEnum.template ? `${andProvider.queryMatch.field}` : '', queryMatch: { ...andProvider.queryMatch, displayField: undefined, displayValue: undefined, value: - type === DataProviderType.template ? `{${andProvider.queryMatch.field}}` : '', - operator: (type === DataProviderType.template + type === DataProviderTypeEnum.template + ? `{${andProvider.queryMatch.field}}` + : '', + operator: (type === DataProviderTypeEnum.template ? IS_OPERATOR : EXISTS_OPERATOR) as QueryOperator, }, @@ -995,13 +999,13 @@ const updateTypeProvider = (type: DataProviderType, providerId: string, timeline ? { ...provider, type, - name: type === DataProviderType.template ? `${provider.queryMatch.field}` : '', + name: type === DataProviderTypeEnum.template ? `${provider.queryMatch.field}` : '', queryMatch: { ...provider.queryMatch, displayField: undefined, displayValue: undefined, - value: type === DataProviderType.template ? `{${provider.queryMatch.field}}` : '', - operator: (type === DataProviderType.template + value: type === DataProviderTypeEnum.template ? `{${provider.queryMatch.field}}` : '', + operator: (type === DataProviderTypeEnum.template ? IS_OPERATOR : EXISTS_OPERATOR) as QueryOperator, }, @@ -1018,7 +1022,10 @@ export const updateTimelineProviderType = ({ }: UpdateTimelineProviderTypeParams): TimelineById => { const timeline = timelineById[id]; - if (timeline.timelineType !== TimelineType.template && type === DataProviderType.template) { + if ( + timeline.timelineType !== TimelineTypeEnum.template && + type === DataProviderTypeEnum.template + ) { // Not supported, timeline template cannot have template type providers return timelineById; } diff --git a/x-pack/plugins/security_solution/public/timelines/store/middlewares/helpers.test.ts b/x-pack/plugins/security_solution/public/timelines/store/middlewares/helpers.test.ts index e58d797c95120..85bf3652ab0b9 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/middlewares/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/middlewares/helpers.test.ts @@ -7,7 +7,7 @@ import { createMockStore, kibanaMock, mockGlobalState } from '../../../common/mock'; import { TimelineId } from '../../../../common/types/timeline'; -import { TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../common/api/timeline'; import { persistTimeline } from '../../containers/api'; import { ensureTimelineIsSaved } from './helpers'; @@ -58,7 +58,7 @@ describe('Timeline middleware helpers', () => { }); expect(returnedTimeline.savedObjectId).toBe(mockSavedObjectId); - expect(returnedTimeline.status).toBe(TimelineStatus.draft); + expect(returnedTimeline.status).toBe(TimelineStatusEnum.draft); }); }); }); diff --git a/x-pack/plugins/security_solution/public/timelines/store/middlewares/helpers.ts b/x-pack/plugins/security_solution/public/timelines/store/middlewares/helpers.ts index cf1d74e07051c..c5cb62b523bb8 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/middlewares/helpers.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/middlewares/helpers.ts @@ -12,7 +12,7 @@ import type { inputsModel } from '../../../common/store/inputs'; import { inputsSelectors } from '../../../common/store/inputs'; import type { TimelineModel } from '../model'; import { saveTimeline, updateTimeline } from '../actions'; -import { TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineStatusEnum } from '../../../../common/api/timeline'; import { selectTimelineById } from '../selectors'; /** @@ -51,7 +51,7 @@ export async function ensureTimelineIsSaved({ id: localTimelineId, timeline: { ...timeline, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }, }) ); diff --git a/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_favorite.ts b/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_favorite.ts index 8cf58908bb2ed..17fd55ee194c1 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_favorite.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_favorite.ts @@ -18,7 +18,7 @@ import { showCallOutUnauthorizedMsg, } from '../actions'; import type { ResponseFavoriteTimeline } from '../../../../common/api/timeline'; -import { TimelineType } from '../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../common/api/timeline'; import { persistFavorite } from '../../containers/api'; import { selectTimelineById } from '../selectors'; import * as i18n from '../../pages/translations'; @@ -46,7 +46,7 @@ export const favoriteTimelineMiddleware: (kibana: CoreStart) => Middleware<{}, S timelineId: timeline.id, templateTimelineId: timeline.templateTimelineId, templateTimelineVersion: timeline.templateTimelineVersion, - timelineType: timeline.timelineType ?? TimelineType.default, + timelineType: timeline.timelineType ?? TimelineTypeEnum.default, }); const response: ResponseFavoriteTimeline = get('data.persistFavorite', result); diff --git a/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_save.test.ts b/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_save.test.ts index b42c520e72b60..6051c9c1bb4e5 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_save.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_save.test.ts @@ -9,7 +9,7 @@ import type { Filter } from '@kbn/es-query'; import { FilterStateStore } from '@kbn/es-query'; import { Direction } from '../../../../common/search_strategy'; import { TimelineId, TimelineTabs } from '../../../../common/types/timeline'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../common/api/timeline'; import { convertTimelineAsInput } from './timeline_save'; import type { TimelineModel } from '../model'; import { createMockStore, kibanaMock } from '../../../common/mock'; @@ -310,7 +310,7 @@ describe('Timeline save middleware', () => { loadingEventIds: [], queryFields: [], title: 'saved', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: null, noteIds: [], @@ -330,7 +330,7 @@ describe('Timeline save middleware', () => { sortDirection: Direction.desc, }, ], - status: TimelineStatus.active, + status: TimelineStatusEnum.active, version: 'WzM4LDFd', id: '11169110-fc22-11e9-8ca9-072f15ce2685', savedQueryId: 'my endgame timeline query', @@ -483,9 +483,9 @@ describe('Timeline save middleware', () => { ], templateTimelineId: null, templateTimelineVersion: null, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, title: 'saved', - status: TimelineStatus.active, + status: TimelineStatusEnum.active, }); }); }); diff --git a/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_save.ts b/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_save.ts index e8d1e335ab569..dcbbc5cadb6d0 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_save.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/middlewares/timeline_save.ts @@ -33,7 +33,7 @@ import { inputsSelectors } from '../../../common/store/inputs'; import { selectTimelineById } from '../selectors'; import * as i18n from '../../pages/translations'; import type { inputsModel } from '../../../common/store/inputs'; -import { TimelineStatus, TimelineType } from '../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../common/api/timeline'; import type { TimelineErrorResponse, TimelineResponse } from '../../../../common/api/timeline'; import type { TimelineInput } from '../../../../common/search_strategy'; import type { TimelineModel } from '../model'; @@ -124,8 +124,8 @@ export const saveTimelineMiddleware: (kibana: CoreStart) => Middleware<{}, State updated: response.timeline.updated ?? undefined, savedObjectId: response.timeline.savedObjectId, version: response.timeline.version, - status: response.timeline.status ?? TimelineStatus.active, - timelineType: response.timeline.timelineType ?? TimelineType.default, + status: response.timeline.status ?? TimelineStatusEnum.active, + timelineType: response.timeline.timelineType ?? TimelineTypeEnum.default, templateTimelineId: response.timeline.templateTimelineId ?? null, templateTimelineVersion: response.timeline.templateTimelineVersion ?? null, savedSearchId: response.timeline.savedSearchId ?? null, @@ -168,7 +168,7 @@ const timelineInput: TimelineInput = { kqlQuery: null, indexNames: null, title: null, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineVersion: null, templateTimelineId: null, dateRange: null, diff --git a/x-pack/plugins/security_solution/public/timelines/store/reducer.ts b/x-pack/plugins/security_solution/public/timelines/store/reducer.ts index f51ee7b451373..ba93b512136c8 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/reducer.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/reducer.ts @@ -109,7 +109,7 @@ import { import type { TimelineState } from './types'; import { EMPTY_TIMELINE_BY_ID } from './types'; -import { TimelineType } from '../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../common/api/timeline'; export const initialTimelineState: TimelineState = { timelineById: EMPTY_TIMELINE_BY_ID, @@ -128,17 +128,20 @@ export const timelineReducer = reducerWithInitialState(initialTimelineState) timelineById: state.timelineById, }), })) - .case(createTimeline, (state, { id, timelineType = TimelineType.default, ...timelineProps }) => { - return { - ...state, - timelineById: addNewTimeline({ - id, - timelineById: state.timelineById, - timelineType, - ...timelineProps, - }), - }; - }) + .case( + createTimeline, + (state, { id, timelineType = TimelineTypeEnum.default, ...timelineProps }) => { + return { + ...state, + timelineById: addNewTimeline({ + id, + timelineById: state.timelineById, + timelineType, + ...timelineProps, + }), + }; + } + ) .case(addNote, (state, { id, noteId }) => ({ ...state, timelineById: addTimelineNote({ id, noteId, timelineById: state.timelineById }), diff --git a/x-pack/plugins/security_solution/public/timelines/store/selectors.ts b/x-pack/plugins/security_solution/public/timelines/store/selectors.ts index 19281ba06883d..842ae76c43b1c 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/selectors.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/selectors.ts @@ -17,12 +17,12 @@ import { TimelineTabs } from '../../../common/types'; import type { State } from '../../common/store/types'; import type { TimelineModel } from './model'; import type { InsertTimeline, TimelineById } from './types'; -import { TimelineStatus, TimelineType } from '../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../common/api/timeline'; export const getTimelineShowStatusByIdSelector = () => createSelector(timelineSelectors.selectTimeline, (timeline) => ({ activeTab: timeline?.activeTab ?? TimelineTabs.query, - status: timeline?.status ?? TimelineStatus.draft, + status: timeline?.status ?? TimelineStatusEnum.draft, show: timeline?.show ?? false, updated: timeline?.updated ?? undefined, changed: timeline?.changed ?? false, @@ -145,7 +145,7 @@ export const selectTitleByTimelineById = createSelector( if (!isEmpty(savedTitle)) { return savedTitle; } - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { return UNTITLED_TEMPLATE; } return UNTITLED_TIMELINE; diff --git a/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/import_timelines.ts b/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/import_timelines.ts index eea6d60c739d3..34b6897ce530f 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/import_timelines.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/import_timelines.ts @@ -7,7 +7,7 @@ import { omit } from 'lodash/fp'; import { TimelineId } from '../../../../common/types/timeline'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../common/api/timeline'; export const mockDuplicateIdErrors = []; @@ -140,7 +140,7 @@ export const mockGetTimelineValue = { kqlMode: 'filter', kqlQuery: { filterQuery: [] }, title: 'My duplicate timeline', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, dateRange: { start: '2020-03-18T09:31:47.294Z', end: '2020-03-19T09:31:47.294Z' }, savedQueryId: null, sort: { columnId: '@timestamp', sortDirection: 'desc' }, @@ -154,7 +154,7 @@ export const mockGetTimelineValue = { export const mockGetTemplateTimelineValue = { ...mockGetTimelineValue, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, templateTimelineId: '79deb4c0-6bc1-0000-0000-f5341fb7a189', templateTimelineVersion: 1, }; @@ -187,8 +187,8 @@ export const mockGetDraftTimelineValue = { updatedBy: 'angela', noteIds: [], pinnedEventIds: ['k-gi8nABm-sIqJ_scOoS'], - timelineType: TimelineType.default, - status: TimelineStatus.draft, + timelineType: TimelineTypeEnum.default, + status: TimelineStatusEnum.draft, }; export const mockParsedTimelineObject = omit( diff --git a/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/request_responses.ts b/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/request_responses.ts index 1fdc16d4aeec3..eb4649f941d11 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/request_responses.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/request_responses.ts @@ -21,7 +21,11 @@ import type { createTimelineSchema, GetTimelineQuery, } from '../../../../common/api/timeline'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { + type TimelineType, + TimelineTypeEnum, + TimelineStatusEnum, +} from '../../../../common/api/timeline'; import { requestMock } from '../../detection_engine/routes/__mocks__'; @@ -74,7 +78,7 @@ export const inputTimeline: SavedTimeline = { kqlMode: 'filter', kqlQuery: { filterQuery: null }, title: 't', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, templateTimelineId: null, templateTimelineVersion: 1, dateRange: { start: '2020-03-26T12:50:05.527Z', end: '2020-03-27T12:50:05.527Z' }, @@ -84,7 +88,7 @@ export const inputTimeline: SavedTimeline = { export const inputTemplateTimeline = { ...inputTimeline, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, templateTimelineId: '79deb4c0-6bc1-11ea-inpt-templatea189', templateTimelineVersion: null, }; @@ -94,15 +98,15 @@ export const createTimelineWithoutTimelineId = { timeline: inputTimeline, timelineId: null, version: null, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }; export const createTemplateTimelineWithoutTimelineId = { timeline: inputTemplateTimeline, timelineId: null, version: null, - timelineType: TimelineType.template, - status: TimelineStatus.active, + timelineType: TimelineTypeEnum.template, + status: TimelineStatusEnum.active, }; export const createTimelineWithTimelineId = { diff --git a/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/resolve_timeline.ts b/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/resolve_timeline.ts index b3f2d8adbaba9..ea875a71416c1 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/resolve_timeline.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/__mocks__/resolve_timeline.ts @@ -6,7 +6,7 @@ */ import type { ResolvedTimelineWithOutcomeSavedObject } from '../../../../common/api/timeline'; -import { TimelineStatus, TimelineType } from '../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../common/api/timeline'; export const mockResolvedSavedObject = { saved_object: { @@ -74,7 +74,7 @@ export const mockResolvedTimeline = { eventType: 'all', filters: [], kqlMode: 'filter', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, kqlQuery: { filterQuery: null }, title: 'Test Timeline', sort: [ @@ -84,7 +84,7 @@ export const mockResolvedTimeline = { columnId: '@timestamp', }, ], - status: TimelineStatus.active, + status: TimelineStatusEnum.active, created: 1632932987378, createdBy: 'tester', updated: 1632932988422, diff --git a/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/clean_draft_timelines/index.test.ts b/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/clean_draft_timelines/index.test.ts index acd28651e23cb..ba727f6c0d707 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/clean_draft_timelines/index.test.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/clean_draft_timelines/index.test.ts @@ -6,7 +6,7 @@ */ import type { SecurityPluginSetup } from '@kbn/security-plugin/server'; -import { TimelineType } from '../../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../../common/api/timeline'; import { serverMock, @@ -82,10 +82,10 @@ describe('clean draft timelines', () => { }); const response = await server.inject( - cleanDraftTimelinesRequest(TimelineType.default), + cleanDraftTimelinesRequest(TimelineTypeEnum.default), requestContextMock.convertContext(context) ); - const req = cleanDraftTimelinesRequest(TimelineType.default); + const req = cleanDraftTimelinesRequest(TimelineTypeEnum.default); expect(mockPersistTimeline).toHaveBeenCalled(); expect(mockPersistTimeline.mock.calls[0][3]).toEqual({ ...draftTimelineDefaults, @@ -109,10 +109,10 @@ describe('clean draft timelines', () => { mockGetTimeline.mockResolvedValue({ ...mockGetDraftTimelineValue }); const response = await server.inject( - cleanDraftTimelinesRequest(TimelineType.default), + cleanDraftTimelinesRequest(TimelineTypeEnum.default), requestContextMock.convertContext(context) ); - const req = cleanDraftTimelinesRequest(TimelineType.default); + const req = cleanDraftTimelinesRequest(TimelineTypeEnum.default); expect(mockPersistTimeline).not.toHaveBeenCalled(); expect(mockResetTimeline).toHaveBeenCalled(); diff --git a/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/clean_draft_timelines/index.ts b/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/clean_draft_timelines/index.ts index ae1cff768fded..f8b9ad8392982 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/clean_draft_timelines/index.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/clean_draft_timelines/index.ts @@ -21,7 +21,7 @@ import { persistTimeline, } from '../../../saved_object/timelines'; import { draftTimelineDefaults } from '../../../utils/default_timeline'; -import { cleanDraftTimelineSchema, TimelineType } from '../../../../../../common/api/timeline'; +import { cleanDraftTimelineSchema, TimelineTypeEnum } from '../../../../../../common/api/timeline'; export const cleanDraftTimelinesRoute = (router: SecuritySolutionPluginRouter, _: ConfigType) => { router.versioned @@ -70,7 +70,7 @@ export const cleanDraftTimelinesRoute = (router: SecuritySolutionPluginRouter, _ }); } const templateTimelineData = - request.body.timelineType === TimelineType.template + request.body.timelineType === TimelineTypeEnum.template ? { timelineType: request.body.timelineType, templateTimelineId: uuidv4(), diff --git a/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/get_draft_timelines/index.test.ts b/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/get_draft_timelines/index.test.ts index fd38d5c4a865d..75c9b361bc78f 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/get_draft_timelines/index.test.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/routes/draft_timelines/get_draft_timelines/index.test.ts @@ -6,7 +6,7 @@ */ import type { SecurityPluginSetup } from '@kbn/security-plugin/server'; -import { TimelineType } from '../../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../../common/api/timeline'; import { serverMock, @@ -81,7 +81,7 @@ describe('get draft timelines', () => { mockGetDraftTimeline.mockResolvedValue({ timeline: [], }); - const req = getDraftTimelinesRequest(TimelineType.default); + const req = getDraftTimelinesRequest(TimelineTypeEnum.default); const response = await server.inject(req, requestContextMock.convertContext(context)); expect(mockPersistTimeline).toHaveBeenCalled(); expect(mockPersistTimeline.mock.calls[0][3]).toEqual({ @@ -105,7 +105,7 @@ describe('get draft timelines', () => { }); const response = await server.inject( - getDraftTimelinesRequest(TimelineType.default), + getDraftTimelinesRequest(TimelineTypeEnum.default), requestContextMock.convertContext(context) ); expect(mockPersistTimeline).not.toHaveBeenCalled(); diff --git a/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/import_timelines/helpers.ts b/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/import_timelines/helpers.ts index 0858df47ac360..6f7767247396d 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/import_timelines/helpers.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/import_timelines/helpers.ts @@ -12,7 +12,10 @@ import { createPromiseFromStreams } from '@kbn/utils'; import { validate } from '@kbn/securitysolution-io-ts-utils'; import type { ImportTimelineResultSchema } from '../../../../../../common/api/timeline'; -import { importTimelineResultSchema, TimelineStatus } from '../../../../../../common/api/timeline'; +import { + importTimelineResultSchema, + TimelineStatusEnum, +} from '../../../../../../common/api/timeline'; import type { BulkError } from '../../../../detection_engine/routes/utils'; import { createBulkErrorObject } from '../../../../detection_engine/routes/utils'; @@ -70,9 +73,9 @@ export const setTimeline = ( return { ...parsedTimelineObject, status: - parsedTimeline.status === TimelineStatus.draft - ? TimelineStatus.active - : parsedTimeline.status ?? TimelineStatus.active, + parsedTimeline.status === TimelineStatusEnum.draft + ? TimelineStatusEnum.active + : parsedTimeline.status ?? TimelineStatusEnum.active, templateTimelineVersion: isTemplateTimeline ? parsedTimeline.templateTimelineVersion ?? 1 : null, diff --git a/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/import_timelines/index.test.ts b/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/import_timelines/index.test.ts index 9f66040d8704b..3415df46e9ac4 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/import_timelines/index.test.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/import_timelines/index.test.ts @@ -13,7 +13,7 @@ import { createMockConfig, } from '../../../../detection_engine/routes/__mocks__'; import { TIMELINE_EXPORT_URL } from '../../../../../../common/constants'; -import { TimelineStatus, TimelineType } from '../../../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../../../common/api/timeline'; import type { SecurityPluginSetup } from '@kbn/security-plugin/server'; import { @@ -184,7 +184,7 @@ describe('import timelines', () => { await server.inject(mockRequest, requestContextMock.convertContext(context)); expect(mockPersistTimeline.mock.calls[0][3]).toEqual({ ...mockParsedTimelineObject, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, templateTimelineId: null, templateTimelineVersion: null, }); @@ -429,7 +429,7 @@ describe('import timelines', () => { [ { ...mockGetTimelineValue, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }, ], ]); @@ -630,7 +630,7 @@ describe('import timeline templates', () => { await server.inject(mockRequest, requestContextMock.convertContext(context)); expect(mockPersistTimeline.mock.calls[0][3]).toEqual({ ...mockParsedTemplateTimelineObject, - status: TimelineStatus.active, + status: TimelineStatusEnum.active, }); }); @@ -851,7 +851,7 @@ describe('import timeline templates', () => { [ { ...mockUniqueParsedTemplateTimelineObjects[0], - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }, ], ]); diff --git a/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/persist_favorite/index.ts b/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/persist_favorite/index.ts index 3b220ccf57e20..f53acf25803a8 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/persist_favorite/index.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/routes/timelines/persist_favorite/index.ts @@ -17,7 +17,7 @@ import { buildSiemResponse } from '../../../../detection_engine/routes/utils'; import { buildFrameworkRequest } from '../../../utils/common'; import { persistFavorite } from '../../../saved_object/timelines'; -import { TimelineType, persistFavoriteSchema } from '../../../../../../common/api/timeline'; +import { TimelineTypeEnum, persistFavoriteSchema } from '../../../../../../common/api/timeline'; export const persistFavoriteRoute = (router: SecuritySolutionPluginRouter, _: ConfigType) => { router.versioned @@ -48,7 +48,7 @@ export const persistFavoriteRoute = (router: SecuritySolutionPluginRouter, _: Co timelineId || null, templateTimelineId || null, templateTimelineVersion || null, - timelineType || TimelineType.default + timelineType || TimelineTypeEnum.default ); return response.ok({ diff --git a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/convert_saved_object_to_savedtimeline.ts b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/convert_saved_object_to_savedtimeline.ts index 60d2e1cdca502..2cde936f1c462 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/convert_saved_object_to_savedtimeline.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/convert_saved_object_to_savedtimeline.ts @@ -17,7 +17,12 @@ import { SavedObjectTimelineStatus, } from '../../../../../common/types/timeline/saved_object'; import type { TimelineSavedObject } from '../../../../../common/api/timeline'; -import { TimelineType, TimelineStatus } from '../../../../../common/api/timeline'; +import { + type TimelineType, + TimelineTypeEnum, + type TimelineStatus, + TimelineStatusEnum, +} from '../../../../../common/api/timeline'; // TODO: Added to support legacy TimelineType.draft, can be removed in 7.10 const TimelineSavedObjectWithDraftRuntime = intersection([ @@ -100,10 +105,10 @@ function savedObjectTimelineTypeToAPITimelineType( ): TimelineType { switch (timelineType) { case SavedObjectTimelineType.template: - return TimelineType.template; + return TimelineTypeEnum.template; case 'draft': default: - return TimelineType.default; + return TimelineTypeEnum.default; } } @@ -113,15 +118,15 @@ function savedObjectTimelineStatusToAPITimelineStatus( ): TimelineStatus { // TODO: Added to support legacy TimelineType.draft, can be removed in 7.10 if (timelineType === 'draft') { - return TimelineStatus.draft; + return TimelineStatusEnum.draft; } switch (status) { case SavedObjectTimelineStatus.draft: - return TimelineStatus.draft; + return TimelineStatusEnum.draft; case SavedObjectTimelineStatus.immutable: - return TimelineStatus.immutable; + return TimelineStatusEnum.immutable; case SavedObjectTimelineStatus.active: default: - return TimelineStatus.active; + return TimelineStatusEnum.active; } } diff --git a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/index.test.ts b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/index.test.ts index f8ce73092a804..20049a63bddba 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/index.test.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/index.test.ts @@ -21,7 +21,7 @@ import { import { convertSavedObjectToSavedTimeline } from './convert_saved_object_to_savedtimeline'; import { getNotesByTimelineId, persistNote } from '../notes/saved_object'; import { getAllPinnedEventsByTimelineId, persistPinnedEventOnTimeline } from '../pinned_events'; -import { TimelineType } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum } from '../../../../../common/api/timeline'; import type { AllTimelinesResponse, ResolvedTimelineWithOutcomeSavedObject, @@ -455,7 +455,7 @@ describe('saved_object', () => { }); test('should get draft filtered by current user', async () => { - await getDraftTimeline(mockRequest, TimelineType.default); + await getDraftTimeline(mockRequest, TimelineTypeEnum.default); expect(mockFindSavedObject).toBeCalledWith({ filter: 'not siem-ui-timeline.attributes.timelineType: template and siem-ui-timeline.attributes.status: draft and not siem-ui-timeline.attributes.status: immutable and siem-ui-timeline.attributes.updatedBy: "username" and siem-ui-timeline.attributes.createdBy: "username"', diff --git a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/index.ts b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/index.ts index d9b770c258319..71d61c22ab33c 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/index.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/index.ts @@ -27,14 +27,14 @@ import type { ResponseTimeline, SortTimeline, TimelineResult, - TimelineTypeLiteralWithNull, - TimelineStatusLiteralWithNull, + TimelineType, + TimelineStatus, ResolvedTimelineWithOutcomeSavedObject, TimelineSavedObject, SavedTimeline, TimelineWithoutExternalRefs, } from '../../../../../common/api/timeline'; -import { TimelineStatus, TimelineType } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../../common/api/timeline'; import type { SavedObjectTimelineWithoutExternalRefs } from '../../../../../common/types/timeline/saved_object'; import type { FrameworkRequest } from '../../../framework'; import * as note from '../notes/saved_object'; @@ -52,11 +52,11 @@ export { convertSavedObjectToSavedTimeline } from './convert_saved_object_to_sav export const getTimeline = async ( request: FrameworkRequest, timelineId: string, - timelineType: TimelineTypeLiteralWithNull = TimelineType.default + timelineType: TimelineType | null = TimelineTypeEnum.default ): Promise => { let timelineIdToUse = timelineId; try { - if (timelineType === TimelineType.template) { + if (timelineType === TimelineTypeEnum.template) { const options = { type: timelineSavedObjectType, perPage: 1, @@ -130,33 +130,33 @@ export const getTimelineTemplateOrNull = async ( /** The filter here is able to handle the legacy data, * which has no timelineType exists in the savedObject */ const getTimelineTypeFilter = ( - timelineType: TimelineTypeLiteralWithNull, - status: TimelineStatusLiteralWithNull + timelineType: TimelineType | null, + status: TimelineStatus | null ) => { const typeFilter = timelineType == null ? null - : timelineType === TimelineType.template - ? `siem-ui-timeline.attributes.timelineType: ${TimelineType.template}` /** Show only whose timelineType exists and equals to "template" */ + : timelineType === TimelineTypeEnum.template + ? `siem-ui-timeline.attributes.timelineType: ${TimelineTypeEnum.template}` /** Show only whose timelineType exists and equals to "template" */ : /** Show me every timeline whose timelineType is not "template". * which includes timelineType === 'default' and * those timelineType doesn't exists */ - `not siem-ui-timeline.attributes.timelineType: ${TimelineType.template}`; + `not siem-ui-timeline.attributes.timelineType: ${TimelineTypeEnum.template}`; /** Show me every timeline whose status is not "draft". * which includes status === 'active' and * those status doesn't exists */ const draftFilter = - status === TimelineStatus.draft - ? `siem-ui-timeline.attributes.status: ${TimelineStatus.draft}` - : `not siem-ui-timeline.attributes.status: ${TimelineStatus.draft}`; + status === TimelineStatusEnum.draft + ? `siem-ui-timeline.attributes.status: ${TimelineStatusEnum.draft}` + : `not siem-ui-timeline.attributes.status: ${TimelineStatusEnum.draft}`; const immutableFilter = status == null ? null - : status === TimelineStatus.immutable - ? `siem-ui-timeline.attributes.status: ${TimelineStatus.immutable}` - : `not siem-ui-timeline.attributes.status: ${TimelineStatus.immutable}`; + : status === TimelineStatusEnum.immutable + ? `siem-ui-timeline.attributes.status: ${TimelineStatusEnum.immutable}` + : `not siem-ui-timeline.attributes.status: ${TimelineStatusEnum.immutable}`; const filters = [typeFilter, draftFilter, immutableFilter]; return combineFilters(filters); @@ -204,7 +204,7 @@ export const getExistingPrepackagedTimelines = async ( const elasticTemplateTimelineOptions = { type: timelineSavedObjectType, ...queryPageInfo, - filter: getTimelineTypeFilter(TimelineType.template, TimelineStatus.immutable), + filter: getTimelineTypeFilter(TimelineTypeEnum.template, TimelineStatusEnum.immutable), }; return getAllSavedTimeline(request, elasticTemplateTimelineOptions); @@ -216,8 +216,8 @@ export const getAllTimeline = async ( pageInfo: PageInfoTimeline, search: string | null, sort: SortTimeline | null, - status: TimelineStatusLiteralWithNull, - timelineType: TimelineTypeLiteralWithNull + status: TimelineStatus | null, + timelineType: TimelineType | null ): Promise => { const searchTerm = search != null ? search : undefined; const searchFields = ['title', 'description']; @@ -240,21 +240,21 @@ export const getAllTimeline = async ( type: timelineSavedObjectType, perPage: 1, page: 1, - filter: getTimelineTypeFilter(TimelineType.default, TimelineStatus.active), + filter: getTimelineTypeFilter(TimelineTypeEnum.default, TimelineStatusEnum.active), }; const templateTimelineOptions = { type: timelineSavedObjectType, perPage: 1, page: 1, - filter: getTimelineTypeFilter(TimelineType.template, null), + filter: getTimelineTypeFilter(TimelineTypeEnum.template, null), }; const customTemplateTimelineOptions = { type: timelineSavedObjectType, perPage: 1, page: 1, - filter: getTimelineTypeFilter(TimelineType.template, TimelineStatus.active), + filter: getTimelineTypeFilter(TimelineTypeEnum.template, TimelineStatusEnum.active), }; const favoriteTimelineOptions = { @@ -264,7 +264,7 @@ export const getAllTimeline = async ( perPage: 1, page: 1, filter: combineFilters([ - getTimelineTypeFilter(timelineType ?? null, TimelineStatus.active), + getTimelineTypeFilter(timelineType ?? null, TimelineStatusEnum.active), getTimelineFavoriteFilter({ onlyUserFavorite: true, request }), ]), }; @@ -290,10 +290,10 @@ export const getAllTimeline = async ( export const getDraftTimeline = async ( request: FrameworkRequest, - timelineType: TimelineTypeLiteralWithNull + timelineType: TimelineType | null ): Promise => { const filter = combineFilters([ - getTimelineTypeFilter(timelineType ?? null, TimelineStatus.draft), + getTimelineTypeFilter(timelineType ?? null, TimelineStatusEnum.draft), getTimelinesCreatedAndUpdatedByCurrentUser({ request }), ]); const options: SavedObjectsFindOptions = { @@ -597,7 +597,7 @@ export const copyTimeline = async ( pinnedEvent.getAllPinnedEventsByTimelineId(request, timelineId), ]); - const isImmutable = timeline.status === TimelineStatus.immutable; + const isImmutable = timeline.status === TimelineStatusEnum.immutable; const userInfo = isImmutable ? ({ username: 'Elastic' } as AuthenticatedUser) : request.user; const timelineResponse = await createTimeline({ @@ -773,7 +773,7 @@ export const getSelectedTimelines = async ( }, null, null, - TimelineStatus.active, + TimelineStatusEnum.active, null ); exportedIds = savedAllTimelines.map((t) => t.savedObjectId); diff --git a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/pick_saved_timeline.test.ts b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/pick_saved_timeline.test.ts index db32de9dc65ce..e14c49bf5dbee 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/pick_saved_timeline.test.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/pick_saved_timeline.test.ts @@ -8,7 +8,7 @@ import type { AuthenticatedUser } from '@kbn/security-plugin/common'; import type { SavedTimeline, Note } from '../../../../../common/api/timeline'; -import { TimelineStatus, TimelineType } from '../../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../../common/api/timeline'; import { pickSavedTimeline } from './pick_saved_timeline'; @@ -55,7 +55,7 @@ describe('pickSavedTimeline', () => { sort: { sortDirection: 'desc', columnType: 'number', columnId: '@timestamp' }, title: 'title', kqlMode: 'filter', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, savedQueryId: null, kqlQuery: { filterQuery: null }, dataProviders: [], @@ -185,7 +185,7 @@ describe('pickSavedTimeline', () => { const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.active); + expect(result.status).toEqual(TimelineStatusEnum.active); }); test('Creating a timeline without title', () => { @@ -194,7 +194,7 @@ describe('pickSavedTimeline', () => { const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.draft); + expect(result.status).toEqual(TimelineStatusEnum.draft); }); test('Updating a timeline with a new title', () => { @@ -203,7 +203,7 @@ describe('pickSavedTimeline', () => { const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.active); + expect(result.status).toEqual(TimelineStatusEnum.active); }); test('Updating a timeline without title', () => { @@ -212,65 +212,65 @@ describe('pickSavedTimeline', () => { const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.active); + expect(result.status).toEqual(TimelineStatusEnum.active); }); test('Updating an immutable timeline with a new title', () => { - const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatus.immutable }; + const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatusEnum.immutable }; const timelineId = savedTimeline.savedObjectId ?? null; const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.immutable); + expect(result.status).toEqual(TimelineStatusEnum.immutable); }); test('Creating a draft timeline with title', () => { - const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatus.draft }; + const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatusEnum.draft }; const timelineId = null; const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.active); + expect(result.status).toEqual(TimelineStatusEnum.active); }); test('Creating a draft timeline without title', () => { const savedTimeline = { ...getMockSavedTimeline(), title: null, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }; const timelineId = null; const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.draft); + expect(result.status).toEqual(TimelineStatusEnum.draft); }); test('Updating an untitled draft timeline with a title', () => { - const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatus.draft }; + const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatusEnum.draft }; const timelineId = savedTimeline.savedObjectId ?? null; const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.active); + expect(result.status).toEqual(TimelineStatusEnum.active); }); test('Updating a draft timeline with a new title', () => { - const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatus.draft }; + const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatusEnum.draft }; const timelineId = savedTimeline.savedObjectId ?? null; const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.active); + expect(result.status).toEqual(TimelineStatusEnum.active); }); test('Updating a draft timeline without title', () => { - const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatus.draft }; + const savedTimeline = { ...getMockSavedTimeline(), status: TimelineStatusEnum.draft }; const timelineId = savedTimeline.savedObjectId ?? null; const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.status).toEqual(TimelineStatus.active); + expect(result.status).toEqual(TimelineStatusEnum.active); }); }); @@ -280,8 +280,8 @@ describe('pickSavedTimeline', () => { const userInfo = { username: 'elastic' } as AuthenticatedUser; const result = pickSavedTimeline(timelineId, savedTimeline, userInfo); - expect(result.timelineType).toEqual(TimelineType.default); - expect(result.status).toEqual(TimelineStatus.active); + expect(result.timelineType).toEqual(TimelineTypeEnum.default); + expect(result.status).toEqual(TimelineStatusEnum.active); expect(result.templateTimelineId).toBeNull(); expect(result.templateTimelineVersion).toBeNull(); }); diff --git a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/pick_saved_timeline.ts b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/pick_saved_timeline.ts index 90467a4568244..50b57bf96bd5b 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/pick_saved_timeline.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/saved_object/timelines/pick_saved_timeline.ts @@ -10,7 +10,7 @@ import type { AuthenticatedUser } from '@kbn/security-plugin/common'; import { getUserDisplayName } from '@kbn/user-profile-components'; import { UNAUTHENTICATED_USER } from '../../../../../common/constants'; import type { SavedTimelineWithSavedObjectId } from '../../../../../common/api/timeline'; -import { TimelineType, TimelineStatus } from '../../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../../common/api/timeline'; export const pickSavedTimeline = ( timelineId: string | null, @@ -29,21 +29,21 @@ export const pickSavedTimeline = ( savedTimeline.updatedBy = userInfo ? getUserDisplayName(userInfo) : UNAUTHENTICATED_USER; } - if (savedTimeline.status === TimelineStatus.draft || savedTimeline.status == null) { + if (savedTimeline.status === TimelineStatusEnum.draft || savedTimeline.status == null) { savedTimeline.status = !isEmpty(savedTimeline.title) - ? TimelineStatus.active - : TimelineStatus.draft; + ? TimelineStatusEnum.active + : TimelineStatusEnum.draft; } - if (savedTimeline.timelineType === TimelineType.default) { - savedTimeline.timelineType = savedTimeline.timelineType ?? TimelineType.default; - savedTimeline.status = savedTimeline.status ?? TimelineStatus.active; + if (savedTimeline.timelineType === TimelineTypeEnum.default) { + savedTimeline.timelineType = savedTimeline.timelineType ?? TimelineTypeEnum.default; + savedTimeline.status = savedTimeline.status ?? TimelineStatusEnum.active; savedTimeline.templateTimelineId = null; savedTimeline.templateTimelineVersion = null; } - if (!isEmpty(savedTimeline.title) && savedTimeline.status === TimelineStatus.draft) { - savedTimeline.status = TimelineStatus.active; + if (!isEmpty(savedTimeline.title) && savedTimeline.status === TimelineStatusEnum.draft) { + savedTimeline.status = TimelineStatusEnum.active; } savedTimeline.excludedRowRendererIds = savedTimeline.excludedRowRendererIds ?? []; diff --git a/x-pack/plugins/security_solution/server/lib/timeline/utils/compare_timelines_status.test.ts b/x-pack/plugins/security_solution/server/lib/timeline/utils/compare_timelines_status.test.ts index 2cff9c903c734..89cd06342c0df 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/utils/compare_timelines_status.test.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/utils/compare_timelines_status.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../common/api/timeline'; import type { FrameworkRequest } from '../../framework'; import { @@ -62,7 +62,7 @@ describe('CompareTimelinesStatus', () => { id: mockUniqueParsedObjects[0].savedObjectId, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, title: mockUniqueParsedObjects[0].title, templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, @@ -137,7 +137,7 @@ describe('CompareTimelinesStatus', () => { id: mockUniqueParsedObjects[0].savedObjectId, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, title: mockUniqueParsedObjects[0].title, templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, @@ -203,7 +203,7 @@ describe('CompareTimelinesStatus', () => { id: mockUniqueParsedObjects[0].savedObjectId, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, title: mockUniqueParsedObjects[0].title, templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, @@ -288,7 +288,7 @@ describe('CompareTimelinesStatus', () => { id: mockUniqueParsedObjects[0].savedObjectId, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, title: mockUniqueParsedObjects[0].title, templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, @@ -380,14 +380,14 @@ describe('CompareTimelinesStatus', () => { timelineObj = new CompareTimelinesStatus({ timelineInput: { id: mockUniqueParsedObjects[0].savedObjectId, - type: TimelineType.default, + type: TimelineTypeEnum.default, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, title: null, templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, - type: TimelineType.template, + type: TimelineTypeEnum.template, version: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineVersion, }, frameworkRequest: {} as FrameworkRequest, @@ -460,14 +460,14 @@ describe('CompareTimelinesStatus', () => { timelineObj = new CompareTimelinesStatus({ timelineInput: { id: mockUniqueParsedObjects[0].savedObjectId, - type: TimelineType.default, + type: TimelineTypeEnum.default, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, title: null, templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, - type: TimelineType.template, + type: TimelineTypeEnum.template, version: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineVersion, }, frameworkRequest: {} as FrameworkRequest, @@ -537,7 +537,7 @@ describe('CompareTimelinesStatus', () => { return { getTimelineOrNull: mockGetTimeline.mockReturnValue({ ...mockGetTimelineValue, - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }), getTimelineTemplateOrNull: mockGetTemplateTimeline.mockReturnValue(null), }; @@ -550,15 +550,15 @@ describe('CompareTimelinesStatus', () => { timelineObj = new CompareTimelinesStatus({ timelineInput: { id: mockUniqueParsedObjects[0].savedObjectId, - type: TimelineType.default, + type: TimelineTypeEnum.default, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, title: 'mock title', - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, - type: TimelineType.template, + type: TimelineTypeEnum.template, version: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineVersion, }, frameworkRequest: {} as FrameworkRequest, @@ -610,11 +610,11 @@ describe('CompareTimelinesStatus', () => { return { getTimelineOrNull: mockGetTimeline.mockReturnValue({ ...mockGetTemplateTimelineValue, - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }), getTimelineTemplateOrNull: mockGetTemplateTimeline.mockReturnValue({ ...mockGetTemplateTimelineValue, - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }), }; }); @@ -626,15 +626,15 @@ describe('CompareTimelinesStatus', () => { timelineObj = new CompareTimelinesStatus({ timelineInput: { id: mockUniqueParsedObjects[0].savedObjectId, - type: TimelineType.default, + type: TimelineTypeEnum.default, version: mockUniqueParsedObjects[0].version, }, - status: TimelineStatus.immutable, - timelineType: TimelineType.template, + status: TimelineStatusEnum.immutable, + timelineType: TimelineTypeEnum.template, title: 'mock title', templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, - type: TimelineType.template, + type: TimelineTypeEnum.template, version: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineVersion, }, frameworkRequest: {} as FrameworkRequest, @@ -696,7 +696,7 @@ describe('CompareTimelinesStatus', () => { id: mockUniqueParsedObjects[0].savedObjectId, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, title: mockUniqueParsedObjects[0].title, templateTimelineInput: { id: null, @@ -761,7 +761,7 @@ describe('CompareTimelinesStatus', () => { id: mockUniqueParsedObjects[0].savedObjectId, version: mockUniqueParsedObjects[0].version, }, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, title: mockUniqueParsedObjects[0].title, templateTimelineInput: { id: mockUniqueParsedTemplateTimelineObjects[0].templateTimelineId, diff --git a/x-pack/plugins/security_solution/server/lib/timeline/utils/compare_timelines_status.ts b/x-pack/plugins/security_solution/server/lib/timeline/utils/compare_timelines_status.ts index 7c41cfa9c5449..3892fc067f9bd 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/utils/compare_timelines_status.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/utils/compare_timelines_status.ts @@ -6,11 +6,12 @@ */ import { isEmpty, isInteger } from 'lodash/fp'; -import type { - TimelineTypeLiteralWithNull, - TimelineTypeLiteral, +import { + type TimelineType, + TimelineTypeEnum, + type TimelineStatus, + TimelineStatusEnum, } from '../../../../common/api/timeline'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; import type { FrameworkRequest } from '../../framework'; import type { TimelineStatusAction } from './common'; @@ -26,14 +27,14 @@ import { interface GivenTimelineInput { id: string | null | undefined; - type?: TimelineTypeLiteralWithNull; + type?: TimelineType | null; version: string | number | null | undefined; } interface TimelinesStatusProps { status: TimelineStatus | null | undefined; title: string | null | undefined; - timelineType: TimelineTypeLiteralWithNull | undefined; + timelineType: TimelineType | null | undefined; timelineInput: GivenTimelineInput; templateTimelineInput: GivenTimelineInput; frameworkRequest: FrameworkRequest; @@ -42,33 +43,33 @@ interface TimelinesStatusProps { export class CompareTimelinesStatus { public readonly timelineObject: TimelineObject; public readonly templateTimelineObject: TimelineObject; - private readonly timelineType: TimelineTypeLiteral; + private readonly timelineType: TimelineType; private readonly title: string | null; private readonly status: TimelineStatus; constructor({ - status = TimelineStatus.active, + status = TimelineStatusEnum.active, title, - timelineType = TimelineType.default, + timelineType = TimelineTypeEnum.default, timelineInput, templateTimelineInput, frameworkRequest, }: TimelinesStatusProps) { this.timelineObject = new TimelineObject({ id: timelineInput.id, - type: timelineInput.type ?? TimelineType.default, + type: timelineInput.type ?? TimelineTypeEnum.default, version: timelineInput.version, frameworkRequest, }); this.templateTimelineObject = new TimelineObject({ id: templateTimelineInput.id, - type: templateTimelineInput.type ?? TimelineType.template, + type: templateTimelineInput.type ?? TimelineTypeEnum.template, version: templateTimelineInput.version, frameworkRequest, }); - this.timelineType = timelineType ?? TimelineType.default; + this.timelineType = timelineType ?? TimelineTypeEnum.default; this.title = title ?? null; - this.status = status ?? TimelineStatus.active; + this.status = status ?? TimelineStatusEnum.active; } public get isCreatable() { @@ -109,8 +110,8 @@ export class CompareTimelinesStatus { const obj = this.isHandlingTemplateTimeline ? this.templateTimelineObject : this.timelineObject; return obj.isExists - ? this.status === obj.getData?.status && this.status !== TimelineStatus.draft - : this.status !== TimelineStatus.draft; + ? this.status === obj.getData?.status && this.status !== TimelineStatusEnum.draft + : this.status !== TimelineStatusEnum.draft; } public get isUpdatable() { @@ -124,7 +125,7 @@ export class CompareTimelinesStatus { private get isTimelineTypeValid() { const obj = this.isHandlingTemplateTimeline ? this.templateTimelineObject : this.timelineObject; - const existintTimelineType = obj.getData?.timelineType ?? TimelineType.default; + const existintTimelineType = obj.getData?.timelineType ?? TimelineTypeEnum.default; return obj.isExists ? this.timelineType === existintTimelineType : true; } @@ -142,8 +143,8 @@ export class CompareTimelinesStatus { public get isTitleValid() { return ( - (this.status !== TimelineStatus.draft && !isEmpty(this.title)) || - this.status === TimelineStatus.draft + (this.status !== TimelineStatusEnum.draft && !isEmpty(this.title)) || + this.status === TimelineStatusEnum.draft ); } @@ -196,7 +197,7 @@ export class CompareTimelinesStatus { } public get isHandlingTemplateTimeline() { - return this.timelineType === TimelineType.template; + return this.timelineType === TimelineTypeEnum.template; } private get isSavedObjectVersionConflict() { @@ -242,8 +243,8 @@ export class CompareTimelinesStatus { ? this.templateTimelineInput.data?.status : this.timelineInput.data?.status; return ( - ((existingStatus == null || existingStatus === TimelineStatus.active) && - (status == null || status === TimelineStatus.active)) || + ((existingStatus == null || existingStatus === TimelineStatusEnum.active) && + (status == null || status === TimelineStatusEnum.active)) || (existingStatus != null && status === existingStatus) ); } diff --git a/x-pack/plugins/security_solution/server/lib/timeline/utils/default_timeline.ts b/x-pack/plugins/security_solution/server/lib/timeline/utils/default_timeline.ts index 3624458c9e7fd..33c2af9d4e39c 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/utils/default_timeline.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/utils/default_timeline.ts @@ -7,7 +7,7 @@ import { defaultHeaders } from './default_timeline_headers'; import type { SavedTimeline } from '../../../../common/api/timeline'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import { TimelineTypeEnum, TimelineStatusEnum } from '../../../../common/api/timeline'; import { Direction } from '../../../../common/search_strategy'; export const draftTimelineDefaults: SavedTimeline = { @@ -17,7 +17,7 @@ export const draftTimelineDefaults: SavedTimeline = { eventType: 'all', filters: [], kqlMode: 'filter', - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, kqlQuery: { filterQuery: null, }, @@ -26,5 +26,5 @@ export const draftTimelineDefaults: SavedTimeline = { columnId: '@timestamp', sortDirection: Direction.desc, }, - status: TimelineStatus.draft, + status: TimelineStatusEnum.draft, }; diff --git a/x-pack/plugins/security_solution/server/lib/timeline/utils/failure_cases.test.ts b/x-pack/plugins/security_solution/server/lib/timeline/utils/failure_cases.test.ts index de4a0bd8ca678..e5e247c1209fe 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/utils/failure_cases.test.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/utils/failure_cases.test.ts @@ -27,19 +27,19 @@ import { TEMPLATE_TIMELINE_VERSION_CONFLICT_MESSAGE, } from './failure_cases'; import type { TimelineSavedObject } from '../../../../common/api/timeline'; -import { TimelineStatus, TimelineType } from '../../../../common/api/timeline'; +import { TimelineStatusEnum, TimelineTypeEnum } from '../../../../common/api/timeline'; import { mockGetTimelineValue, mockGetTemplateTimelineValue } from '../__mocks__/import_timelines'; describe('failure cases', () => { describe('commonFailureChecker', () => { test('If timeline type is draft, it should not return error if title is not given', () => { - const result = commonFailureChecker(TimelineStatus.draft, null); + const result = commonFailureChecker(TimelineStatusEnum.draft, null); expect(result).toBeNull(); }); test('If timeline type is active, it should return error if title is not given', () => { - const result = commonFailureChecker(TimelineStatus.active, null); + const result = commonFailureChecker(TimelineStatusEnum.active, null); expect(result).toEqual({ body: EMPTY_TITLE_ERROR_MESSAGE, @@ -48,7 +48,7 @@ describe('failure cases', () => { }); test('If timeline type is immutable, it should return error if title is not given', () => { - const result = commonFailureChecker(TimelineStatus.immutable, null); + const result = commonFailureChecker(TimelineStatusEnum.immutable, null); expect(result).toEqual({ body: EMPTY_TITLE_ERROR_MESSAGE, @@ -57,7 +57,7 @@ describe('failure cases', () => { }); test('If timeline type is not a draft, it should return no error if title is given', () => { - const result = commonFailureChecker(TimelineStatus.active, 'title'); + const result = commonFailureChecker(TimelineStatusEnum.active, 'title'); expect(result).toBeNull(); }); @@ -73,8 +73,8 @@ describe('failure cases', () => { const existTemplateTimeline = null; const result = checkIsCreateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.default, + TimelineStatusEnum.active, + TimelineTypeEnum.default, version, templateTimelineVersion, templateTimelineId, @@ -97,8 +97,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsCreateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -121,8 +121,8 @@ describe('failure cases', () => { const existTemplateTimeline = null; const result = checkIsCreateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -145,13 +145,13 @@ describe('failure cases', () => { const templateTimelineId = null; const existTimeline = { ...(mockGetTimelineValue as TimelineSavedObject), - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }; const existTemplateTimeline = null; const result = checkIsUpdateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.default, + TimelineStatusEnum.active, + TimelineTypeEnum.default, version, templateTimelineVersion, templateTimelineId, @@ -173,12 +173,12 @@ describe('failure cases', () => { const existTimeline = null; const existTemplateTimeline = { ...(mockGetTemplateTimelineValue as TimelineSavedObject), - status: TimelineStatus.immutable, + status: TimelineStatusEnum.immutable, }; const result = checkIsUpdateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -201,8 +201,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsUpdateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.default, + TimelineStatusEnum.active, + TimelineTypeEnum.default, version, templateTimelineVersion, templateTimelineId, @@ -225,8 +225,8 @@ describe('failure cases', () => { const existTemplateTimeline = null; const result = checkIsUpdateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.default, + TimelineStatusEnum.active, + TimelineTypeEnum.default, version, templateTimelineVersion, templateTimelineId, @@ -252,8 +252,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsUpdateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -276,8 +276,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsUpdateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -303,8 +303,8 @@ describe('failure cases', () => { const existTemplateTimeline = null; const result = checkIsUpdateFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -329,8 +329,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsCreateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.draft, - TimelineType.template, + TimelineStatusEnum.draft, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -353,8 +353,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsCreateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -377,8 +377,8 @@ describe('failure cases', () => { const existTemplateTimeline = null; const result = checkIsCreateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.default, + TimelineStatusEnum.active, + TimelineTypeEnum.default, version, templateTimelineVersion, templateTimelineId, @@ -403,8 +403,8 @@ describe('failure cases', () => { const existTemplateTimeline = null; const result = checkIsUpdateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.default, + TimelineStatusEnum.active, + TimelineTypeEnum.default, version, templateTimelineVersion, templateTimelineId, @@ -427,8 +427,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsUpdateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.default, + TimelineStatusEnum.active, + TimelineTypeEnum.default, version, templateTimelineVersion, templateTimelineId, @@ -451,8 +451,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsUpdateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.immutable, - TimelineType.template, + TimelineStatusEnum.immutable, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -475,8 +475,8 @@ describe('failure cases', () => { const existTemplateTimeline = null; const result = checkIsUpdateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.default, + TimelineStatusEnum.active, + TimelineTypeEnum.default, version, templateTimelineVersion, templateTimelineId, @@ -502,8 +502,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsUpdateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -526,8 +526,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsUpdateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, @@ -550,8 +550,8 @@ describe('failure cases', () => { const existTemplateTimeline = mockGetTemplateTimelineValue as TimelineSavedObject; const result = checkIsUpdateViaImportFailureCases( isHandlingTemplateTimeline, - TimelineStatus.active, - TimelineType.template, + TimelineStatusEnum.active, + TimelineTypeEnum.template, version, templateTimelineVersion, templateTimelineId, diff --git a/x-pack/plugins/security_solution/server/lib/timeline/utils/failure_cases.ts b/x-pack/plugins/security_solution/server/lib/timeline/utils/failure_cases.ts index f71e825e3514c..045793e2251ba 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/utils/failure_cases.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/utils/failure_cases.ts @@ -6,8 +6,8 @@ */ import { isEmpty } from 'lodash/fp'; -import type { TimelineTypeLiteral, TimelineSavedObject } from '../../../../common/api/timeline'; -import { TimelineStatus } from '../../../../common/api/timeline'; +import type { TimelineType, TimelineSavedObject } from '../../../../common/api/timeline'; +import { type TimelineStatus, TimelineStatusEnum } from '../../../../common/api/timeline'; export const UPDATE_TIMELINE_ERROR_MESSAGE = 'You cannot create new timelines with PATCH. Use POST instead.'; @@ -46,11 +46,12 @@ const isUpdatingStatus = ( existTemplateTimeline: TimelineSavedObject | null ) => { const obj = isHandlingTemplateTimeline ? existTemplateTimeline : existTimeline; - return obj?.status === TimelineStatus.immutable ? UPDATE_STATUS_ERROR_MESSAGE : null; + return obj?.status === TimelineStatusEnum.immutable ? UPDATE_STATUS_ERROR_MESSAGE : null; }; const isGivenTitleValid = (status: TimelineStatus, title: string | null | undefined) => { - return (status !== TimelineStatus.draft && !isEmpty(title)) || status === TimelineStatus.draft + return (status !== TimelineStatusEnum.draft && !isEmpty(title)) || + status === TimelineStatusEnum.draft ? null : EMPTY_TITLE_ERROR_MESSAGE; }; @@ -71,7 +72,7 @@ export const commonFailureChecker = (status: TimelineStatus, title: string | nul const commonUpdateTemplateTimelineCheck = ( isHandlingTemplateTimeline: boolean, status: TimelineStatus | null | undefined, - timelineType: TimelineTypeLiteral, + timelineType: TimelineType, version: string | null, templateTimelineVersion: number | null, templateTimelineId: string | null | undefined, @@ -124,7 +125,7 @@ const commonUpdateTemplateTimelineCheck = ( const commonUpdateTimelineCheck = ( isHandlingTemplateTimeline: boolean, status: TimelineStatus | null | undefined, - timelineType: TimelineTypeLiteral, + timelineType: TimelineType, version: string | null, templateTimelineVersion: number | null, templateTimelineId: string | null | undefined, @@ -153,7 +154,7 @@ const commonUpdateTimelineCheck = ( const commonUpdateCases = ( isHandlingTemplateTimeline: boolean, status: TimelineStatus | null | undefined, - timelineType: TimelineTypeLiteral, + timelineType: TimelineType, version: string | null, templateTimelineVersion: number | null, templateTimelineId: string | null | undefined, @@ -188,7 +189,7 @@ const commonUpdateCases = ( const createTemplateTimelineCheck = ( isHandlingTemplateTimeline: boolean, status: TimelineStatus, - timelineType: TimelineTypeLiteral, + timelineType: TimelineType, version: string | null, templateTimelineVersion: number | null, templateTimelineId: string | null | undefined, @@ -214,7 +215,7 @@ const createTemplateTimelineCheck = ( export const checkIsUpdateViaImportFailureCases = ( isHandlingTemplateTimeline: boolean, status: TimelineStatus | null | undefined, - timelineType: TimelineTypeLiteral, + timelineType: TimelineType, version: string | null, templateTimelineVersion: number | null, templateTimelineId: string | null | undefined, @@ -233,8 +234,8 @@ export const checkIsUpdateViaImportFailureCases = ( } else { const isStatusValid = ((existTemplateTimeline?.status == null || - existTemplateTimeline?.status === TimelineStatus.active) && - (status == null || status === TimelineStatus.active)) || + existTemplateTimeline?.status === TimelineStatusEnum.active) && + (status == null || status === TimelineStatusEnum.active)) || (existTemplateTimeline?.status != null && status === existTemplateTimeline?.status); if (!isStatusValid) { @@ -276,7 +277,7 @@ export const checkIsUpdateViaImportFailureCases = ( export const checkIsUpdateFailureCases = ( isHandlingTemplateTimeline: boolean, status: TimelineStatus | null | undefined, - timelineType: TimelineTypeLiteral, + timelineType: TimelineType, version: string | null, templateTimelineVersion: number | null, templateTimelineId: string | null | undefined, @@ -310,7 +311,7 @@ export const checkIsUpdateFailureCases = ( export const checkIsCreateFailureCases = ( isHandlingTemplateTimeline: boolean, status: TimelineStatus, - timelineType: TimelineTypeLiteral, + timelineType: TimelineType, version: string | null, templateTimelineVersion: number | null, templateTimelineId: string | null | undefined, @@ -341,14 +342,14 @@ export const checkIsCreateFailureCases = ( export const checkIsCreateViaImportFailureCases = ( isHandlingTemplateTimeline: boolean, status: TimelineStatus | null | undefined, - timelineType: TimelineTypeLiteral, + timelineType: TimelineType, version: string | null, templateTimelineVersion: number | null, templateTimelineId: string | null | undefined, existTimeline: TimelineSavedObject | null, existTemplateTimeline: TimelineSavedObject | null ) => { - if (status === TimelineStatus.draft) { + if (status === TimelineStatusEnum.draft) { return { body: CREATE_WITH_INVALID_STATUS_ERROR_MESSAGE, statusCode: 405, diff --git a/x-pack/plugins/security_solution/server/lib/timeline/utils/timeline_object.ts b/x-pack/plugins/security_solution/server/lib/timeline/utils/timeline_object.ts index d7e8e240fea1d..360125e450764 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/utils/timeline_object.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/utils/timeline_object.ts @@ -5,21 +5,25 @@ * 2.0. */ -import type { TimelineSavedObject, TimelineTypeLiteral } from '../../../../common/api/timeline'; -import { TimelineType, TimelineStatus } from '../../../../common/api/timeline'; +import type { TimelineSavedObject } from '../../../../common/api/timeline'; +import { + type TimelineType, + TimelineTypeEnum, + TimelineStatusEnum, +} from '../../../../common/api/timeline'; import type { FrameworkRequest } from '../../framework'; import { getTimelineOrNull, getTimelineTemplateOrNull } from '../saved_object/timelines'; interface TimelineObjectProps { id: string | null | undefined; - type: TimelineTypeLiteral; + type: TimelineType; version: string | number | null | undefined; frameworkRequest: FrameworkRequest; } export class TimelineObject { public readonly id: string | null; - private type: TimelineTypeLiteral; + private type: TimelineType; public readonly version: string | number | null; private frameworkRequest: FrameworkRequest; @@ -27,7 +31,7 @@ export class TimelineObject { constructor({ id = null, - type = TimelineType.default, + type = TimelineTypeEnum.default, version = null, frameworkRequest, }: TimelineObjectProps) { @@ -42,7 +46,7 @@ export class TimelineObject { public async getTimeline() { this.data = this.id != null - ? this.type === TimelineType.template + ? this.type === TimelineTypeEnum.template ? await getTimelineTemplateOrNull(this.frameworkRequest, this.id) : await getTimelineOrNull(this.frameworkRequest, this.id) : null; @@ -54,7 +58,7 @@ export class TimelineObject { } private get isImmutable() { - return this.data?.status === TimelineStatus.immutable; + return this.data?.status === TimelineStatusEnum.immutable; } public get isExists() { @@ -70,7 +74,7 @@ export class TimelineObject { } public get isUpdatableViaImport() { - return this.type === TimelineType.template && this.isExists; + return this.type === TimelineTypeEnum.template && this.isExists; } public get getVersion() { diff --git a/x-pack/plugins/timelines/common/types/timeline/data_provider/index.ts b/x-pack/plugins/timelines/common/types/timeline/data_provider/index.ts index d9ef64c0ea1e3..f89a198638e92 100644 --- a/x-pack/plugins/timelines/common/types/timeline/data_provider/index.ts +++ b/x-pack/plugins/timelines/common/types/timeline/data_provider/index.ts @@ -19,11 +19,6 @@ export const IS_ONE_OF_OPERATOR = 'includes'; /** The operator applied to a field */ export type QueryOperator = typeof IS_OPERATOR | typeof EXISTS_OPERATOR | typeof IS_ONE_OF_OPERATOR; -export enum DataProviderType { - default = 'default', - template = 'template', -} - export interface QueryMatch { field: string; displayField?: string; @@ -62,7 +57,7 @@ export interface DataProvider { /** * Returns a DataProviderType */ - type?: DataProviderType.default | DataProviderType.template; + type?: 'default' | 'template'; } export type DataProvidersAnd = Pick>; diff --git a/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/helpers.ts b/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/helpers.ts index 1f1a4bb821082..9f40373976c28 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/helpers.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/helpers.ts @@ -7,7 +7,7 @@ import type SuperTest from 'supertest'; import { v4 as uuidv4 } from 'uuid'; -import { TimelineType } from '@kbn/security-solution-plugin/common/api/timeline'; +import { TimelineTypeEnum } from '@kbn/security-solution-plugin/common/api/timeline'; export const createBasicTimeline = async (supertest: SuperTest.Agent, titleToSaved: string) => await supertest @@ -35,6 +35,6 @@ export const createBasicTimelineTemplate = async ( title: titleToSaved, templateTimelineId: uuidv4(), templateTimelineVersion: 1, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }, }); diff --git a/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/timeline.ts b/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/timeline.ts index 21270c6d36289..6895d79c5aa8e 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/timeline.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/investigation/saved_objects/trial_license_complete_tier/timeline.ts @@ -6,7 +6,10 @@ */ import expect from '@kbn/expect'; -import { TimelineResult, TimelineType } from '@kbn/security-solution-plugin/common/api/timeline'; +import { + TimelineResult, + TimelineTypeEnum, +} from '@kbn/security-solution-plugin/common/api/timeline'; import { FtrProviderContext } from '../../../../../api_integration/ftr_provider_context'; import { createBasicTimeline } from './helpers'; @@ -207,7 +210,7 @@ export default function ({ getService }: FtrProviderContext) { timelineId: savedObjectId, templateTimelineId: null, templateTimelineVersion: null, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); expect(responseToTest.body.data!.persistFavorite.savedObjectId).to.be(savedObjectId); @@ -216,7 +219,7 @@ export default function ({ getService }: FtrProviderContext) { expect(responseToTest.body.data!.persistFavorite.templateTimelineId).to.be.eql(null); expect(responseToTest.body.data!.persistFavorite.templateTimelineVersion).to.be.eql(null); expect(responseToTest.body.data!.persistFavorite.timelineType).to.be.eql( - TimelineType.default + TimelineTypeEnum.default ); }); @@ -235,7 +238,7 @@ export default function ({ getService }: FtrProviderContext) { timelineId: savedObjectId, templateTimelineId: templateTimelineIdFromStore, templateTimelineVersion: templateTimelineVersionFromStore, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }); expect(responseToTest.body.data!.persistFavorite.savedObjectId).to.be(savedObjectId); expect(responseToTest.body.data!.persistFavorite.favorite.length).to.be(1); @@ -247,7 +250,7 @@ export default function ({ getService }: FtrProviderContext) { templateTimelineVersionFromStore ); expect(responseToTest.body.data!.persistFavorite.timelineType).to.be.eql( - TimelineType.template + TimelineTypeEnum.template ); }); @@ -261,7 +264,7 @@ export default function ({ getService }: FtrProviderContext) { timelineId: savedObjectId, templateTimelineId: null, templateTimelineVersion: null, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); const responseToTest = await supertest @@ -271,7 +274,7 @@ export default function ({ getService }: FtrProviderContext) { timelineId: savedObjectId, templateTimelineId: null, templateTimelineVersion: null, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); expect(responseToTest.body.data!.persistFavorite.savedObjectId).to.be(savedObjectId); @@ -280,7 +283,7 @@ export default function ({ getService }: FtrProviderContext) { expect(responseToTest.body.data!.persistFavorite.templateTimelineId).to.be.eql(null); expect(responseToTest.body.data!.persistFavorite.templateTimelineVersion).to.be.eql(null); expect(responseToTest.body.data!.persistFavorite.timelineType).to.be.eql( - TimelineType.default + TimelineTypeEnum.default ); }); @@ -296,7 +299,7 @@ export default function ({ getService }: FtrProviderContext) { timelineId: savedObjectId, templateTimelineId: templateTimelineIdFromStore, templateTimelineVersion: templateTimelineVersionFromStore, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }); const responseToTest = await supertest @@ -306,7 +309,7 @@ export default function ({ getService }: FtrProviderContext) { timelineId: savedObjectId, templateTimelineId: templateTimelineIdFromStore, templateTimelineVersion: templateTimelineVersionFromStore, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }); expect(responseToTest.body.data!.persistFavorite.savedObjectId).to.be(savedObjectId); @@ -319,7 +322,7 @@ export default function ({ getService }: FtrProviderContext) { templateTimelineVersionFromStore ); expect(responseToTest.body.data!.persistFavorite.timelineType).to.be.eql( - TimelineType.template + TimelineTypeEnum.template ); }); @@ -331,7 +334,7 @@ export default function ({ getService }: FtrProviderContext) { timelineId: null, templateTimelineId: null, templateTimelineVersion: null, - timelineType: TimelineType.default, + timelineType: TimelineTypeEnum.default, }); expect(response.body.data!.persistFavorite.savedObjectId).to.not.be.empty(); @@ -339,7 +342,9 @@ export default function ({ getService }: FtrProviderContext) { expect(response.body.data!.persistFavorite.version).to.not.be.empty(); expect(response.body.data!.persistFavorite.templateTimelineId).to.be.eql(null); expect(response.body.data!.persistFavorite.templateTimelineVersion).to.be.eql(null); - expect(response.body.data!.persistFavorite.timelineType).to.be.eql(TimelineType.default); + expect(response.body.data!.persistFavorite.timelineType).to.be.eql( + TimelineTypeEnum.default + ); }); it('to a timeline template without a timelineId', async () => { @@ -353,7 +358,7 @@ export default function ({ getService }: FtrProviderContext) { timelineId: null, templateTimelineId: templateTimelineIdFromStore, templateTimelineVersion: templateTimelineVersionFromStore, - timelineType: TimelineType.template, + timelineType: TimelineTypeEnum.template, }); expect(response.body.data!.persistFavorite.savedObjectId).to.not.be.empty(); @@ -365,7 +370,9 @@ export default function ({ getService }: FtrProviderContext) { expect(response.body.data!.persistFavorite.templateTimelineVersion).to.be.eql( templateTimelineVersionFromStore ); - expect(response.body.data!.persistFavorite.timelineType).to.be.eql(TimelineType.template); + expect(response.body.data!.persistFavorite.timelineType).to.be.eql( + TimelineTypeEnum.template + ); }); }); diff --git a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/ess/timeline.ts b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/ess/timeline.ts index 80eefe0b5f6b5..8a37ad6e9cac9 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/ess/timeline.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/ess/timeline.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { SavedTimeline, TimelineType } from '@kbn/security-solution-plugin/common/api/timeline'; +import { SavedTimeline, TimelineTypeEnum } from '@kbn/security-solution-plugin/common/api/timeline'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; import { @@ -55,7 +55,9 @@ export default function ({ getService }: FtrProviderContextWithSpaces) { const templates: SavedTimeline[] = resp.body.timeline; expect(templates.length).to.greaterThan(0); - expect(templates.filter((t) => t.timelineType === TimelineType.default).length).to.equal(0); + expect( + templates.filter((t) => t.timelineType === TimelineTypeEnum.default).length + ).to.equal(0); }); }); describe('resolve timeline', () => {