From 08b89b905591a70b3c512bca879cfdad8bd7b333 Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Mon, 20 May 2024 14:59:37 -0700 Subject: [PATCH 01/11] remove s3 data source redirection to use discover implementation Signed-off-by: Paul Sebastian --- .../datasource_selectable.tsx | 8 +------ .../public/components/sidebar/index.tsx | 21 ++++--------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx b/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx index 51ee0bb25b41..48216f8da735 100644 --- a/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx +++ b/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx @@ -68,18 +68,12 @@ const addOrUpdateGroup = ( ) => { const metadata = dataSource.getMetadata(); const groupType = metadata.ui.groupType; - let groupName = + const groupName = metadata.ui.typeLabel || i18n.translate('dataExplorer.dataSourceSelector.defaultGroupTitle', { defaultMessage: 'Default Group', }); - if (dataSource.getType() !== 'DEFAULT_INDEX_PATTERNS') { - groupName += i18n.translate('dataExplorer.dataSourceSelector.redirectionHint', { - defaultMessage: DATA_SELECTOR_S3_DATA_SOURCE_GROUP_HINT_LABEL, - }); - } - const group = existingGroups.find((g: DataSourceGroup) => g.id === groupType); if (group && !group.options.some((opt) => opt.key === option.key)) { group.options.push(option); diff --git a/src/plugins/data_explorer/public/components/sidebar/index.tsx b/src/plugins/data_explorer/public/components/sidebar/index.tsx index d36c4111a5b1..f765972b711d 100644 --- a/src/plugins/data_explorer/public/components/sidebar/index.tsx +++ b/src/plugins/data_explorer/public/components/sidebar/index.tsx @@ -25,7 +25,6 @@ export const Sidebar: FC = ({ children }) => { services: { data: { indexPatterns, dataSources, ui }, notifications: { toasts }, - application, }, } = useOpenSearchDashboards(); @@ -77,31 +76,19 @@ export const Sidebar: FC = ({ children }) => { } }, [indexPatternId, activeDataSources, dataSourceOptionList]); - const redirectToLogExplorer = useCallback( - (dsName: string, dsType: string) => { - return application.navigateToUrl( - `../observability-logs#/explorer?datasourceName=${dsName}&datasourceType=${dsType}` - ); - }, - [application] - ); - const handleSourceSelection = useCallback( (selectedDataSources: DataSourceOption[]) => { if (selectedDataSources.length === 0) { 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); + // if the datasource is default: dispatch(setIndexPattern(selectedDataSources[0].value)); + // if the datasource is s3: + // see what setting the index pattern does, maybe it also changes some thing we want to change, like selected "name" in query bar }, - [dispatch, redirectToLogExplorer, setSelectedSources] + [dispatch, setSelectedSources] ); const handleGetDataSetError = useCallback( From 230e7fc691583e3aa6968a07f792fdd7bbd0fa2a Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Fri, 24 May 2024 09:19:31 -0700 Subject: [PATCH 02/11] selected data source gives polling option if needed Signed-off-by: Paul Sebastian --- src/plugins/data/common/constants.ts | 4 ++ .../data/public/data_sources/constants.tsx | 1 - .../datasource_selectable.tsx | 1 - .../public/components/sidebar/index.tsx | 16 ++++++-- .../utils/state_management/metadata_slice.ts | 12 +++++- .../helpers/get_data_source_fetch_strategy.ts | 39 +++++++++++++++++++ .../utils/use_index_pattern.ts | 3 +- .../view_components/utils/use_search.ts | 5 ++- 8 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts diff --git a/src/plugins/data/common/constants.ts b/src/plugins/data/common/constants.ts index 27cfc64cf2f6..a80c4e4df881 100644 --- a/src/plugins/data/common/constants.ts +++ b/src/plugins/data/common/constants.ts @@ -30,6 +30,10 @@ export const DEFAULT_QUERY_LANGUAGE = 'kuery'; +// to resolve: copies constants from src/plugins/data/public/data_sources/constants.tsx, should it be removed from there? +export const S3_GLUE_DATA_SOURCE_TYPE = 's3glue'; +export const DEFAULT_DATA_SOURCE_TYPE = 'DEFAULT_INDEX_PATTERNS'; + export const UI_SETTINGS = { META_FIELDS: 'metaFields', DOC_HIGHLIGHT: 'doc_table:highlight', diff --git a/src/plugins/data/public/data_sources/constants.tsx b/src/plugins/data/public/data_sources/constants.tsx index eb0a0cfb0ac8..42b60bf0f2d1 100644 --- a/src/plugins/data/public/data_sources/constants.tsx +++ b/src/plugins/data/public/data_sources/constants.tsx @@ -43,4 +43,3 @@ export const s3DataSourceMetadata = { export const DATA_SELECTOR_REFRESHER_POPOVER_TEXT = 'Refresh data selector'; export const DATA_SELECTOR_DEFAULT_PLACEHOLDER = 'Select a data source'; -export const DATA_SELECTOR_S3_DATA_SOURCE_GROUP_HINT_LABEL = ' - Opens in Log Explorer'; diff --git a/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx b/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx index 48216f8da735..3a8383b5c6db 100644 --- a/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx +++ b/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx @@ -12,7 +12,6 @@ import { DataSelectorRefresher } from './data_selector_refresher'; import { DATA_SELECTOR_DEFAULT_PLACEHOLDER, DATA_SELECTOR_REFRESHER_POPOVER_TEXT, - DATA_SELECTOR_S3_DATA_SOURCE_GROUP_HINT_LABEL, } from '../constants'; // Asynchronously retrieves and formats dataset from a given data source. diff --git a/src/plugins/data_explorer/public/components/sidebar/index.tsx b/src/plugins/data_explorer/public/components/sidebar/index.tsx index f765972b711d..77205196cb48 100644 --- a/src/plugins/data_explorer/public/components/sidebar/index.tsx +++ b/src/plugins/data_explorer/public/components/sidebar/index.tsx @@ -12,6 +12,8 @@ import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react import { DataExplorerServices } from '../../types'; import { setIndexPattern, useTypedDispatch, useTypedSelector } from '../../utils/state_management'; import './index.scss'; +import { DEFAULT_DATA_SOURCE_TYPE, S3_GLUE_DATA_SOURCE_TYPE } from '../../../../data/common'; +import { setDataSourceType } from '../../utils/state_management/metadata_slice'; export const Sidebar: FC = ({ children }) => { const { indexPattern: indexPatternId } = useTypedSelector((state) => state.metadata); @@ -83,10 +85,16 @@ export const Sidebar: FC = ({ children }) => { return; } setSelectedSources(selectedDataSources); - // if the datasource is default: - dispatch(setIndexPattern(selectedDataSources[0].value)); - // if the datasource is s3: - // see what setting the index pattern does, maybe it also changes some thing we want to change, like selected "name" in query bar + + switch (selectedDataSources[0].type) { + case DEFAULT_DATA_SOURCE_TYPE: // need to make sure we have a constant here - common with data source types + dispatch(setIndexPattern(selectedDataSources[0].value)); + dispatch(setDataSourceType(DEFAULT_DATA_SOURCE_TYPE)); + break; + case S3_GLUE_DATA_SOURCE_TYPE: + dispatch(setDataSourceType(S3_GLUE_DATA_SOURCE_TYPE)); + break; + } }, [dispatch, setSelectedSources] ); diff --git a/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts b/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts index e9fe84713120..1dbda4743387 100644 --- a/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts +++ b/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts @@ -8,6 +8,7 @@ import { DataExplorerServices } from '../../types'; export interface MetadataState { indexPattern?: string; + dataSourceType?: string; originatingApp?: string; view?: string; } @@ -40,6 +41,9 @@ export const slice = createSlice({ setIndexPattern: (state, action: PayloadAction) => { state.indexPattern = action.payload; }, + setDataSourceType: (state, action: PayloadAction) => { + state.dataSourceType = action.payload; + }, setOriginatingApp: (state, action: PayloadAction) => { state.originatingApp = action.payload; }, @@ -53,4 +57,10 @@ export const slice = createSlice({ }); export const { reducer } = slice; -export const { setIndexPattern, setOriginatingApp, setView, setState } = slice.actions; +export const { + setIndexPattern, + setDataSourceType, + setOriginatingApp, + setView, + setState, +} = slice.actions; diff --git a/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts b/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts new file mode 100644 index 000000000000..2dafa6818587 --- /dev/null +++ b/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts @@ -0,0 +1,39 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + * + * Any modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Returns a polling strategy based off of the data source type, which is meant to be given as + * an option during fetching. + */ + +export function dataSourceFetchingStrategy(dataSource: string): string { + if (dataSource === 's3glue') return 'polling'; + return 'default'; +} diff --git a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts index e8a81234278e..7ed3b2128862 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts @@ -28,6 +28,7 @@ export const useIndexPattern = (services: DiscoverViewServices) => { const indexPatternIdFromState = useSelector((state) => state.metadata.indexPattern); const [indexPattern, setIndexPattern] = useState(undefined); const { data, toastNotifications, uiSettings: config, store } = services; + const dataSourceType = useSelector((state) => state.metadata.dataSourceType); useEffect(() => { let isMounted = true; @@ -73,5 +74,5 @@ export const useIndexPattern = (services: DiscoverViewServices) => { }; }, [indexPatternIdFromState, data.indexPatterns, toastNotifications, config, store]); - return indexPattern; + return { indexPattern, dataSourceType }; }; diff --git a/src/plugins/discover/public/application/view_components/utils/use_search.ts b/src/plugins/discover/public/application/view_components/utils/use_search.ts index 9da9704f32a7..a9fc9808f52c 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_search.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_search.ts @@ -31,6 +31,7 @@ import { getResponseInspectorStats, } from '../../../opensearch_dashboards_services'; import { SEARCH_ON_PAGE_LOAD_SETTING } from '../../../../common'; +import { dataSourceFetchingStrategy } from '../../helpers/get_data_source_fetch_strategy'; export enum ResultStatus { UNINITIALIZED = 'uninitialized', @@ -72,7 +73,7 @@ export const useSearch = (services: DiscoverViewServices) => { const [savedSearch, setSavedSearch] = useState(undefined); const { savedSearch: savedSearchId, sort, interval } = useSelector((state) => state.discover); const { data, filterManager, getSavedSearchById, core, toastNotifications, chrome } = services; - const indexPattern = useIndexPattern(services); + const { indexPattern, dataSourceType } = useIndexPattern(services); const timefilter = data.query.timefilter.timefilter; const fetchStateRef = useRef<{ abortController: AbortController | undefined; @@ -161,6 +162,7 @@ export const useSearch = (services: DiscoverViewServices) => { const fetchResp = await searchSource.fetch({ abortSignal: fetchStateRef.current.abortController.signal, withLongNumeralsSupport: true, + strategy: dataSourceFetchingStrategy(dataSourceType ?? ''), }); inspectorRequest @@ -220,6 +222,7 @@ export const useSearch = (services: DiscoverViewServices) => { } }, [ indexPattern, + dataSourceType, interval, timefilter, toastNotifications, From 3b9d7c6ac0c9446d8edcb865c208eb0922ba91e1 Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Tue, 28 May 2024 10:24:59 -0700 Subject: [PATCH 03/11] update license Signed-off-by: Paul Sebastian --- .../helpers/get_data_source_fetch_strategy.ts | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts b/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts index 2dafa6818587..735fb1cf1c2e 100644 --- a/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts +++ b/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts @@ -1,31 +1,6 @@ /* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Any modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. */ /** From 179c0cf9c2384ceaf87aa7801454cc20bf19e3fc Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Tue, 4 Jun 2024 09:46:45 -0700 Subject: [PATCH 04/11] pass whole datasource through cycle to interceptor and also into search params Signed-off-by: Paul Sebastian --- .../search_source/fetch/get_search_params.ts | 2 ++ .../common/search/search_source/search_source.ts | 2 +- .../data/common/search/search_source/types.ts | 2 ++ .../public/data_sources/datasource/datasource.ts | 6 ++++++ .../data/public/data_sources/datasource/types.ts | 1 + .../datasource_selector/datasource_selectable.tsx | 1 + .../data_sources/datasource_selector/types.ts | 1 + .../default_datasource/default_datasource.ts | 11 +++++++++-- .../data_sources/register_default_datasource.ts | 1 + .../public/components/sidebar/index.tsx | 15 +++++++-------- .../utils/state_management/metadata_slice.ts | 9 +++++---- .../view_components/utils/update_search_source.ts | 4 ++++ .../view_components/utils/use_index_pattern.ts | 4 ++-- .../view_components/utils/use_search.ts | 7 +++---- 14 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/plugins/data/common/search/search_source/fetch/get_search_params.ts b/src/plugins/data/common/search/search_source/fetch/get_search_params.ts index d9bd7721d6cb..2d6efee345b5 100644 --- a/src/plugins/data/common/search/search_source/fetch/get_search_params.ts +++ b/src/plugins/data/common/search/search_source/fetch/get_search_params.ts @@ -60,9 +60,11 @@ export function getExternalSearchParamsFromRequest( const searchParams = getSearchParams(getConfig); const dataFrame = getDataFrame(); const indexTitle = searchRequest.index.title || searchRequest.index; + const dataSource = searchRequest.dataSource; return { index: indexTitle, + dataSource, body: { ...searchRequest.body, ...(dataFrame && dataFrame?.name === indexTitle ? { df: dataFrame } : {}), diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts index b7dc48b404b6..588233f30af7 100644 --- a/src/plugins/data/common/search/search_source/search_source.ts +++ b/src/plugins/data/common/search/search_source/search_source.ts @@ -506,6 +506,7 @@ export class SearchSource { const fields = uniq((data[key] || []).concat(val)); return addToRoot(key, fields); case 'index': + case 'dataSource': case 'type': case 'highlightAll': return key && data[key] == null && addToRoot(key, val); @@ -551,7 +552,6 @@ export class SearchSource { flatten() { const searchRequest = this.mergeProps(); - searchRequest.body = searchRequest.body || {}; const { body, index, fields, query, filters, highlightAll } = searchRequest; searchRequest.indexType = this.getIndexType(index); diff --git a/src/plugins/data/common/search/search_source/types.ts b/src/plugins/data/common/search/search_source/types.ts index 9f3fd75e1ce9..56ee8e517c81 100644 --- a/src/plugins/data/common/search/search_source/types.ts +++ b/src/plugins/data/common/search/search_source/types.ts @@ -29,6 +29,7 @@ */ import { NameList } from 'elasticsearch'; +import { DataSource } from 'src/plugins/data/public'; import { Filter, IDataFrame, IndexPattern, Query } from '../..'; import { SearchSource } from './search_source'; @@ -104,6 +105,7 @@ export interface SearchSourceFields { timeout?: string; terminate_after?: number; df?: IDataFrame; + dataSource: DataSource; } export interface SearchSourceOptions { diff --git a/src/plugins/data/public/data_sources/datasource/datasource.ts b/src/plugins/data/public/data_sources/datasource/datasource.ts index bcff4d0d6cc7..192540386434 100644 --- a/src/plugins/data/public/data_sources/datasource/datasource.ts +++ b/src/plugins/data/public/data_sources/datasource/datasource.ts @@ -36,12 +36,14 @@ export abstract class DataSource< private readonly id: string; private readonly name: string; private readonly type: string; + private readonly connectionType: 'os' | 'flint'; private readonly metadata: TMetadata; constructor(settings: IDataSourceSettings) { this.id = settings.id; this.name = settings.name; this.type = settings.type; + this.connectionType = settings.connectionType; this.metadata = settings.metadata; } @@ -61,6 +63,10 @@ export abstract class DataSource< return this.metadata; } + getConnectionType() { + return this.connectionType; + } + /** * Abstract method to get the dataset associated with the data source. * Implementing classes need to provide the specific implementation. diff --git a/src/plugins/data/public/data_sources/datasource/types.ts b/src/plugins/data/public/data_sources/datasource/types.ts index 74a670573898..3d1f3eb75b9d 100644 --- a/src/plugins/data/public/data_sources/datasource/types.ts +++ b/src/plugins/data/public/data_sources/datasource/types.ts @@ -51,6 +51,7 @@ export interface IDataSourceSettings { const baseOption = { type: dataSource.getType(), + connectionType: dataSource.getConnectionType(), name: dataSource.getName(), ds: dataSource, }; diff --git a/src/plugins/data/public/data_sources/datasource_selector/types.ts b/src/plugins/data/public/data_sources/datasource_selector/types.ts index fe1e4360e961..267cb45525f6 100644 --- a/src/plugins/data/public/data_sources/datasource_selector/types.ts +++ b/src/plugins/data/public/data_sources/datasource_selector/types.ts @@ -23,6 +23,7 @@ export interface DataSourceOption { label: string; value: string; type: string; + connectionType: 'os' | 'flint'; ds: DataSource; } diff --git a/src/plugins/data/public/data_sources/default_datasource/default_datasource.ts b/src/plugins/data/public/data_sources/default_datasource/default_datasource.ts index db65a7df903d..8a6241e20849 100644 --- a/src/plugins/data/public/data_sources/default_datasource/default_datasource.ts +++ b/src/plugins/data/public/data_sources/default_datasource/default_datasource.ts @@ -36,8 +36,15 @@ export class DefaultDslDataSource extends DataSource< > { private readonly indexPatterns: IndexPatternsContract; - constructor({ id, name, type, metadata, indexPatterns }: LocalDataSourceSettings) { - super({ id, name, type, metadata }); + constructor({ + id, + name, + type, + connectionType, + metadata, + indexPatterns, + }: LocalDataSourceSettings) { + super({ id, name, type, connectionType, metadata }); this.indexPatterns = indexPatterns; } diff --git a/src/plugins/data/public/data_sources/register_default_datasource.ts b/src/plugins/data/public/data_sources/register_default_datasource.ts index d8ae19114c3c..c69947cf35c2 100644 --- a/src/plugins/data/public/data_sources/register_default_datasource.ts +++ b/src/plugins/data/public/data_sources/register_default_datasource.ts @@ -25,6 +25,7 @@ export const registerDefaultDataSource = (data: Omit { const { indexPattern: indexPatternId } = useTypedSelector((state) => state.metadata); @@ -80,19 +80,18 @@ export const Sidebar: FC = ({ children }) => { const handleSourceSelection = useCallback( (selectedDataSources: DataSourceOption[]) => { + setSelectedSources(selectedDataSources); if (selectedDataSources.length === 0) { - setSelectedSources(selectedDataSources); return; } - setSelectedSources(selectedDataSources); - switch (selectedDataSources[0].type) { - case DEFAULT_DATA_SOURCE_TYPE: // need to make sure we have a constant here - common with data source types + switch (selectedDataSources[0].connectionType) { + case 'os': // need to make sure we have a constant here - common with data source types dispatch(setIndexPattern(selectedDataSources[0].value)); - dispatch(setDataSourceType(DEFAULT_DATA_SOURCE_TYPE)); + dispatch(setDataSource(selectedDataSources[0].ds)); break; - case S3_GLUE_DATA_SOURCE_TYPE: - dispatch(setDataSourceType(S3_GLUE_DATA_SOURCE_TYPE)); + case 'flint': + dispatch(setDataSource(selectedDataSources[0].ds)); break; } }, diff --git a/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts b/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts index 1dbda4743387..f8e352f73c2e 100644 --- a/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts +++ b/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts @@ -4,11 +4,12 @@ */ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import { DataSource } from 'src/plugins/data/public'; import { DataExplorerServices } from '../../types'; export interface MetadataState { indexPattern?: string; - dataSourceType?: string; + dataSource?: DataSource; originatingApp?: string; view?: string; } @@ -41,8 +42,8 @@ export const slice = createSlice({ setIndexPattern: (state, action: PayloadAction) => { state.indexPattern = action.payload; }, - setDataSourceType: (state, action: PayloadAction) => { - state.dataSourceType = action.payload; + setDataSource: (state, action: PayloadAction) => { + state.dataSource = action.payload; }, setOriginatingApp: (state, action: PayloadAction) => { state.originatingApp = action.payload; @@ -59,7 +60,7 @@ export const slice = createSlice({ export const { reducer } = slice; export const { setIndexPattern, - setDataSourceType, + setDataSource, setOriginatingApp, setView, setState, diff --git a/src/plugins/discover/public/application/view_components/utils/update_search_source.ts b/src/plugins/discover/public/application/view_components/utils/update_search_source.ts index a8480fdad18a..981ff7ef2264 100644 --- a/src/plugins/discover/public/application/view_components/utils/update_search_source.ts +++ b/src/plugins/discover/public/application/view_components/utils/update_search_source.ts @@ -8,6 +8,7 @@ import { ISearchSource, indexPatterns as indexPatternUtils, AggConfigs, + DataSource, } from '../../../../../data/public'; import { DiscoverServices } from '../../../build_services'; import { SortOrder } from '../../../saved_searches/types'; @@ -15,6 +16,7 @@ import { getSortForSearchSource } from './get_sort_for_search_source'; import { SORT_DEFAULT_ORDER_SETTING, SAMPLE_SIZE_SETTING } from '../../../../common'; interface Props { + dataSource: DataSource | undefined; indexPattern: IndexPattern; services: DiscoverServices; sort: SortOrder[] | undefined; @@ -23,6 +25,7 @@ interface Props { } export const updateSearchSource = async ({ + dataSource, indexPattern, services, searchSource, @@ -67,6 +70,7 @@ export const updateSearchSource = async ({ searchSourceInstance.setParent(timeRangeSearchSource); searchSourceInstance.setFields({ + dataSource, index: dataSet, sort: sortForSearchSource, size, diff --git a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts index 7ed3b2128862..b9040bb87855 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts @@ -28,7 +28,7 @@ export const useIndexPattern = (services: DiscoverViewServices) => { const indexPatternIdFromState = useSelector((state) => state.metadata.indexPattern); const [indexPattern, setIndexPattern] = useState(undefined); const { data, toastNotifications, uiSettings: config, store } = services; - const dataSourceType = useSelector((state) => state.metadata.dataSourceType); + const dataSource = useSelector((state) => state.metadata.dataSource); useEffect(() => { let isMounted = true; @@ -74,5 +74,5 @@ export const useIndexPattern = (services: DiscoverViewServices) => { }; }, [indexPatternIdFromState, data.indexPatterns, toastNotifications, config, store]); - return { indexPattern, dataSourceType }; + return { indexPattern, dataSource }; }; diff --git a/src/plugins/discover/public/application/view_components/utils/use_search.ts b/src/plugins/discover/public/application/view_components/utils/use_search.ts index a9fc9808f52c..7dec3546f2df 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_search.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_search.ts @@ -31,7 +31,6 @@ import { getResponseInspectorStats, } from '../../../opensearch_dashboards_services'; import { SEARCH_ON_PAGE_LOAD_SETTING } from '../../../../common'; -import { dataSourceFetchingStrategy } from '../../helpers/get_data_source_fetch_strategy'; export enum ResultStatus { UNINITIALIZED = 'uninitialized', @@ -73,7 +72,7 @@ export const useSearch = (services: DiscoverViewServices) => { const [savedSearch, setSavedSearch] = useState(undefined); const { savedSearch: savedSearchId, sort, interval } = useSelector((state) => state.discover); const { data, filterManager, getSavedSearchById, core, toastNotifications, chrome } = services; - const { indexPattern, dataSourceType } = useIndexPattern(services); + const { indexPattern, dataSource } = useIndexPattern(services); const timefilter = data.query.timefilter.timefilter; const fetchStateRef = useRef<{ abortController: AbortController | undefined; @@ -129,6 +128,7 @@ export const useSearch = (services: DiscoverViewServices) => { ? createHistogramConfigs(dataSet, interval || 'auto', data) : undefined; const searchSource = await updateSearchSource({ + dataSource, indexPattern: dataSet, services, sort, @@ -162,7 +162,6 @@ export const useSearch = (services: DiscoverViewServices) => { const fetchResp = await searchSource.fetch({ abortSignal: fetchStateRef.current.abortController.signal, withLongNumeralsSupport: true, - strategy: dataSourceFetchingStrategy(dataSourceType ?? ''), }); inspectorRequest @@ -222,7 +221,7 @@ export const useSearch = (services: DiscoverViewServices) => { } }, [ indexPattern, - dataSourceType, + dataSource, interval, timefilter, toastNotifications, From d61a054b77194f9eb3bd90687aa077386ac8c02f Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Tue, 4 Jun 2024 10:01:16 -0700 Subject: [PATCH 05/11] remove strategy fetcher Signed-off-by: Paul Sebastian --- .../helpers/get_data_source_fetch_strategy.ts | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts diff --git a/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts b/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts deleted file mode 100644 index 735fb1cf1c2e..000000000000 --- a/src/plugins/discover/public/application/helpers/get_data_source_fetch_strategy.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * Returns a polling strategy based off of the data source type, which is meant to be given as - * an option during fetching. - */ - -export function dataSourceFetchingStrategy(dataSource: string): string { - if (dataSource === 's3glue') return 'polling'; - return 'default'; -} From bd835f6d7b0711f61d13b9b1f09fffbc7a531689 Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Tue, 4 Jun 2024 10:26:09 -0700 Subject: [PATCH 06/11] disable showing all index patterns Signed-off-by: Paul Sebastian --- .../data/public/data_sources/register_default_datasource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/public/data_sources/register_default_datasource.ts b/src/plugins/data/public/data_sources/register_default_datasource.ts index c69947cf35c2..1d5570ebfbea 100644 --- a/src/plugins/data/public/data_sources/register_default_datasource.ts +++ b/src/plugins/data/public/data_sources/register_default_datasource.ts @@ -32,7 +32,7 @@ export const registerDefaultDataSource = (data: Omit Date: Tue, 4 Jun 2024 11:15:26 -0700 Subject: [PATCH 07/11] remove unused constants Signed-off-by: Paul Sebastian --- src/plugins/data/common/constants.ts | 4 ---- src/plugins/data_explorer/public/components/sidebar/index.tsx | 1 - 2 files changed, 5 deletions(-) diff --git a/src/plugins/data/common/constants.ts b/src/plugins/data/common/constants.ts index a80c4e4df881..27cfc64cf2f6 100644 --- a/src/plugins/data/common/constants.ts +++ b/src/plugins/data/common/constants.ts @@ -30,10 +30,6 @@ export const DEFAULT_QUERY_LANGUAGE = 'kuery'; -// to resolve: copies constants from src/plugins/data/public/data_sources/constants.tsx, should it be removed from there? -export const S3_GLUE_DATA_SOURCE_TYPE = 's3glue'; -export const DEFAULT_DATA_SOURCE_TYPE = 'DEFAULT_INDEX_PATTERNS'; - export const UI_SETTINGS = { META_FIELDS: 'metaFields', DOC_HIGHLIGHT: 'doc_table:highlight', diff --git a/src/plugins/data_explorer/public/components/sidebar/index.tsx b/src/plugins/data_explorer/public/components/sidebar/index.tsx index f2215c1b6108..649cfaa176b5 100644 --- a/src/plugins/data_explorer/public/components/sidebar/index.tsx +++ b/src/plugins/data_explorer/public/components/sidebar/index.tsx @@ -12,7 +12,6 @@ import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react import { DataExplorerServices } from '../../types'; import { setIndexPattern, useTypedDispatch, useTypedSelector } from '../../utils/state_management'; import './index.scss'; -import { DEFAULT_DATA_SOURCE_TYPE, S3_GLUE_DATA_SOURCE_TYPE } from '../../../../data/common'; import { setDataSource } from '../../utils/state_management/metadata_slice'; export const Sidebar: FC = ({ children }) => { From 1e6ef88ab3532cdb01f1cc45744aea17d5fdc57d Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Tue, 4 Jun 2024 16:42:26 -0700 Subject: [PATCH 08/11] remove os and flint references Signed-off-by: Paul Sebastian --- .../common/search/search_source/search_source.ts | 1 + .../data/public/data_sources/constants.tsx | 15 +-------------- .../public/data_sources/datasource/datasource.ts | 5 ----- .../data/public/data_sources/datasource/types.ts | 1 - .../datasource_selector/datasource_selectable.tsx | 1 - .../data_sources/datasource_selector/types.ts | 1 - .../default_datasource/default_datasource.ts | 11 ++--------- .../data_sources/register_default_datasource.ts | 1 - .../public/components/sidebar/index.tsx | 13 +++++-------- 9 files changed, 9 insertions(+), 40 deletions(-) diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts index 588233f30af7..93ffeeec08af 100644 --- a/src/plugins/data/common/search/search_source/search_source.ts +++ b/src/plugins/data/common/search/search_source/search_source.ts @@ -552,6 +552,7 @@ export class SearchSource { flatten() { const searchRequest = this.mergeProps(); + searchRequest.body = searchRequest.body || {}; const { body, index, fields, query, filters, highlightAll } = searchRequest; searchRequest.indexType = this.getIndexType(index); diff --git a/src/plugins/data/public/data_sources/constants.tsx b/src/plugins/data/public/data_sources/constants.tsx index 42b60bf0f2d1..990fe11bdbbe 100644 --- a/src/plugins/data/public/data_sources/constants.tsx +++ b/src/plugins/data/public/data_sources/constants.tsx @@ -6,9 +6,7 @@ import { i18n } from '@osd/i18n'; import { DataSourceUIGroupType } from './datasource/types'; -export const S3_GLUE_DATA_SOURCE_DISPLAY_NAME = 'Amazon S3'; -export const S3_GLUE_DATA_SOURCE_TYPE = 's3glue'; -export const DEFAULT_DATA_SOURCE_TYPE = 'DEFAULT_INDEX_PATTERNS'; +export const DEFAULT_DATA_SOURCE_TYPE = 'default'; export const DEFAULT_DATA_SOURCE_NAME = i18n.translate('data.datasource.type.openSearchDefault', { defaultMessage: 'OpenSearch Default', }); @@ -30,16 +28,5 @@ export const defaultDataSourceMetadata = { }, }; -export const s3DataSourceMetadata = { - ui: { - label: S3_GLUE_DATA_SOURCE_DISPLAY_NAME, - typeLabel: S3_GLUE_DATA_SOURCE_TYPE, - groupType: DataSourceUIGroupType.s3glue, - selector: { - displayDatasetsAsSource: false, - }, - }, -}; - export const DATA_SELECTOR_REFRESHER_POPOVER_TEXT = 'Refresh data selector'; export const DATA_SELECTOR_DEFAULT_PLACEHOLDER = 'Select a data source'; diff --git a/src/plugins/data/public/data_sources/datasource/datasource.ts b/src/plugins/data/public/data_sources/datasource/datasource.ts index 192540386434..2f66caecb33b 100644 --- a/src/plugins/data/public/data_sources/datasource/datasource.ts +++ b/src/plugins/data/public/data_sources/datasource/datasource.ts @@ -36,7 +36,6 @@ export abstract class DataSource< private readonly id: string; private readonly name: string; private readonly type: string; - private readonly connectionType: 'os' | 'flint'; private readonly metadata: TMetadata; constructor(settings: IDataSourceSettings) { @@ -63,10 +62,6 @@ export abstract class DataSource< return this.metadata; } - getConnectionType() { - return this.connectionType; - } - /** * Abstract method to get the dataset associated with the data source. * Implementing classes need to provide the specific implementation. diff --git a/src/plugins/data/public/data_sources/datasource/types.ts b/src/plugins/data/public/data_sources/datasource/types.ts index 3d1f3eb75b9d..74a670573898 100644 --- a/src/plugins/data/public/data_sources/datasource/types.ts +++ b/src/plugins/data/public/data_sources/datasource/types.ts @@ -51,7 +51,6 @@ export interface IDataSourceSettings { const baseOption = { type: dataSource.getType(), - connectionType: dataSource.getConnectionType(), name: dataSource.getName(), ds: dataSource, }; diff --git a/src/plugins/data/public/data_sources/datasource_selector/types.ts b/src/plugins/data/public/data_sources/datasource_selector/types.ts index 267cb45525f6..fe1e4360e961 100644 --- a/src/plugins/data/public/data_sources/datasource_selector/types.ts +++ b/src/plugins/data/public/data_sources/datasource_selector/types.ts @@ -23,7 +23,6 @@ export interface DataSourceOption { label: string; value: string; type: string; - connectionType: 'os' | 'flint'; ds: DataSource; } diff --git a/src/plugins/data/public/data_sources/default_datasource/default_datasource.ts b/src/plugins/data/public/data_sources/default_datasource/default_datasource.ts index 8a6241e20849..db65a7df903d 100644 --- a/src/plugins/data/public/data_sources/default_datasource/default_datasource.ts +++ b/src/plugins/data/public/data_sources/default_datasource/default_datasource.ts @@ -36,15 +36,8 @@ export class DefaultDslDataSource extends DataSource< > { private readonly indexPatterns: IndexPatternsContract; - constructor({ - id, - name, - type, - connectionType, - metadata, - indexPatterns, - }: LocalDataSourceSettings) { - super({ id, name, type, connectionType, metadata }); + constructor({ id, name, type, metadata, indexPatterns }: LocalDataSourceSettings) { + super({ id, name, type, metadata }); this.indexPatterns = indexPatterns; } diff --git a/src/plugins/data/public/data_sources/register_default_datasource.ts b/src/plugins/data/public/data_sources/register_default_datasource.ts index 1d5570ebfbea..1a9bc8ca9d79 100644 --- a/src/plugins/data/public/data_sources/register_default_datasource.ts +++ b/src/plugins/data/public/data_sources/register_default_datasource.ts @@ -25,7 +25,6 @@ export const registerDefaultDataSource = (data: Omit { return; } - switch (selectedDataSources[0].connectionType) { - case 'os': // need to make sure we have a constant here - common with data source types - dispatch(setIndexPattern(selectedDataSources[0].value)); - dispatch(setDataSource(selectedDataSources[0].ds)); - break; - case 'flint': - dispatch(setDataSource(selectedDataSources[0].ds)); - break; + if (selectedDataSources[0].type === 'default') { + dispatch(setIndexPattern(selectedDataSources[0].value)); + dispatch(setDataSource(selectedDataSources[0].ds)); + } else { + dispatch(setDataSource(selectedDataSources[0].ds)); } }, [dispatch, setSelectedSources] From 09e1b9ec491e86c2f00de4f20f62ff261188c778 Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Tue, 4 Jun 2024 20:21:53 -0700 Subject: [PATCH 09/11] remove last reference to connection type Signed-off-by: Paul Sebastian --- src/plugins/data/public/data_sources/datasource/datasource.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/data/public/data_sources/datasource/datasource.ts b/src/plugins/data/public/data_sources/datasource/datasource.ts index 2f66caecb33b..bcff4d0d6cc7 100644 --- a/src/plugins/data/public/data_sources/datasource/datasource.ts +++ b/src/plugins/data/public/data_sources/datasource/datasource.ts @@ -42,7 +42,6 @@ export abstract class DataSource< this.id = settings.id; this.name = settings.name; this.type = settings.type; - this.connectionType = settings.connectionType; this.metadata = settings.metadata; } From 0f42ccf8debd2f782d216c123e219e8d5e70e644 Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Wed, 5 Jun 2024 16:40:57 -0700 Subject: [PATCH 10/11] use custom datasource hook for redux Signed-off-by: Paul Sebastian --- .../register_default_datasource.ts | 2 +- .../public/components/sidebar/index.tsx | 4 +- .../utils/state_management/metadata_slice.ts | 5 +-- .../view_components/utils/use_datasource.ts | 40 +++++++++++++++++++ .../utils/use_index_pattern.ts | 3 +- .../view_components/utils/use_search.ts | 4 +- 6 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 src/plugins/discover/public/application/view_components/utils/use_datasource.ts diff --git a/src/plugins/data/public/data_sources/register_default_datasource.ts b/src/plugins/data/public/data_sources/register_default_datasource.ts index 1a9bc8ca9d79..d8ae19114c3c 100644 --- a/src/plugins/data/public/data_sources/register_default_datasource.ts +++ b/src/plugins/data/public/data_sources/register_default_datasource.ts @@ -31,7 +31,7 @@ export const registerDefaultDataSource = (data: Omit { if (selectedDataSources[0].type === 'default') { dispatch(setIndexPattern(selectedDataSources[0].value)); - dispatch(setDataSource(selectedDataSources[0].ds)); - } else { - dispatch(setDataSource(selectedDataSources[0].ds)); } + dispatch(setDataSource(selectedDataSources[0].ds.getId())); }, [dispatch, setSelectedSources] ); diff --git a/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts b/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts index f8e352f73c2e..1ee70f2a9d12 100644 --- a/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts +++ b/src/plugins/data_explorer/public/utils/state_management/metadata_slice.ts @@ -4,12 +4,11 @@ */ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import { DataSource } from 'src/plugins/data/public'; import { DataExplorerServices } from '../../types'; export interface MetadataState { indexPattern?: string; - dataSource?: DataSource; + dataSource?: string; originatingApp?: string; view?: string; } @@ -42,7 +41,7 @@ export const slice = createSlice({ setIndexPattern: (state, action: PayloadAction) => { state.indexPattern = action.payload; }, - setDataSource: (state, action: PayloadAction) => { + setDataSource: (state, action: PayloadAction) => { state.dataSource = action.payload; }, setOriginatingApp: (state, action: PayloadAction) => { diff --git a/src/plugins/discover/public/application/view_components/utils/use_datasource.ts b/src/plugins/discover/public/application/view_components/utils/use_datasource.ts new file mode 100644 index 000000000000..513b3e28a9a9 --- /dev/null +++ b/src/plugins/discover/public/application/view_components/utils/use_datasource.ts @@ -0,0 +1,40 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { useEffect, useState } from 'react'; +import { DataSource, IDataSourceFilter } from '../../../../../data/public'; +import { useSelector } from '../../utils/state_management'; +import { DiscoverViewServices } from '../../../build_services'; + +export const useDataSource = (services: DiscoverViewServices) => { + const dataSourceId = useSelector((state) => state.metadata.dataSource); + const [dataSource, setDataSource] = useState(undefined); + const { data } = services; + + useEffect(() => { + let isMounted = true; + let subscription; + + if (dataSourceId) { + // get the data source object from the id + subscription = data.dataSources.dataSourceService + .getDataSources$([dataSourceId] as IDataSourceFilter) + .subscribe((ds) => { + if (isMounted) { + setDataSource(ds[dataSourceId]); + } + }); + } else { + subscription = data.dataSources.dataSourceService.getDataSources$().subscribe(() => {}); + } + + return () => { + subscription.unsubscribe(); + isMounted = false; + }; + }, [dataSourceId, data.dataSources]); + + return { dataSource }; +}; diff --git a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts index b9040bb87855..4b0b3c7591ba 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts @@ -28,7 +28,6 @@ export const useIndexPattern = (services: DiscoverViewServices) => { const indexPatternIdFromState = useSelector((state) => state.metadata.indexPattern); const [indexPattern, setIndexPattern] = useState(undefined); const { data, toastNotifications, uiSettings: config, store } = services; - const dataSource = useSelector((state) => state.metadata.dataSource); useEffect(() => { let isMounted = true; @@ -74,5 +73,5 @@ export const useIndexPattern = (services: DiscoverViewServices) => { }; }, [indexPatternIdFromState, data.indexPatterns, toastNotifications, config, store]); - return { indexPattern, dataSource }; + return { indexPattern }; }; diff --git a/src/plugins/discover/public/application/view_components/utils/use_search.ts b/src/plugins/discover/public/application/view_components/utils/use_search.ts index 7dec3546f2df..201cfa43b304 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_search.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_search.ts @@ -31,6 +31,7 @@ import { getResponseInspectorStats, } from '../../../opensearch_dashboards_services'; import { SEARCH_ON_PAGE_LOAD_SETTING } from '../../../../common'; +import { useDataSource } from './use_datasource'; export enum ResultStatus { UNINITIALIZED = 'uninitialized', @@ -72,7 +73,8 @@ export const useSearch = (services: DiscoverViewServices) => { const [savedSearch, setSavedSearch] = useState(undefined); const { savedSearch: savedSearchId, sort, interval } = useSelector((state) => state.discover); const { data, filterManager, getSavedSearchById, core, toastNotifications, chrome } = services; - const { indexPattern, dataSource } = useIndexPattern(services); + const { indexPattern } = useIndexPattern(services); + const { dataSource } = useDataSource(services); const timefilter = data.query.timefilter.timefilter; const fetchStateRef = useRef<{ abortController: AbortController | undefined; From 3e8fc6a6a824dc5e805301a2a605d73baabc069e Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Wed, 5 Jun 2024 16:42:37 -0700 Subject: [PATCH 11/11] remove unneccessary object Signed-off-by: Paul Sebastian --- .../application/view_components/utils/use_datasource.ts | 2 +- .../application/view_components/utils/use_index_pattern.ts | 2 +- .../public/application/view_components/utils/use_search.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/discover/public/application/view_components/utils/use_datasource.ts b/src/plugins/discover/public/application/view_components/utils/use_datasource.ts index 513b3e28a9a9..8029d58bb8f1 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_datasource.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_datasource.ts @@ -36,5 +36,5 @@ export const useDataSource = (services: DiscoverViewServices) => { }; }, [dataSourceId, data.dataSources]); - return { dataSource }; + return dataSource; }; diff --git a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts index 4b0b3c7591ba..e8a81234278e 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts @@ -73,5 +73,5 @@ export const useIndexPattern = (services: DiscoverViewServices) => { }; }, [indexPatternIdFromState, data.indexPatterns, toastNotifications, config, store]); - return { indexPattern }; + return indexPattern; }; diff --git a/src/plugins/discover/public/application/view_components/utils/use_search.ts b/src/plugins/discover/public/application/view_components/utils/use_search.ts index 201cfa43b304..762e87ee2885 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_search.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_search.ts @@ -73,8 +73,8 @@ export const useSearch = (services: DiscoverViewServices) => { const [savedSearch, setSavedSearch] = useState(undefined); const { savedSearch: savedSearchId, sort, interval } = useSelector((state) => state.discover); const { data, filterManager, getSavedSearchById, core, toastNotifications, chrome } = services; - const { indexPattern } = useIndexPattern(services); - const { dataSource } = useDataSource(services); + const indexPattern = useIndexPattern(services); + const dataSource = useDataSource(services); const timefilter = data.query.timefilter.timefilter; const fetchStateRef = useRef<{ abortController: AbortController | undefined;