diff --git a/src/plugins/data/public/query/query_string/dataset_service/lib/index_type.ts b/src/plugins/data/public/query/query_string/dataset_service/lib/index_type.ts index 272db09eabe8..5d81e157e413 100644 --- a/src/plugins/data/public/query/query_string/dataset_service/lib/index_type.ts +++ b/src/plugins/data/public/query/query_string/dataset_service/lib/index_type.ts @@ -119,19 +119,17 @@ const fetchDataSources = async (client: SavedObjectsClientContract) => { type: 'data-source', perPage: 10000, }); - const dataSources: DataStructure[] = [DEFAULT_DATA.STRUCTURES.LOCAL_DATASOURCE].concat( - response.savedObjects - .filter( - (savedObject) => - typeof savedObject.attributes?.dataSourceEngineType === 'string' && - !savedObject.attributes?.dataSourceEngineType?.includes('OpenSearch Serverless') - ) - .map((savedObject) => ({ - id: savedObject.id, - title: savedObject.attributes.title, - type: 'DATA_SOURCE', - })) - ); + const dataSources: DataStructure[] = response.savedObjects + .filter( + (savedObject) => + typeof savedObject.attributes?.dataSourceEngineType === 'string' && + !savedObject.attributes?.dataSourceEngineType?.includes('OpenSearch Serverless') + ) + .map((savedObject) => ({ + id: savedObject.id, + title: savedObject.attributes.title, + type: 'DATA_SOURCE', + })); return injectMetaToDataStructures(dataSources); }; diff --git a/src/plugins/query_enhancements/public/datasets/s3_type.test.ts b/src/plugins/query_enhancements/public/datasets/s3_type.test.ts index 3f085c135f28..eb1df6736303 100644 --- a/src/plugins/query_enhancements/public/datasets/s3_type.test.ts +++ b/src/plugins/query_enhancements/public/datasets/s3_type.test.ts @@ -150,8 +150,8 @@ describe('s3TypeConfig', () => { { id: 'unknown', title: 'Unknown', type: 'UNKNOWN' }, ]); - expect(result.children).toHaveLength(2); // Including DEFAULT_DATA.STRUCTURES.LOCAL_DATASOURCE - expect(result.children?.[1].title).toBe('DataSource 1'); + expect(result.children).toHaveLength(1); // Including DEFAULT_DATA.STRUCTURES.LOCAL_DATASOURCE + expect(result.children?.[0].title).toBe('DataSource 1'); expect(result.hasNext).toBe(true); }); @@ -171,9 +171,9 @@ describe('s3TypeConfig', () => { { id: 'unknown', title: 'Unknown', type: 'UNKNOWN' }, ]); - expect(result.children).toHaveLength(3); // Including DEFAULT_DATA.STRUCTURES.LOCAL_DATASOURCE - expect(result.children?.[1].title).toBe('DataSource 1'); - expect(result.children?.[2].title).toBe('DataSource 3'); + expect(result.children).toHaveLength(2); // Including DEFAULT_DATA.STRUCTURES.LOCAL_DATASOURCE + expect(result.children?.[0].title).toBe('DataSource 1'); + expect(result.children?.[1].title).toBe('DataSource 3'); expect(result.children?.some((child) => child.title === 'DataSource 2')).toBe(false); expect(result.hasNext).toBe(true); }); diff --git a/src/plugins/query_enhancements/public/datasets/s3_type.ts b/src/plugins/query_enhancements/public/datasets/s3_type.ts index a62f2d21cecc..948ed9461ac6 100644 --- a/src/plugins/query_enhancements/public/datasets/s3_type.ts +++ b/src/plugins/query_enhancements/public/datasets/s3_type.ts @@ -196,26 +196,24 @@ const fetchDataSources = async (client: SavedObjectsClientContract): Promise - typeof savedObject.attributes?.dataSourceEngineType === 'string' && - !savedObject.attributes?.dataSourceEngineType?.includes('OpenSearch Serverless') - ) - .map((savedObject) => ({ - id: savedObject.id, - title: savedObject.attributes.title, - type: 'DATA_SOURCE', - meta: { - query: { - id: savedObject.id, - }, - type: DATA_STRUCTURE_META_TYPES.CUSTOM, - } as DataStructureCustomMeta, - })) - ); + const dataSources: DataStructure[] = resp.savedObjects + .filter( + (savedObject) => + typeof savedObject.attributes?.dataSourceEngineType === 'string' && + !savedObject.attributes?.dataSourceEngineType?.includes('OpenSearch Serverless') + ) + .map((savedObject) => ({ + id: savedObject.id, + title: savedObject.attributes.title, + type: 'DATA_SOURCE', + meta: { + query: { + id: savedObject.id, + }, + type: DATA_STRUCTURE_META_TYPES.CUSTOM, + } as DataStructureCustomMeta, + })); + return dataSources; }; const fetchConnections = async (