Skip to content

Commit

Permalink
running linter
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Li <[email protected]>
  • Loading branch information
sejli committed Jul 18, 2024
1 parent 5533086 commit dd27499
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
4 changes: 4 additions & 0 deletions src/plugins/data/public/ui/query_editor/dataset_navigator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
38 changes: 10 additions & 28 deletions src/plugins/data_explorer/public/components/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataSourceOption[]>([]);
const [selectedCluster, setSelectedCluster] = useState<any>();
const [indexPatternOptionList, setIndexPatternOptionList] = useState<DataSourceOption[]>([]);
const [dataSourceOptionList, setDataSourceOptionList] = useState<DataSourceGroup[]>([]);
const [activeDataSources, setActiveDataSources] = useState<DataSource[]>([]);
const [isEnhancementsEnabled, setIsEnhancementsEnabled] = useState<boolean>(false);
Expand Down Expand Up @@ -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(
Expand All @@ -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]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit dd27499

Please sign in to comment.