From dd27499c1968e24ef553286484bce0ee99a5199d Mon Sep 17 00:00:00 2001 From: Sean Li Date: Thu, 18 Jul 2024 11:27:16 -0700 Subject: [PATCH] running linter Signed-off-by: Sean Li --- .../ui/query_editor/dataset_navigator.tsx | 4 ++ .../public/components/sidebar/index.tsx | 38 +++++-------------- .../utils/create_extension.tsx | 2 +- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/plugins/data/public/ui/query_editor/dataset_navigator.tsx b/src/plugins/data/public/ui/query_editor/dataset_navigator.tsx index e69de29bb2d..a850c1690e3 100644 --- a/src/plugins/data/public/ui/query_editor/dataset_navigator.tsx +++ b/src/plugins/data/public/ui/query_editor/dataset_navigator.tsx @@ -0,0 +1,4 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/src/plugins/data_explorer/public/components/sidebar/index.tsx b/src/plugins/data_explorer/public/components/sidebar/index.tsx index db2ac781bbf..f4c628a7d70 100644 --- a/src/plugins/data_explorer/public/components/sidebar/index.tsx +++ b/src/plugins/data_explorer/public/components/sidebar/index.tsx @@ -4,26 +4,19 @@ */ import React, { FC, useCallback, useEffect, useRef, useState } from 'react'; -import { EuiPageSideBar, EuiPortal, EuiSplitPanel } from '@elastic/eui'; +import { EuiPageSideBar, EuiSplitPanel } from '@elastic/eui'; import { i18n } from '@osd/i18n'; -import { DataSource, DataSourceGroup, DataSetNavigator, DataSourceSelectable } from '../../../../data/public'; +import { DataSource, DataSourceGroup, DataSourceSelectable } from '../../../../data/public'; import { DataSourceOption } from '../../../../data/public/'; import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public'; import { DataExplorerServices } from '../../types'; -import { - setIndexPattern, - setDataset, - useTypedDispatch, - useTypedSelector, -} from '../../utils/state_management'; +import { setIndexPattern, useTypedDispatch, useTypedSelector } from '../../utils/state_management'; import './index.scss'; export const Sidebar: FC = ({ children }) => { const { indexPattern: indexPatternId } = useTypedSelector((state) => state.metadata); const dispatch = useTypedDispatch(); const [selectedSources, setSelectedSources] = useState([]); - const [selectedCluster, setSelectedCluster] = useState(); - const [indexPatternOptionList, setIndexPatternOptionList] = useState([]); const [dataSourceOptionList, setDataSourceOptionList] = useState([]); const [activeDataSources, setActiveDataSources] = useState([]); const [isEnhancementsEnabled, setIsEnhancementsEnabled] = useState(false); @@ -100,21 +93,10 @@ export const Sidebar: FC = ({ children }) => { useEffect(() => { if (indexPatternId) { const option = getMatchedOption(dataSourceOptionList, indexPatternId); - setSelectedSources((prev) => option ? [option] : prev); + setSelectedSources((prev) => (option ? [option] : prev)); } }, [indexPatternId, activeDataSources, dataSourceOptionList]); - const getMatchedIndexPattern = (indexPatternList: DataSourceOption[], ipId: string) => { - return indexPatternList.find((indexPattern) => indexPattern.value === ipId); - }; - - useEffect(() => { - if (indexPatternId) { - const option = getMatchedIndexPattern(indexPatternOptionList, indexPatternId); - setSelectedSources((prev) => option ? [option] : prev); - } - }, [indexPatternId, activeDataSources, indexPatternOptionList]); - const redirectToLogExplorer = useCallback( (dsName: string, dsType: string) => { return application.navigateToUrl( @@ -130,14 +112,14 @@ export const Sidebar: FC = ({ children }) => { setSelectedSources(selectedDataSources); return; } + // Temporary redirection solution for 2.11, where clicking non-index-pattern data sources + // will prompt users with modal explaining they are being redirected to Observability log explorer + if (selectedDataSources[0]?.ds?.getType() !== 'DEFAULT_INDEX_PATTERNS') { + redirectToLogExplorer(selectedDataSources[0].label, selectedDataSources[0].type); + return; + } setSelectedSources(selectedDataSources); dispatch(setIndexPattern(selectedDataSources[0].value)); - // dispatch( - // setDataset({ - // id: selectedDataSources[0].value, - // datasource: { ref: selectedDataSources[0]?.ds?.getId() }, - // }) - // ); }, [dispatch, redirectToLogExplorer, setSelectedSources] ); diff --git a/src/plugins/query_enhancements/public/data_source_connection/utils/create_extension.tsx b/src/plugins/query_enhancements/public/data_source_connection/utils/create_extension.tsx index 5b3a603103b..0250c196d12 100644 --- a/src/plugins/query_enhancements/public/data_source_connection/utils/create_extension.tsx +++ b/src/plugins/query_enhancements/public/data_source_connection/utils/create_extension.tsx @@ -5,11 +5,11 @@ import React from 'react'; import { ToastsSetup } from 'opensearch-dashboards/public'; +import { of } from 'rxjs'; import { QueryEditorExtensionConfig } from '../../../../data/public'; import { ConfigSchema } from '../../../common/config'; import { ConnectionsBar } from '../components'; import { ConnectionsService } from '../services'; -import { of } from 'rxjs'; export const createDataSourceConnectionExtension = ( connectionsService: ConnectionsService,