Skip to content

Commit

Permalink
remove embeddable migration from dashboard and put in maps
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Feb 15, 2022
1 parent e8a8d0b commit a64328e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
MigrateFunctionsObject,
} from '../../../kibana_utils/common';
import { replaceIndexPatternReference } from './replace_index_pattern_reference';
import { migrateMapEmbeddable } from './migrate_map_embeddable';

function migrateIndexPattern(doc: DashboardDoc700To720) {
const searchSourceJSON = get(doc, 'attributes.kibanaSavedObjectMeta.searchSourceJSON');
Expand Down Expand Up @@ -250,9 +249,6 @@ export const createDashboardSavedObjectTypeMigrations = (
// '7.x': flow(yourNewMigrationFunction, embeddableMigrations['7.x'] ?? identity),

'7.14.0': flow(replaceIndexPatternReference),

'7.17.1': flow(migrateMapEmbeddable),
'8.0.1': flow(migrateMapEmbeddable),
};

return mergeMigrationFunctionMaps(dashboardMigrations, embeddableMigrations);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

27 changes: 27 additions & 0 deletions x-pack/plugins/maps/server/embeddable_migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { MapSavedObjectAttributes } from '../common/map_saved_object_type';
import { moveAttribution } from '../common/migrations/move_attribution';
import { setEmsTmsDefaultModes } from '../common/migrations/set_ems_tms_default_modes';
import { renameLayerTypes } from '../common/migrations/rename_layer_types';
import { extractReferences } from '../common/migrations/references';

/*
* Embeddables such as Maps, Lens, and Visualize can be embedded by value or by reference on a dashboard.
Expand All @@ -31,6 +32,19 @@ export const embeddableMigrations = {
return state;
}
},
'7.17.1': (state: SerializableRecord) => {
try {
const { attributes } = extractReferences(state as { attributes: MapSavedObjectAttributes });
return {
...state,
attributes,
} as SerializableRecord;
} catch (e) {
// Do not fail migration for invalid layerListJSON
// Maps application can display invalid layerListJSON error when saved object is viewed
return state;
}
},
'8.0.0': (state: SerializableRecord) => {
try {
return {
Expand All @@ -43,6 +57,19 @@ export const embeddableMigrations = {
return state;
}
},
'8.0.1': (state: SerializableRecord) => {
try {
const { attributes } = extractReferences(state as { attributes: MapSavedObjectAttributes });
return {
...state,
attributes,
} as SerializableRecord;
} catch (e) {
// Do not fail migration for invalid layerListJSON
// Maps application can display invalid layerListJSON error when saved object is viewed
return state;
}
},
'8.1.0': (state: SerializableRecord) => {
try {
return {
Expand Down

0 comments on commit a64328e

Please sign in to comment.