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 6bd865e2750a2..4abe201b33901 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 @@ -777,7 +777,12 @@ describe('helpers', () => { expect(dispatchAddTimeline).toHaveBeenCalledWith({ id: TimelineId.active, savedTimeline: true, - timeline: mockTimelineModel, + timeline: { + ...mockTimelineModel, + version: null, + updated: undefined, + changed: undefined, + }, }); }); 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 e4f5f8746cc0c..e4a738cbe55e3 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 @@ -435,18 +435,22 @@ export const dispatchUpdateTimeline = preventSettingQuery, }: UpdateTimeline): (() => void) => () => { - if (!isEmpty(timeline.indexNames)) { + let _timeline = timeline; + if (duplicate) { + _timeline = { ...timeline, updated: undefined, changed: undefined, version: null }; + } + if (!isEmpty(_timeline.indexNames)) { dispatch( sourcererActions.setSelectedDataView({ id: SourcererScopeName.timeline, - selectedDataViewId: timeline.dataViewId, - selectedPatterns: timeline.indexNames, + selectedDataViewId: _timeline.dataViewId, + selectedPatterns: _timeline.indexNames, }) ); } if ( - timeline.status === TimelineStatus.immutable && - timeline.timelineType === TimelineType.template + _timeline.status === TimelineStatus.immutable && + _timeline.timelineType === TimelineType.template ) { dispatch( dispatchSetRelativeRangeDatePicker({ @@ -461,24 +465,29 @@ export const dispatchUpdateTimeline = dispatch(dispatchSetTimelineRangeDatePicker({ from, to })); } dispatch( - dispatchAddTimeline({ id, timeline, resolveTimelineConfig, savedTimeline: duplicate }) + dispatchAddTimeline({ + id, + timeline: _timeline, + resolveTimelineConfig, + savedTimeline: duplicate, + }) ); if ( !preventSettingQuery && - timeline.kqlQuery != null && - timeline.kqlQuery.filterQuery != null && - timeline.kqlQuery.filterQuery.kuery != null && - timeline.kqlQuery.filterQuery.kuery.expression !== '' + _timeline.kqlQuery != null && + _timeline.kqlQuery.filterQuery != null && + _timeline.kqlQuery.filterQuery.kuery != null && + _timeline.kqlQuery.filterQuery.kuery.expression !== '' ) { dispatch( dispatchApplyKqlFilterQuery({ id, filterQuery: { kuery: { - kind: timeline.kqlQuery.filterQuery.kuery.kind ?? 'kuery', - expression: timeline.kqlQuery.filterQuery.kuery.expression || '', + kind: _timeline.kqlQuery.filterQuery.kuery.kind ?? 'kuery', + expression: _timeline.kqlQuery.filterQuery.kuery.expression || '', }, - serializedQuery: timeline.kqlQuery.filterQuery.serializedQuery || '', + serializedQuery: _timeline.kqlQuery.filterQuery.serializedQuery || '', }, }) );