mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.12] [SecuritySolution] Reset `updated`, `changed` and `version` when duplicating a timeline (#175110) (#175236)
# Backport This will backport the following commits from `main` to `8.12`: - [[SecuritySolution] Reset `updated`, `changed` and `version` when duplicating a timeline (#175110)](https://github.com/elastic/kibana/pull/175110) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Jan Monschke","email":"jan.monschke@elastic.co"},"sourceCommit":{"committedDate":"2024-01-22T16:32:14Z","message":"[SecuritySolution] Reset `updated`, `changed` and `version` when duplicating a timeline (#175110)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/173968\r\n\r\nWhen duplicating a timeline (note: not the same as `save as new`), the\r\nsave status of the duplicate timeline wasn't displaying correctly\r\n(https://github.com/elastic/kibana/issues/173968). That's because we did\r\nnot reset the local values of `updated`, `changed` and `version`.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"8d2bab7aa8182b9434d0c0cd2ec9cbfa5e703ef0","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Threat Hunting:Investigations","v8.12.0","v8.13.0"],"title":"[SecuritySolution] Reset `updated`, `changed` and `version` when duplicating a timeline","number":175110,"url":"https://github.com/elastic/kibana/pull/175110","mergeCommit":{"message":"[SecuritySolution] Reset `updated`, `changed` and `version` when duplicating a timeline (#175110)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/173968\r\n\r\nWhen duplicating a timeline (note: not the same as `save as new`), the\r\nsave status of the duplicate timeline wasn't displaying correctly\r\n(https://github.com/elastic/kibana/issues/173968). That's because we did\r\nnot reset the local values of `updated`, `changed` and `version`.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"8d2bab7aa8182b9434d0c0cd2ec9cbfa5e703ef0"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175110","number":175110,"mergeCommit":{"message":"[SecuritySolution] Reset `updated`, `changed` and `version` when duplicating a timeline (#175110)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/173968\r\n\r\nWhen duplicating a timeline (note: not the same as `save as new`), the\r\nsave status of the duplicate timeline wasn't displaying correctly\r\n(https://github.com/elastic/kibana/issues/173968). That's because we did\r\nnot reset the local values of `updated`, `changed` and `version`.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"8d2bab7aa8182b9434d0c0cd2ec9cbfa5e703ef0"}}]}] BACKPORT--> Co-authored-by: Jan Monschke <jan.monschke@elastic.co>
This commit is contained in:
parent
269f085dae
commit
490e1e4d9a
2 changed files with 28 additions and 14 deletions
|
@ -777,7 +777,12 @@ describe('helpers', () => {
|
|||
expect(dispatchAddTimeline).toHaveBeenCalledWith({
|
||||
id: TimelineId.active,
|
||||
savedTimeline: true,
|
||||
timeline: mockTimelineModel,
|
||||
timeline: {
|
||||
...mockTimelineModel,
|
||||
version: null,
|
||||
updated: undefined,
|
||||
changed: undefined,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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 || '',
|
||||
},
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue