Skip to content

Commit

Permalink
Revert "Filter saved object version during legacy import (#75597) (#…
Browse files Browse the repository at this point in the history
…75793)"

This reverts commit 6e82885.
  • Loading branch information
mikecote committed Aug 31, 2020
1 parent 2eb8e69 commit 62845cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ describe('importDashboards(req)', () => {
savedObjectClient.bulkCreate.mockResolvedValue({ saved_objects: [] });

importedObjects = [
{
id: 'dashboard-01',
type: 'dashboard',
attributes: { panelJSON: '{}' },
references: [],
version: 'foo',
},
{ id: 'dashboard-01', type: 'dashboard', attributes: { panelJSON: '{}' }, references: [] },
{ id: 'panel-01', type: 'visualization', attributes: { visState: '{}' }, references: [] },
];
});

test('should call bulkCreate with each asset, filtering out any version if present', async () => {
test('should call bulkCreate with each asset', async () => {
await importDashboards(savedObjectClient, importedObjects, { overwrite: false, exclude: [] });

expect(savedObjectClient.bulkCreate).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export async function importDashboards(
// docs are not seen as automatically up-to-date.
const docs = objects
.filter((item) => !exclude.includes(item.type))
// filter out any document version, if present
.map(({ version, ...doc }) => ({ ...doc, migrationVersion: doc.migrationVersion || {} }));
.map((doc) => ({ ...doc, migrationVersion: doc.migrationVersion || {} }));

const results = await savedObjectsClient.bulkCreate(docs, { overwrite });
return { objects: results.saved_objects };
Expand Down

0 comments on commit 62845cc

Please sign in to comment.