Skip to content

Commit d2fffdc

Browse files
[Cases] Cleaning up migration and re-hiding comments saved object (#109344)
* Cleaning up migration and so * Refactoring filter to be check in reduce
1 parent c7ee7d7 commit d2fffdc

File tree

2 files changed

+37
-43
lines changed

2 files changed

+37
-43
lines changed

x-pack/plugins/cases/server/saved_object_types/comments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const createCaseCommentSavedObjectType = ({
1515
migrationDeps: CreateCommentsMigrationsDeps;
1616
}): SavedObjectsType => ({
1717
name: CASE_COMMENT_SAVED_OBJECT,
18-
hidden: false,
18+
hidden: true,
1919
namespaceType: 'single',
2020
mappings: {
2121
properties: {

x-pack/plugins/cases/server/saved_object_types/migrations/index.ts

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/* eslint-disable @typescript-eslint/naming-convention */
99

10-
import { flow, mapValues } from 'lodash';
10+
import { mapValues } from 'lodash';
1111
import { LensServerPluginSetup } from '../../../../lens/server';
1212

1313
import {
@@ -148,49 +148,43 @@ export const createCommentsMigrations = (
148148
) as MigrateFunctionsObject;
149149

150150
const commentsMigrations = {
151-
'7.11.0': flow(
152-
(
153-
doc: SavedObjectUnsanitizedDoc<UnsanitizedComment>
154-
): SavedObjectSanitizedDoc<SanitizedComment> => {
155-
return {
156-
...doc,
157-
attributes: {
158-
...doc.attributes,
159-
type: CommentType.user,
160-
},
161-
references: doc.references || [],
162-
};
163-
}
164-
),
165-
'7.12.0': flow(
166-
(
167-
doc: SavedObjectUnsanitizedDoc<UnsanitizedComment>
168-
): SavedObjectSanitizedDoc<SanitizedCommentForSubCases> => {
169-
let attributes: SanitizedCommentForSubCases & UnsanitizedComment = {
151+
'7.11.0': (
152+
doc: SavedObjectUnsanitizedDoc<UnsanitizedComment>
153+
): SavedObjectSanitizedDoc<SanitizedComment> => {
154+
return {
155+
...doc,
156+
attributes: {
170157
...doc.attributes,
171-
associationType: AssociationType.case,
172-
};
173-
174-
// only add the rule object for alert comments. Prior to 7.12 we only had CommentType.alert, generated alerts are
175-
// introduced in 7.12.
176-
if (doc.attributes.type === CommentType.alert) {
177-
attributes = { ...attributes, rule: { id: null, name: null } };
178-
}
179-
180-
return {
181-
...doc,
182-
attributes,
183-
references: doc.references || [],
184-
};
185-
}
186-
),
187-
'7.14.0': flow(
188-
(
189-
doc: SavedObjectUnsanitizedDoc<Record<string, unknown>>
190-
): SavedObjectSanitizedDoc<SanitizedCaseOwner> => {
191-
return addOwnerToSO(doc);
158+
type: CommentType.user,
159+
},
160+
references: doc.references || [],
161+
};
162+
},
163+
'7.12.0': (
164+
doc: SavedObjectUnsanitizedDoc<UnsanitizedComment>
165+
): SavedObjectSanitizedDoc<SanitizedCommentForSubCases> => {
166+
let attributes: SanitizedCommentForSubCases & UnsanitizedComment = {
167+
...doc.attributes,
168+
associationType: AssociationType.case,
169+
};
170+
171+
// only add the rule object for alert comments. Prior to 7.12 we only had CommentType.alert, generated alerts are
172+
// introduced in 7.12.
173+
if (doc.attributes.type === CommentType.alert) {
174+
attributes = { ...attributes, rule: { id: null, name: null } };
192175
}
193-
),
176+
177+
return {
178+
...doc,
179+
attributes,
180+
references: doc.references || [],
181+
};
182+
},
183+
'7.14.0': (
184+
doc: SavedObjectUnsanitizedDoc<Record<string, unknown>>
185+
): SavedObjectSanitizedDoc<SanitizedCaseOwner> => {
186+
return addOwnerToSO(doc);
187+
},
194188
};
195189

196190
return mergeMigrationFunctionMaps(commentsMigrations, embeddableMigrations);

0 commit comments

Comments
 (0)