@@ -2517,13 +2525,13 @@ exports[`ManageDirectQueryDataConnectionsTable should get direct query connectio
setScopeRow={false}
textOnly={true}
truncateText={true}
- width="35%"
+ width="45%"
>
|
diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.test.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.test.tsx
index 6f3f8ef959cf..cf104ef0c64b 100644
--- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.test.tsx
+++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.test.tsx
@@ -34,6 +34,7 @@ describe('ManageDirectQueryDataConnectionsTable', () => {
component = await mount(
wrapWithIntl(
{
spyOn(utils, 'fetchDataSourceConnections').and.returnValue(
Promise.resolve(getMappedDataSources)
);
+ spyOn(utils, 'getHideLocalCluster').and.returnValue(false);
spyOn(uiSettings, 'get').and.returnValue('test1');
await act(async () => {
component = await mount(
wrapWithIntl(
{
+interface DirectQueryDataConnectionsProps extends RouteComponentProps {
+ featureFlagStatus: boolean;
+}
+
+export const ManageDirectQueryDataConnectionsTable = ({
+ featureFlagStatus,
+ history,
+}: DirectQueryDataConnectionsProps) => {
const { savedObjects, http, notifications, uiSettings } = useOpenSearchDashboards<
DataSourceManagementContext
>().services;
@@ -63,8 +73,11 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
setSelectedDataSources(selected);
};
- const selection = {
+ const selection = featureFlagStatus && {
onSelectionChange,
+ selectable: (item: DataSourceTableItem) => {
+ return item.id !== LOCAL_CLUSTER;
+ },
};
const setDefaultDataSource = async () => {
@@ -200,12 +213,38 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
const fetchDataSources = useCallback(() => {
setIsLoading(true);
- getDataSources(savedObjects.client)
- .then((response: DataSourceTableItem[]) => {
- return fetchDataSourceConnections(response, http, notifications);
+ const fetchConnections = featureFlagStatus
+ ? getDataSources(savedObjects.client)
+ : http.get(`${DATACONNECTIONS_BASE}`);
+
+ fetchConnections
+ .then((response) => {
+ return featureFlagStatus
+ ? fetchDataSourceConnections(
+ response,
+ http,
+ notifications,
+ true,
+ getHideLocalCluster().enabled
+ )
+ : response.map((dataConnection: DirectQueryDatasourceDetails) => ({
+ id: dataConnection.name,
+ title: dataConnection.name,
+ type:
+ {
+ S3GLUE: 'Amazon S3',
+ PROMETHEUS: 'Prometheus',
+ }[dataConnection.connector] || dataConnection.connector,
+ connectionType: dataConnection.connector,
+ description: dataConnection.description,
+ }));
})
.then((finalData) => {
- setData(finalData.filter((item) => item.relatedConnections?.length > 0));
+ setData(
+ featureFlagStatus
+ ? finalData.filter((item) => item.relatedConnections?.length > 0)
+ : finalData
+ );
})
.catch(() => {
setData([]);
@@ -218,7 +257,7 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
.finally(() => {
setIsLoading(false);
});
- }, [http, savedObjects, notifications]);
+ }, [http, savedObjects, notifications, featureFlagStatus]);
useEffect(() => {
fetchDataSources();
@@ -229,7 +268,7 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
}, [fetchDataSources]);
const tableColumns = [
- {
+ featureFlagStatus && {
align: LEFT_ALIGNMENT,
width: '40px',
isExpander: true,
@@ -243,7 +282,7 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
) : null,
},
{
- width: '25%',
+ width: '32%',
field: 'title',
name: i18n.translate('dataSourcesManagement.directQueryTable.dataSourceField', {
defaultMessage: 'Data source',
@@ -254,21 +293,32 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
const path =
record.connectionType === DataSourceConnectionType.OpenSearchConnection
? record.id
- : `manage/${name}?dataSourceMDSId=${record.parentId}`;
+ : `manage/${name}${
+ record.parentId && record.parentId !== LOCAL_CLUSTER
+ ? `?dataSourceMDSId=${record.parentId}`
+ : ''
+ }`;
const indentStyle =
+ featureFlagStatus &&
record.connectionType !== DataSourceConnectionType.OpenSearchConnection
? { marginLeft: '20px' }
: {};
return (
-
+
{name}
);
},
},
{
- width: '15%',
+ width: '22%',
field: 'type',
name: i18n.translate('dataSourcesManagement.directQueryTable.typeField', {
defaultMessage: 'Type',
@@ -276,7 +326,7 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
truncateText: true,
},
{
- width: '35%',
+ width: '45%',
field: 'description',
name: i18n.translate('dataSourcesManagement.directQueryTable.descriptionField', {
defaultMessage: 'Description',
@@ -286,7 +336,7 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
show: false,
},
},
- {
+ featureFlagStatus && {
field: 'relatedConnections',
name: i18n.translate('dataSourcesManagement.directQueryTable.relatedConnectionsField', {
defaultMessage: 'Related connections',
@@ -295,7 +345,7 @@ export const ManageDirectQueryDataConnectionsTable = ({ history }: RouteComponen
truncateText: true,
render: (relatedConnections: DataSourceTableItem[]) => relatedConnections?.length,
},
- ] as Array>;
+ ].filter(Boolean) as Array>;
const customSearchBar: EuiSearchBarProps = {
toolsLeft: renderToolsLeft(),
diff --git a/src/plugins/data_source_management/public/components/utils.ts b/src/plugins/data_source_management/public/components/utils.ts
index 127a69e69d5e..721d47274b0c 100644
--- a/src/plugins/data_source_management/public/components/utils.ts
+++ b/src/plugins/data_source_management/public/components/utils.ts
@@ -42,7 +42,7 @@ import {
defaultDataSourceSelection,
} from '../service/data_source_selection_service';
import { DataSourceError } from '../types';
-import { DATACONNECTIONS_BASE } from '../constants';
+import { DATACONNECTIONS_BASE, LOCAL_CLUSTER } from '../constants';
export const getDirectQueryConnections = async (dataSourceId: string, http: HttpSetup) => {
const endpoint = `${DATACONNECTIONS_BASE}/dataSourceMDSId=${dataSourceId}`;
@@ -67,9 +67,29 @@ export const getDirectQueryConnections = async (dataSourceId: string, http: Http
return directQueryConnections;
};
+export const getLocalClusterConnections = async (http: HttpSetup) => {
+ const res = await http.get(`${DATACONNECTIONS_BASE}`);
+ const localClusterConnections: DataSourceTableItem[] = res.map(
+ (dataConnection: DirectQueryDatasourceDetails) => ({
+ id: `${dataConnection.name}`,
+ title: dataConnection.name,
+ type:
+ {
+ S3GLUE: 'Amazon S3',
+ PROMETHEUS: 'Prometheus',
+ }[dataConnection.connector] || dataConnection.connector,
+ connectionType: DataSourceConnectionType.DirectQueryConnection,
+ description: dataConnection.description,
+ parentId: LOCAL_CLUSTER,
+ })
+ );
+ return localClusterConnections;
+};
+
export const mergeDataSourcesWithConnections = (
dataSources: DataSourceTableItem[],
- directQueryConnections: DataSourceTableItem[]
+ directQueryConnections: DataSourceTableItem[],
+ localClusterConnections?: DataSourceTableItem[]
): DataSourceTableItem[] => {
const dataSourcesList: DataSourceTableItem[] = [];
dataSources.forEach((ds) => {
@@ -87,13 +107,25 @@ export const mergeDataSourcesWithConnections = (
});
});
+ if (localClusterConnections) {
+ dataSourcesList.push({
+ id: LOCAL_CLUSTER,
+ type: 'OpenSearch',
+ connectionType: DataSourceConnectionType.OpenSearchConnection,
+ title: LOCAL_CLUSTER,
+ relatedConnections: localClusterConnections,
+ });
+ }
+
return dataSourcesList;
};
export const fetchDataSourceConnections = async (
dataSources: DataSourceTableItem[],
http: HttpSetup | undefined,
- notifications: NotificationsStart | undefined
+ notifications: NotificationsStart | undefined,
+ directQueryTable: boolean,
+ hideLocalCluster: boolean
) => {
try {
const directQueryConnectionsPromises = dataSources.map((ds) =>
@@ -101,7 +133,13 @@ export const fetchDataSourceConnections = async (
);
const directQueryConnectionsResult = await Promise.all(directQueryConnectionsPromises);
const directQueryConnections = directQueryConnectionsResult.flat();
- return mergeDataSourcesWithConnections(dataSources, directQueryConnections);
+ const localClusterConnections =
+ directQueryTable && !hideLocalCluster ? await getLocalClusterConnections(http!) : undefined;
+ return mergeDataSourcesWithConnections(
+ dataSources,
+ directQueryConnections,
+ localClusterConnections
+ );
} catch (error) {
notifications?.toasts.addDanger(
i18n.translate('dataSource.fetchDataSourceConnections', {
diff --git a/src/plugins/data_source_management/public/constants.ts b/src/plugins/data_source_management/public/constants.ts
index 770405626ee8..961f6b2d3f33 100644
--- a/src/plugins/data_source_management/public/constants.ts
+++ b/src/plugins/data_source_management/public/constants.ts
@@ -7,6 +7,7 @@ import { DirectQueryDatasourceType } from './types';
export const QUERY_RESTRICTED = 'query-restricted';
export const QUERY_ALL = 'query-all';
+export const LOCAL_CLUSTER = 'local_cluster';
export const DatasourceTypeToDisplayName: { [key in DirectQueryDatasourceType]: string } = {
PROMETHEUS: 'Prometheus',
|