-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MDS] Fix showing DQS sources list in workspaces #8838
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- [MDS] Fix showing DQS sources list in workspaces ([#8838](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8838)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,11 +41,13 @@ | |
deleteMultipleDataSources, | ||
setFirstDataSourceAsDefault, | ||
getHideLocalCluster, | ||
getDataConnections, | ||
} from '../../utils'; | ||
import { LoadingMask } from '../../loading_mask'; | ||
import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_react/public'; | ||
import { DATACONNECTIONS_BASE, LOCAL_CLUSTER } from '../../../constants'; | ||
import { DEFAULT_DATA_SOURCE_UI_SETTINGS_ID } from '../../constants'; | ||
import { DataConnectionType } from '../../../../../data_source/common'; | ||
|
||
interface DirectQueryDataConnectionsProps extends RouteComponentProps { | ||
featureFlagStatus: boolean; | ||
|
@@ -128,50 +130,68 @@ | |
const fetchDataSources = useCallback(() => { | ||
setIsLoading(true); | ||
|
||
const fetchConnections = featureFlagStatus | ||
? getDataSources(savedObjects.client) | ||
: http.get(`${DATACONNECTIONS_BASE}`); | ||
|
||
return 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( | ||
featureFlagStatus | ||
const fetchOpenSearchConnections = async (): Promise<DataSourceTableItem[]> => { | ||
const fetchConnections = featureFlagStatus | ||
? getDataSources(savedObjects.client) | ||
: http.get(`${DATACONNECTIONS_BASE}`); | ||
|
||
return fetchConnections | ||
.then((response) => { | ||
return featureFlagStatus | ||
? fetchDataSourceConnections( | ||
response, | ||
http, | ||
notifications, | ||
true, | ||
getHideLocalCluster().enabled | ||
) | ||
: response.map((dataConnection: DirectQueryDatasourceDetails) => ({ | ||
Check warning on line 148 in src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.tsx Codecov / codecov/patchsrc/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.tsx#L148
|
||
id: dataConnection.name, | ||
title: dataConnection.name, | ||
type: | ||
{ | ||
S3GLUE: 'Amazon S3', | ||
PROMETHEUS: 'Prometheus', | ||
}[dataConnection.connector] || dataConnection.connector, | ||
connectionType: dataConnection.connector, | ||
description: dataConnection.description, | ||
})); | ||
}) | ||
.then((finalData) => { | ||
return featureFlagStatus | ||
? finalData.filter((item) => item.relatedConnections?.length > 0) | ||
: finalData | ||
); | ||
}) | ||
.catch(() => { | ||
setData([]); | ||
notifications.toasts.addDanger( | ||
i18n.translate('dataSourcesManagement.directQueryTable.fetchDataSources', { | ||
defaultMessage: 'Could not fetch data sources', | ||
}) | ||
); | ||
}) | ||
.finally(() => { | ||
setIsLoading(false); | ||
}); | ||
: finalData; | ||
}) | ||
.catch(() => { | ||
notifications.toasts.addDanger( | ||
i18n.translate('dataSourcesManagement.directQueryTable.fetchDataSources', { | ||
defaultMessage: 'Could not fetch data sources', | ||
}) | ||
); | ||
return []; | ||
}); | ||
}; | ||
|
||
const fetchDirectQueryConnections = async (): Promise<DataSourceTableItem[]> => { | ||
try { | ||
const dataConnectionSavedObjects = await getDataConnections(savedObjects.client); | ||
return dataConnectionSavedObjects.map((obj) => ({ | ||
Check warning on line 178 in src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.tsx Codecov / codecov/patchsrc/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.tsx#L178
|
||
id: obj.id, | ||
title: obj.attributes.connectionId, | ||
type: obj.attributes.type, | ||
})); | ||
} catch (error: any) { | ||
return []; | ||
} | ||
}; | ||
Comment on lines
+175
to
+186
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make sure this is covered as its new functionality |
||
|
||
const fetchAllData = async () => { | ||
const newData = await fetchOpenSearchConnections(); | ||
setData(newData.concat(await fetchDirectQueryConnections())); | ||
setIsLoading(false); | ||
}; | ||
|
||
fetchAllData(); | ||
}, [http, savedObjects, notifications, featureFlagStatus]); | ||
|
||
/* Delete selected data sources*/ | ||
|
@@ -385,17 +405,25 @@ | |
record.connectionType !== DataSourceConnectionType.OpenSearchConnection | ||
? { marginLeft: '20px' } | ||
: {}; | ||
return ( | ||
<EuiButtonEmpty | ||
size="xs" | ||
href={`${window.location.href.replace(/\/$/, '')}/${path}`} | ||
style={indentStyle} | ||
disabled={record.id === LOCAL_CLUSTER} | ||
flush="left" | ||
> | ||
{name} | ||
</EuiButtonEmpty> | ||
); | ||
if ( | ||
record.type === DataConnectionType.SecurityLake || | ||
record.type === DataConnectionType.CloudWatch | ||
) { | ||
// TODO: link to details page for security lake and cloudwatch | ||
return <span style={indentStyle}> {name}</span>; | ||
Check warning on line 413 in src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.tsx Codecov / codecov/patchsrc/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table.tsx#L413
|
||
} else { | ||
Comment on lines
+408
to
+414
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make sure this is covered as its new functionality |
||
return ( | ||
<EuiButtonEmpty | ||
size="xs" | ||
href={`${window.location.href.replace(/\/$/, '')}/${path}`} | ||
style={indentStyle} | ||
disabled={record.id === LOCAL_CLUSTER} | ||
flush="left" | ||
> | ||
{name} | ||
</EuiButtonEmpty> | ||
); | ||
} | ||
}, | ||
}, | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
} from '../service/data_source_selection_service'; | ||
import { DataSourceError } from '../types'; | ||
import { DATACONNECTIONS_BASE, LOCAL_CLUSTER } from '../constants'; | ||
import { DataConnectionSavedObjectAttributes } from '../../../data_source/common/data_connections'; | ||
|
||
export const getDirectQueryConnections = async (dataSourceId: string, http: HttpSetup) => { | ||
const endpoint = `${DATACONNECTIONS_BASE}/dataSourceMDSId=${dataSourceId}`; | ||
|
@@ -181,6 +182,17 @@ | |
); | ||
} | ||
|
||
export async function getDataConnections(savedObjectsClient: SavedObjectsClientContract) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we type response? |
||
return savedObjectsClient | ||
.find<DataConnectionSavedObjectAttributes>({ | ||
type: 'data-connection', | ||
perPage: 10000, | ||
}) | ||
.then((response) => { | ||
return response?.savedObjects; | ||
}); | ||
Comment on lines
+186
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. given this is new, can we cover with tests? |
||
} | ||
|
||
export async function getDataSourcesWithFields( | ||
savedObjectsClient: SavedObjectsClientContract, | ||
fields: string[] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz use
DatasourceTypeToDisplayName