diff --git a/src/plugins/workspace/public/components/data_source_association/association_data_source_modal.test.tsx b/src/plugins/workspace/public/components/data_source_association/association_data_source_modal.test.tsx index 72e1aae42d6e..f3057716f771 100644 --- a/src/plugins/workspace/public/components/data_source_association/association_data_source_modal.test.tsx +++ b/src/plugins/workspace/public/components/data_source_association/association_data_source_modal.test.tsx @@ -2,7 +2,7 @@ * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ -import { fireEvent, render, screen, waitFor, act } from '@testing-library/react'; +import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import React from 'react'; import { IntlProvider } from 'react-intl'; @@ -78,7 +78,7 @@ const setupAssociationDataSourceModal = ({ id: 'ds1-dqc1', name: 'dqc1', type: 'Amazon S3', - connectionType: 1, + connectionType: DataSourceConnectionType.DirectQueryConnection, parentId: 'ds1', }, ]); diff --git a/src/plugins/workspace/public/components/data_source_association/association_data_source_modal.tsx b/src/plugins/workspace/public/components/data_source_association/association_data_source_modal.tsx index dc61fc0ef358..8feba8a52a44 100644 --- a/src/plugins/workspace/public/components/data_source_association/association_data_source_modal.tsx +++ b/src/plugins/workspace/public/components/data_source_association/association_data_source_modal.tsx @@ -259,9 +259,12 @@ export const AssociationDataSourceModalContent = ({ openSearchConnections, dataConnections, } = convertDataSourcesToOpenSearchAndDataConnections(dataSourcesList); - - const initialLoadingStatus = dataSourcesList.reduce((acc, ds) => { - acc[ds.id] = true; + // Only data source saved object type needs to fetch data source connections, data connection type object not, use loadingStatus to track the loading status of each data source connections + const initialLoadingStatus = [ + ...openSearchConnections.map((ds) => ({ id: ds.id, status: true })), + ...dataConnections.map((ds) => ({ id: ds.id, status: false })), + ].reduce((acc, { id, status }) => { + acc[id] = status; return acc; }, {} as Record); @@ -272,9 +275,8 @@ export const AssociationDataSourceModalContent = ({ return { openSearchConnections }; }) .then(({ openSearchConnections }) => { - // Only data source saved object type needs to fetch data source connections, data connection type object not. openSearchConnections.forEach((ds) => { - // fetch direct query connections for each data source, and set loading status accordingly + // only fetch direct query connections for data source saved object, and set loading status accordingly fetchDirectQueryConnectionsByIDs([ds.id], http, notifications) .then((directQueryConnections) => { setAllConnections((prev) => {