forked from opensearch-project/dashboards-query-workbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the skipping index queries, covering index queries,updates the … (
opensearch-project#134) * added the skipping index queries, covering index queries,updates the data picker Signed-off-by: sumukhswamy <[email protected]> * added the skipping index queries, covering index queries,updates the data picker Signed-off-by: sumukhswamy <[email protected]> * reverted updates to yarn Signed-off-by: sumukhswamy <[email protected]> * updated tests, snapshots Signed-off-by: sumukhswamy <[email protected]> --------- Signed-off-by: sumukhswamy <[email protected]>
- Loading branch information
1 parent
ebf9dab
commit 0330447
Showing
13 changed files
with
419 additions
and
391 deletions.
There are no files selected for viewing
268 changes: 36 additions & 232 deletions
268
public/components/Main/__snapshots__/main.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { CoreStart } from '../../../../../src/core/public'; | ||
|
||
interface CustomView { | ||
http: CoreStart['http']; | ||
onSelect: (selectedItems: []) => void; | ||
} | ||
|
||
export const DataSelect = ({ http, onSelect }: CustomView) => { | ||
const [selectedOptions, setSelectedOptions] = useState<EuiComboBoxOptionOption[]>([{ label: 'OpenSearch' }]); | ||
const [options, setOptions] = useState<any[]>([]); | ||
|
||
const datasources = () => { | ||
http | ||
.get(`/api/get_datasources`) | ||
.then((res) => { | ||
const data = res.data.resp; | ||
|
||
const connectorGroups = {}; | ||
|
||
data.forEach((item) => { | ||
const connector = item.connector; | ||
const name = item.name; | ||
|
||
if (connector === 'S3GLUE') { | ||
if (!connectorGroups[connector]) { | ||
connectorGroups[connector] = []; | ||
} | ||
|
||
connectorGroups[connector].push(name); | ||
} | ||
}); | ||
options.push({ label: 'OpenSearch' }); | ||
for (const connector in connectorGroups) { | ||
if (connectorGroups.hasOwnProperty(connector)) { | ||
const connectorNames = connectorGroups[connector]; | ||
|
||
options.push({ | ||
label: connector, | ||
options: connectorNames.map((name) => ({ label: name })), | ||
}); | ||
} | ||
} | ||
|
||
setOptions(options); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
datasources(); | ||
}, []); | ||
|
||
const handleSelectionChange = (selectedItems: any[]) => { | ||
setSelectedOptions(selectedItems); | ||
onSelect(selectedItems); | ||
}; | ||
|
||
return ( | ||
<EuiComboBox | ||
singleSelection={{ asPlainText: true }} | ||
isClearable={false} | ||
options={options} | ||
selectedOptions={selectedOptions} | ||
onChange={(selectedItems) => handleSelectionChange(selectedItems)} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.