Skip to content

Commit 8e9fa4a

Browse files
[SecuritySolution] Fix behavior of pinnend events and comments on unsaved timelines (#178212)
> This PR is the implementation of the results in the discussion around [[ADR] 0001 - Saving of timeline-associated saved objects](#179830) ## Summary As described in #178182, the removal of autosave on timeline resulted in a regression in which pinned events and comments on unsaved timelines are lost. In this PR, we're re-introducing the previous behavior by saving the timeline when a comment is made / an event is pinned on an unsaved timeline. The timeline will then be auto-saved in a `draft` state instead of an `active` state that would persist it permanently. Fixes #178182 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent d6a942b commit 8e9fa4a

29 files changed

Lines changed: 623 additions & 360 deletions

File tree

x-pack/plugins/security_solution/common/api/timeline/model/api.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { ErrorSchema } from './error_schema';
2525

2626
export const BareNoteSchema = runtimeTypes.intersection([
2727
runtimeTypes.type({
28-
timelineId: unionWithNullType(runtimeTypes.string),
28+
timelineId: runtimeTypes.string,
2929
}),
3030
runtimeTypes.partial({
3131
eventId: unionWithNullType(runtimeTypes.string),
@@ -51,9 +51,6 @@ export const NoteRuntimeType = runtimeTypes.intersection([
5151
noteId: runtimeTypes.string,
5252
version: runtimeTypes.string,
5353
}),
54-
runtimeTypes.partial({
55-
timelineVersion: unionWithNullType(runtimeTypes.string),
56-
}),
5754
]);
5855

5956
export type Note = runtimeTypes.TypeOf<typeof NoteRuntimeType>;

x-pack/plugins/security_solution/common/api/timeline/model/components.yaml

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ components:
1818
type: object
1919
properties:
2020
columns:
21-
$ref: '#/components/schemas/ColumnHeaderResult'
21+
$ref: '#/components/schemas/ColumnHeaderResult'
2222
created:
2323
type: number
2424
createdBy:
@@ -244,19 +244,13 @@ components:
244244
type: string
245245
version:
246246
type: string
247-
timelineVersion:
248-
nullable: true
249-
type: string
250247
GlobalNote:
251248
type: object
252249
properties:
253250
noteId:
254251
type: string
255252
version:
256253
type: string
257-
timelineVersion:
258-
nullable: true
259-
type: string
260254
note:
261255
type: string
262256
timelineId:
@@ -278,8 +272,6 @@ components:
278272
type: string
279273
version:
280274
type: string
281-
timelineVersion:
282-
type: string
283275
RowRendererId:
284276
type: string
285277
enum:
@@ -384,8 +376,6 @@ components:
384376
type: string
385377
version:
386378
type: string
387-
timelineVersion:
388-
type: string
389379
Sort:
390380
type: object
391381
properties:
@@ -415,30 +405,30 @@ components:
415405
description: The status of the timeline. Valid values are `active`, `draft`, and `immutable`.
416406
ImportTimelines:
417407
allOf:
418-
- $ref: '#/components/schemas/SavedTimeline'
419-
- type: object
420-
properties:
421-
savedObjectId:
422-
type: string
423-
nullable: true
424-
version:
408+
- $ref: '#/components/schemas/SavedTimeline'
409+
- type: object
410+
properties:
411+
savedObjectId:
412+
type: string
413+
nullable: true
414+
version:
415+
type: string
416+
nullable: true
417+
globalNotes:
418+
nullable: true
419+
type: array
420+
items:
421+
$ref: '#/components/schemas/BareNote'
422+
eventNotes:
423+
nullable: true
424+
type: array
425+
items:
426+
$ref: '#/components/schemas/BareNote'
427+
pinnedEventIds:
428+
nullable: true
429+
type: array
430+
items:
425431
type: string
426-
nullable: true
427-
globalNotes:
428-
nullable: true
429-
type: array
430-
items:
431-
$ref: '#/components/schemas/BareNote'
432-
eventNotes:
433-
nullable: true
434-
type: array
435-
items:
436-
$ref: '#/components/schemas/BareNote'
437-
pinnedEventIds:
438-
nullable: true
439-
type: array
440-
items:
441-
type: string
442432
ImportTimelineResult:
443433
type: object
444434
properties:

x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route_schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
openapi: 3.0.0
22
info:
33
title: Elastic Security - Timeline - Notes API
4-
version: 8.9.0
4+
version: 8.14.0
55
externalDocs:
66
url: https://www.elastic.co/guide/en/security/current/timeline-api-update.html
77
description: Documentation

x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export const pinnedEventIds = unionWithNullType(runtimeTypes.array(runtimeTypes.
1414
export const persistPinnedEventSchema = runtimeTypes.intersection([
1515
runtimeTypes.type({
1616
eventId: runtimeTypes.string,
17+
timelineId: runtimeTypes.string,
1718
}),
1819
runtimeTypes.partial({
1920
pinnedEventId: unionWithNullType(runtimeTypes.string),
20-
timelineId: unionWithNullType(runtimeTypes.string),
2121
}),
2222
]);
2323

@@ -51,9 +51,6 @@ export const PinnedEventRuntimeType = runtimeTypes.intersection([
5151
version: runtimeTypes.string,
5252
}),
5353
BarePinnedEventType,
54-
runtimeTypes.partial({
55-
timelineVersion: unionWithNullType(runtimeTypes.string),
56-
}),
5754
]);
5855

5956
export interface PinnedEvent extends runtimeTypes.TypeOf<typeof PinnedEventRuntimeType> {}

x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route_schema.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
openapi: 3.0.0
22
info:
33
title: Elastic Security - Timeline - Pinned Event API (https://www.elastic.co/guide/en/security/current/_pin_an_event_to_an_existing_timeline.html)
4-
version: 8.9.0
4+
version: 8.14.0
55
servers:
66
- url: 'http://{kibana_host}:{port}'
77
variables:
@@ -33,7 +33,6 @@ paths:
3333
nullable: true
3434
timelineId:
3535
type: string
36-
nullable: true
3736
responses:
3837
200:
3938
description: Indicate the event was successfully pinned in the timeline.
@@ -55,4 +54,4 @@ paths:
5554
message:
5655
type: string
5756
required:
58-
- data
57+
- data

x-pack/plugins/security_solution/common/types/timeline/note/saved_object.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { unionWithNullType } from '../../../utility_types';
1616
*/
1717
const SavedNoteRuntimeType = runtimeTypes.intersection([
1818
runtimeTypes.type({
19-
timelineId: unionWithNullType(runtimeTypes.string),
19+
timelineId: runtimeTypes.string,
2020
}),
2121
runtimeTypes.partial({
2222
eventId: unionWithNullType(runtimeTypes.string),
@@ -39,11 +39,6 @@ export const SavedObjectNoteRuntimeType = runtimeTypes.intersection([
3939
}),
4040
runtimeTypes.partial({
4141
noteId: runtimeTypes.string,
42-
timelineVersion: runtimeTypes.union([
43-
runtimeTypes.string,
44-
runtimeTypes.null,
45-
runtimeTypes.undefined,
46-
]),
4742
}),
4843
]);
4944

x-pack/plugins/security_solution/common/types/timeline/pinned_event/saved_object.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const SavedObjectPinnedEventRuntimeType = runtimeTypes.intersection([
3838
}),
3939
runtimeTypes.partial({
4040
pinnedEventId: unionWithNullType(runtimeTypes.string),
41-
timelineVersion: unionWithNullType(runtimeTypes.string),
4241
}),
4342
]);
4443

0 commit comments

Comments
 (0)