Skip to content

Commit

Permalink
format import api
Browse files Browse the repository at this point in the history
  • Loading branch information
yujin-emma committed Feb 1, 2024
1 parent 43f3465 commit 43702c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/core/server/saved_objects/routes/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,18 @@ export const registerImportRoute = (router: IRouter, config: SavedObjectConfig)
}

// get datasource from saved object service
const dataSource = dataSourceId ? await context.core.savedObjects.client
.get('data-source', dataSourceId)
.then((response) => {
const attributes: any = response?.attributes || {};
return {
id: response.id,
title: attributes.title,
};
}) : '';
// dataSource is '' when there is no dataSource pass in the url
const dataSource = dataSourceId
? await context.core.savedObjects.client
.get('data-source', dataSourceId)
.then((response) => {
const attributes: any = response?.attributes || {};
return {
id: response.id,
title: attributes.title,
};
})
: '';

const dataSourceTitle = dataSource ? dataSource.title : '';

Expand Down
2 changes: 2 additions & 0 deletions test/functional/apps/management/_import_objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import expect from '@osd/expect';
import path from 'path';
import { keyBy } from 'lodash';
import { wait } from '@hapi/hoek';

const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

Expand Down Expand Up @@ -250,6 +251,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.savedObjects.clickImportDone();
const objects = await PageObjects.savedObjects.getRowTitles();
const isSavedObjectImported = objects.includes('saved object with index pattern conflict');
wait(10000);
expect(isSavedObjectImported).to.be(true);
});

Expand Down

0 comments on commit 43702c8

Please sign in to comment.