Skip to content

Commit

Permalink
add dataSourceId to dataSet (#7361) (#7386)
Browse files Browse the repository at this point in the history
* add dataSourceId to dataSet



* fix tests



---------


(cherry picked from commit 3587291)

Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 5708d4b commit 17a0234
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/plugins/data/public/data_sources/datasource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DataSource } from './datasource';
export interface IndexPatternOption {
title: string;
id: string;
dataSourceId?: string;
}

export interface IDataSourceGroup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ describe('DefaultDslDataSource', () => {

it('should return a populated dataset if getCache returns non-empty array', async () => {
const mockSavedObjects = [
{ id: '1', attributes: { title: 'Index1' } },
{ id: '2', attributes: { title: 'Index2' } },
{ id: '1', attributes: { title: 'Index1' }, references: [] },
{ id: '2', attributes: { title: 'Index2' }, references: [] },
];
indexPatternsMock.getCache.mockResolvedValue(mockSavedObjects);
const dataSource = new DefaultDslDataSource({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { getDataSourceReference } from '../../../common/index_patterns/utils';
import { SavedObject } from '../../../../../core/public';
import {
IndexPatternSavedObjectAttrs,
Expand Down Expand Up @@ -54,6 +55,7 @@ export class DefaultDslDataSource extends DataSource<
return {
id: savedObject.id,
title: savedObject.attributes.title,
dataSourceId: getDataSourceReference(savedObject.references)?.id,
};
}),
};
Expand Down

0 comments on commit 17a0234

Please sign in to comment.