forked from opensearch-project/OpenSearch-Dashboards
-
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.
Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
- Loading branch information
Showing
36 changed files
with
734 additions
and
246 deletions.
There are no files selected for viewing
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,2 @@ | ||
feat: | ||
- Add DataSet dropdown with index patterns and indices ([#7289](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7289)) |
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
16 changes: 16 additions & 0 deletions
16
src/plugins/data/public/ui/dataset_navigator/create_dataset_navigator.tsx
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,16 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { SavedObjectsClientContract } from 'src/core/public'; | ||
import { DataSetNavigator, DataSetNavigatorProps } from './'; | ||
|
||
// Updated function signature to include additional dependencies | ||
export function createDataSetNavigator(savedObjectsClient: SavedObjectsClientContract) { | ||
// Return a function that takes props, omitting the dependencies from the props type | ||
return (props: Omit<DataSetNavigatorProps, 'savedObjectsClient'>) => ( | ||
<DataSetNavigator {...props} savedObjectsClient={savedObjectsClient} /> | ||
); | ||
} |
175 changes: 175 additions & 0 deletions
175
src/plugins/data/public/ui/dataset_navigator/dataset_navigator copy.tsx
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,175 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
// import React, { Component, useEffect, useState } from 'react'; | ||
// import { EuiButtonEmpty, EuiContextMenu, EuiPopover } from '@elastic/eui'; | ||
// import { SavedObjectsClientContract } from 'opensearch-dashboards/public'; | ||
// import _ from 'lodash'; | ||
// import { i18n } from '@osd/i18n'; | ||
// import { IIndexPattern } from '../..'; | ||
// import { createDataFrame } from '../../../common/data_frames'; | ||
// import { fetchClusters } from './fetch_clusters'; | ||
// import { fetchIndices } from './fetch_indices'; | ||
// import { getSearchService } from '../../services'; | ||
|
||
// export interface DataSetOption { | ||
// id: string; | ||
// name: string; | ||
// dataSourceRef?: string; | ||
// } | ||
|
||
// export interface DataSetNavigatorProps { | ||
// dataSet: DataSetOption; | ||
// savedObjectsClient: SavedObjectsClientContract; | ||
// indexPatterns?: Array<IIndexPattern | string>; | ||
// } | ||
|
||
// interface DataSetNavigatorState { | ||
// isLoading: boolean; | ||
// indexPatterns: []; | ||
// dataSources: []; | ||
// externalDataSources: []; | ||
|
||
// searchValue: string | undefined; | ||
// } | ||
|
||
// // Needed for React.lazy | ||
// // eslint-disable-next-line import/no-default-export | ||
// export default class DataSetNavigator extends Component<DataSetNavigatorProps> { | ||
// private isMounted: boolean = false; | ||
// state: DataSetNavigatorState; | ||
// const indexPatternsLabel = i18n.translate('data.query.dataSetNavigator.indexPatternsName', { | ||
// defaultMessage: 'Index Patterns', | ||
// }); | ||
// const clustersLabel = i18n.translate('data.query.dataSetNavigator.clustersName', { | ||
// defaultMessage: 'Clusters', | ||
// }); | ||
// const [isOpen, setIsOpen] = useState(false); | ||
// const [clusterList, setClusterList] = useState<any>([]); | ||
// const [selectedCluster, setSelectedCluster] = useState<any>(null); | ||
// const [indexList, setIndexList] = useState<any>([]); | ||
// const [selectedDataSet, setSelectedDataSet] = useState<string>( | ||
// typeof props.indexPatterns?.[0] === 'string' | ||
// ? props.indexPatterns?.[0] | ||
// : props.indexPatterns?.[0]?.title ?? '' | ||
// ); | ||
|
||
// const search = getSearchService(); | ||
|
||
// const onButtonClick = () => setIsOpen(!isOpen); | ||
// const closePopover = () => setIsOpen(false); | ||
|
||
// const handleDataSetChange = (dataSet: IIndexPattern | string) => { | ||
// const dataSetTitle = typeof dataSet === 'string' ? dataSet : dataSet.title; | ||
// if (selectedCluster) { | ||
// setSelectedDataSet(`${selectedCluster.attributes.title}::${dataSetTitle}`); | ||
// } else { | ||
// setSelectedDataSet(dataSetTitle); | ||
// } | ||
// props.onSelectDataSet(dataSet); | ||
// closePopover(); | ||
// }; | ||
|
||
// useEffect(() => { | ||
// // Fetch clusters | ||
// fetchClusters(props.savedObjectsClient).then((res) => { | ||
// setClusterList(res.savedObjects); | ||
// }); | ||
// }, [props.savedObjectsClient, search, selectedCluster]); | ||
|
||
// useEffect(() => { | ||
// if (selectedCluster) { | ||
// // Fetch indices | ||
// fetchIndices(search, selectedCluster.id).then((res) => { | ||
// // Assuming res is the array to iterate over | ||
// const updatedRes = res.map((index: any) => ({ | ||
// ...index, | ||
// dataSourceRef: selectedCluster.id, | ||
// })); | ||
// setIndexList(updatedRes); | ||
// }); | ||
// } | ||
// }, [selectedCluster, search]); | ||
|
||
// return ( | ||
// <EuiPopover | ||
// button={ | ||
// <EuiButtonEmpty | ||
// className="dataExplorerDSSelect" | ||
// color="text" | ||
// iconType="arrowDown" | ||
// iconSide="right" | ||
// onClick={onButtonClick} | ||
// > | ||
// {selectedDataSet ? selectedDataSet : 'Select a DataSet'} | ||
// </EuiButtonEmpty> | ||
// } | ||
// isOpen={isOpen} | ||
// closePopover={closePopover} | ||
// anchorPosition="downLeft" | ||
// > | ||
// <EuiContextMenu | ||
// initialPanelId={0} | ||
// className="datasetNavigator" | ||
// panels={[ | ||
// { | ||
// id: 0, | ||
// title: 'DATA', | ||
// items: [ | ||
// { | ||
// name: indexPatternsLabel, | ||
// panel: 1, | ||
// }, | ||
// ...clusterList.map((cluster) => ({ | ||
// name: cluster.attributes.title, | ||
// panel: 2, | ||
// onClick: () => setSelectedCluster(cluster), | ||
// })), | ||
// ], | ||
// }, | ||
// { | ||
// id: 1, | ||
// title: indexPatternsLabel, | ||
// items: props.indexPatterns?.map((indexPattern) => ({ | ||
// name: typeof indexPattern === 'string' ? indexPattern : indexPattern.title, | ||
// onClick: () => { | ||
// setSelectedCluster(null); | ||
// handleDataSetChange(indexPattern); | ||
// }, | ||
// })), | ||
// }, | ||
// { | ||
// id: 2, | ||
// title: selectedCluster ? selectedCluster.attributes.title : 'Cluster', | ||
// items: [ | ||
// { | ||
// name: 'Indexes', | ||
// panel: 3, | ||
// }, | ||
// ], | ||
// }, | ||
// { | ||
// id: 3, | ||
// title: selectedCluster ? selectedCluster.attributes.title : 'Cluster', | ||
// items: indexList.map((index: any) => ({ | ||
// name: index.name, | ||
// onClick: async () => { | ||
// // const await search.df.set( | ||
// // createDataFrame({ | ||
// // name: index.name, | ||
// // meta: { queryConfig: { dataSource: selectedCluster } }, | ||
// // fields: [], | ||
// // }) | ||
// // ); | ||
// // TODO: should we just create an index pattern here with get fetch fields? | ||
// handleDataSetChange(index); | ||
// }, | ||
// })), | ||
// }, | ||
// ]} | ||
// /> | ||
// </EuiPopover> | ||
// ); | ||
// }; |
Oops, something went wrong.