[Cases] Cleaning up migration and re-hiding comments saved object (#109344)

* Cleaning up migration and so

* Refactoring filter to be check in reduce
This commit is contained in:
Jonathan Buttner 2021-09-02 09:24:37 -04:00 committed by GitHub
parent c7ee7d7898
commit d2fffdcca1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 42 deletions

View file

@ -15,7 +15,7 @@ export const createCaseCommentSavedObjectType = ({
migrationDeps: CreateCommentsMigrationsDeps;
}): SavedObjectsType => ({
name: CASE_COMMENT_SAVED_OBJECT,
hidden: false,
hidden: true,
namespaceType: 'single',
mappings: {
properties: {

View file

@ -7,7 +7,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { flow, mapValues } from 'lodash';
import { mapValues } from 'lodash';
import { LensServerPluginSetup } from '../../../../lens/server';
import {
@ -148,49 +148,43 @@ export const createCommentsMigrations = (
) as MigrateFunctionsObject;
const commentsMigrations = {
'7.11.0': flow(
(
doc: SavedObjectUnsanitizedDoc<UnsanitizedComment>
): SavedObjectSanitizedDoc<SanitizedComment> => {
return {
...doc,
attributes: {
...doc.attributes,
type: CommentType.user,
},
references: doc.references || [],
};
}
),
'7.12.0': flow(
(
doc: SavedObjectUnsanitizedDoc<UnsanitizedComment>
): SavedObjectSanitizedDoc<SanitizedCommentForSubCases> => {
let attributes: SanitizedCommentForSubCases & UnsanitizedComment = {
'7.11.0': (
doc: SavedObjectUnsanitizedDoc<UnsanitizedComment>
): SavedObjectSanitizedDoc<SanitizedComment> => {
return {
...doc,
attributes: {
...doc.attributes,
associationType: AssociationType.case,
};
type: CommentType.user,
},
references: doc.references || [],
};
},
'7.12.0': (
doc: SavedObjectUnsanitizedDoc<UnsanitizedComment>
): SavedObjectSanitizedDoc<SanitizedCommentForSubCases> => {
let attributes: SanitizedCommentForSubCases & UnsanitizedComment = {
...doc.attributes,
associationType: AssociationType.case,
};
// only add the rule object for alert comments. Prior to 7.12 we only had CommentType.alert, generated alerts are
// introduced in 7.12.
if (doc.attributes.type === CommentType.alert) {
attributes = { ...attributes, rule: { id: null, name: null } };
}
// only add the rule object for alert comments. Prior to 7.12 we only had CommentType.alert, generated alerts are
// introduced in 7.12.
if (doc.attributes.type === CommentType.alert) {
attributes = { ...attributes, rule: { id: null, name: null } };
}
return {
...doc,
attributes,
references: doc.references || [],
};
}
),
'7.14.0': flow(
(
doc: SavedObjectUnsanitizedDoc<Record<string, unknown>>
): SavedObjectSanitizedDoc<SanitizedCaseOwner> => {
return addOwnerToSO(doc);
}
),
return {
...doc,
attributes,
references: doc.references || [],
};
},
'7.14.0': (
doc: SavedObjectUnsanitizedDoc<Record<string, unknown>>
): SavedObjectSanitizedDoc<SanitizedCaseOwner> => {
return addOwnerToSO(doc);
},
};
return mergeMigrationFunctionMaps(commentsMigrations, embeddableMigrations);