diff --git a/README.md b/README.md index 56035fa1..ab741cdb 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ The OpenSearch Dashboards Query Workbench enables you to query your OpenSearch d [cypress-test-badge]: https://img.shields.io/badge/Cypress%20tests-in%20progress-yellow [cypress-test-link]: https://github.com/opensearch-project/opensearch-build/issues/1124 [cypress-code-badge]: https://img.shields.io/badge/Cypress%20code-blue -[cypress-code-link]: https://github.com/opensearch-project/sql/tree/main/workbench/.cypress/integration +[cypress-code-link]: https://github.com/opensearch-project/dashboards-query-workbench/tree/main/.cypress/integration ## Documentation -Please see our technical [documentation](https://opensearch.org/docs/latest/search-plugins/sql/workbench/) to learn more about its features. +Please see our technical [documentation](https://opensearch.org/docs/latest/search-plugins/sql/workbench/) to learn more about its features. ## Contributing diff --git a/common/utils/async_query_helpers.ts b/common/utils/async_query_helpers.ts index 8e5888b1..6e01ff8f 100644 --- a/common/utils/async_query_helpers.ts +++ b/common/utils/async_query_helpers.ts @@ -27,6 +27,7 @@ export const executeAsyncQuery = ( currentDataSource: string, query: {}, pollingCallback: PollingCallback, + dataSourceMDSId?: string, onErrorCallback?: (errorMessage: string) => void ) => { let jobId: string | undefined; @@ -41,6 +42,7 @@ export const executeAsyncQuery = ( ...query, sessionId: getAsyncSessionId(currentDataSource) ?? undefined, }), + query: { dataSourceMDSId }, }) .then((res) => { const responseData = res.data.resp; @@ -76,7 +78,7 @@ export const executeAsyncQuery = ( const pollQueryStatus = (id: string, callback: PollingCallback) => { !isQueryCancelled && http - .get(ASYNC_QUERY_JOB_ENDPOINT + id) + .get(ASYNC_QUERY_JOB_ENDPOINT + id + `/` + dataSourceMDSId) .then((res: AsyncApiResponse) => { const status = res.data.resp.status.toLowerCase(); const errorDetailsMessage = res.data.resp.error ?? ''; diff --git a/common/utils/fetch_datasources.ts b/common/utils/fetch_datasources.ts new file mode 100644 index 00000000..f9f205ee --- /dev/null +++ b/common/utils/fetch_datasources.ts @@ -0,0 +1,53 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + + +import { CoreStart } from "../../../../src/core/public"; + +export const fetchDataSources = (http: CoreStart['http'], dataSourceMDSId: string, urlDataSource: string, onSuccess, onError) => { + let dataOptions: { label: string; options?: Array<{ label: string }>; }[] = []; + let urlSourceFound = false; + if(!dataSourceMDSId){ + dataSourceMDSId = '' + } + + http.get(`/api/get_datasources/${dataSourceMDSId}`) + .then((res) => { + const data = res.data.resp; + const connectorGroups = {}; + + data.forEach((item) => { + const { connector, name } = item + + if (connector === 'S3GLUE') { + if (!connectorGroups[connector]) { + connectorGroups[connector] = []; + } + + connectorGroups[connector].push(name); + if (name === urlDataSource) { + urlSourceFound = true; + } + } + }); + + for (const connector in connectorGroups) { + if (connectorGroups.hasOwnProperty(connector)) { + const connectorNames = connectorGroups[connector]; + + dataOptions.push({ + label: connector, + options: connectorNames.map((name) => ({ label: name })), + }); + } + } + + onSuccess(dataOptions, urlSourceFound); + }) + .catch((err) => { + console.error(err); + onError(err); + }); + }; \ No newline at end of file diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 8ff83c05..9ae570bf 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -4,12 +4,6 @@ "opensearchDashboardsVersion": "2.14.0", "server": true, "ui": true, - "requiredPlugins": [ - "navigation", - "opensearchDashboardsReact", - "opensearchDashboardsUtils" - ], - "optionalPlugins": [ - "observabilityDashboards" - ] + "requiredPlugins": ["navigation", "opensearchDashboardsReact", "opensearchDashboardsUtils"], + "optionalPlugins": ["observabilityDashboards", "dataSource", "dataSourceManagement"] } \ No newline at end of file diff --git a/public/application.tsx b/public/application.tsx index 8957c22b..885e512c 100644 --- a/public/application.tsx +++ b/public/application.tsx @@ -7,13 +7,15 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { AppMountParameters, CoreStart } from '../../../src/core/public'; -import { AppPluginStartDependencies } from './types'; +import { DataSourceManagementPluginSetup } from '../../../src/plugins/data_source_management/public'; import { WorkbenchApp } from './components/app'; +import { AppPluginStartDependencies } from './types'; export const renderApp = ( - { notifications, http, chrome }: CoreStart, - { navigation }: AppPluginStartDependencies, - { appBasePath, element }: AppMountParameters + { notifications, http, chrome, savedObjects }: CoreStart, + { navigation, dataSource }: AppPluginStartDependencies, + { appBasePath, element, setHeaderActionMenu }: AppMountParameters, + dataSourceManagement: DataSourceManagementPluginSetup ) => { ReactDOM.render( , element ); diff --git a/public/components/Main/__snapshots__/main.test.tsx.snap b/public/components/Main/__snapshots__/main.test.tsx.snap index 3002e161..ec09cff2 100644 --- a/public/components/Main/__snapshots__/main.test.tsx.snap +++ b/public/components/Main/__snapshots__/main.test.tsx.snap @@ -2,230 +2,25 @@ exports[`
spec click clear button 1`] = `
-
-
-
- Data Sources -
-
-
-
- -
-
-
+ +

+
@@ -268,15 +63,122 @@ exports[`
spec click clear button 1`] = ` class="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent" role="main" > +
+
+
+ + query-language-swtich + +
+ + +
+
+
+
+ +
-
spec click clear button 1`] = ` exports[`
spec click run button, and response causes an error 1`] = `
-
-
-
- Data Sources -
-
-
-
- -
-
-
+ +

+
@@ -807,13 +504,120 @@ exports[`
spec click run button, and response causes an error 1`] = ` role="main" >
-
+
+ + query-language-swtich + +
+ + +
+
+
+
+ +
+
+
spec click run button, and response causes an error 1`] = ` exports[`
spec click run button, and response is not ok 1`] = `
-
-
-
- Data Sources -
-
-
-
- -
-
-
+ +

+
@@ -1340,15 +943,118 @@ exports[`
spec click run button, and response is not ok 1`] = ` class="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent" role="main" > +
+
+
+ + query-language-swtich + +
+ + +
+
+
+
+ +
-
spec click run button, and response is not ok 1`] = ` exports[`
spec click run button, and response is ok 1`] = `
- Data Sources -
-