From 66a26443d4f7e0ead052acd55a0b879e1b0d9c67 Mon Sep 17 00:00:00 2001 From: Prabhat Sharma Date: Mon, 8 Apr 2024 13:02:53 +0530 Subject: [PATCH] Integrate new props and default data source Signed-off-by: Prabhat Sharma --- opensearch_dashboards.json | 4 +- .../MDSEnabledComponent.tsx | 34 ++-- public/index_management_app.tsx | 6 +- .../Aliases/containers/Aliases/Aliases.tsx | 14 +- .../containers/ChangePolicy/ChangePolicy.tsx | 12 +- .../containers/CreateIndex/CreateIndex.tsx | 10 +- .../containers/IndexForm/index.tsx | 6 +- .../containers/CreatePolicy/CreatePolicy.tsx | 12 +- .../containers/CreateRollup/CreateRollup.tsx | 5 +- .../CreateRollupForm/CreateRollupForm.tsx | 19 +- .../CreateTransformForm.tsx | 19 +- .../Indices/containers/Indices/Indices.tsx | 19 +- public/pages/Main/Main.tsx | 180 +++++++++--------- .../ManagedIndices/ManagedIndices.tsx | 21 +- .../Policies/containers/Policies/Policies.tsx | 17 +- .../PolicyDetails/PolicyDetails.tsx | 12 +- .../Rollups/containers/Rollups/Rollups.tsx | 19 +- .../containers/Transforms/Transforms.tsx | 17 +- .../VisualCreatePolicy/VisualCreatePolicy.tsx | 13 +- public/plugin.ts | 13 +- public/services/DataSourceMenuContext.ts | 11 +- public/services/IndexService.ts | 24 +++ public/services/MDSEnabledClientService.ts | 8 + public/services/ManagedIndexService.ts | 10 +- public/types.ts | 5 - 25 files changed, 263 insertions(+), 247 deletions(-) delete mode 100644 public/types.ts diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index f2e5d849d..4d735f141 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -3,8 +3,8 @@ "version": "3.0.0.0", "opensearchDashboardsVersion": "3.0.0", "configPath": ["opensearch_index_management"], - "requiredPlugins": ["navigation", "opensearchDashboardsReact"], - "optionalPlugins": ["managementOverview", "dataSource", "dataSourceManagement"], + "requiredPlugins": ["navigation", "opensearchDashboardsReact", "managementOverview"], + "optionalPlugins": ["dataSource", "dataSourceManagement"], "server": true, "ui": true } diff --git a/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx b/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx index 340fe1120..536976e12 100644 --- a/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx +++ b/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx @@ -1,33 +1,29 @@ import React, { useContext, useEffect } from "react"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../services/DataSourceMenuContext"; +import { DataSourceMenuContext, DataSourceMenuProperties, DataSourceProperties } from "../../services/DataSourceMenuContext"; import { useHistory } from "react-router"; import queryString from "query-string"; +import { getDataSource } from "src/plugins/data_source/server/client/configure_client_utils"; -export default class MDSEnabledComponent< - Props extends DataSourceMenuProperties, - State extends DataSourceMenuProperties -> extends React.Component { +export default class MDSEnabledComponent extends React.Component< + Props, + State +> { constructor(props: Props) { super(props); this.state = { dataSourceId: props.dataSourceId, - dataSourceLabel: props.dataSourceLabel, multiDataSourceEnabled: props.multiDataSourceEnabled, } as State; } - static getDerivedStateFromProps( + static getDerivedStateFromProps( nextProps: Props, prevState: State ) { // static members cannot reference class type parameters - if ( - nextProps.multiDataSourceEnabled && - (nextProps.dataSourceId !== prevState.dataSourceId || nextProps.dataSourceLabel !== prevState.dataSourceLabel) - ) { + if (nextProps.multiDataSourceEnabled && nextProps.dataSourceId !== prevState.dataSourceId) { return { dataSourceId: nextProps.dataSourceId, - dataSourceLabel: nextProps.dataSourceLabel, }; } return null; @@ -35,8 +31,8 @@ export default class MDSEnabledComponent< } export function useUpdateUrlWithDataSourceProperties() { - const dataSourceMenuProps = useContext(DataSourceMenuContext); - const { dataSourceId, dataSourceLabel, multiDataSourceEnabled } = dataSourceMenuProps; + const dataSourceProps = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); + const { dataSourceId, multiDataSourceEnabled } = dataSourceProps; const history = useHistory(); const currentSearch = history.location.search; const currentQuery = queryString.parse(currentSearch); @@ -46,9 +42,15 @@ export function useUpdateUrlWithDataSourceProperties() { search: queryString.stringify({ ...currentQuery, dataSourceId, - dataSourceLabel, }), }); } - }, [dataSourceId, dataSourceLabel, multiDataSourceEnabled]); + }, [dataSourceId, multiDataSourceEnabled]); +} + +export function getDataSourcePropsFromContext(context: DataSourceMenuProperties): Props { + return { + dataSourceId: context.dataSource[0].id, + multiDataSourceEnabled: context.multiDataSourceEnabled, + } as Props; } diff --git a/public/index_management_app.tsx b/public/index_management_app.tsx index 8f58e4e92..6c08258df 100644 --- a/public/index_management_app.tsx +++ b/public/index_management_app.tsx @@ -11,14 +11,14 @@ import { DarkModeContext } from "./components/DarkMode"; import Main from "./pages/Main"; import { CoreServicesContext } from "./components/core_services"; import "./app.scss"; -import { AppPluginStartDependencies } from "./types"; import { DataSourceManagementPluginSetup } from "../../../src/plugins/data_source_management/public"; +import { DataSourcePluginSetup } from "../../../src/plugins/data_source/public"; export function renderApp( coreStart: CoreStart, - pluginStartDependencies: AppPluginStartDependencies, params: AppMountParameters, landingPage: string, + dataSource: DataSourcePluginSetup, dataSourceManagement: DataSourceManagementPluginSetup ) { const isDarkMode = coreStart.uiSettings.get("theme:darkMode") || false; @@ -33,7 +33,7 @@ export function renderApp( {...props} landingPage={landingPage} setActionMenu={params.setHeaderActionMenu} - multiDataSourceEnabled={!!pluginStartDependencies.dataSource} + multiDataSourceEnabled={dataSource.dataSourceEnabled} dataSourceManagement={dataSourceManagement} /> diff --git a/public/pages/Aliases/containers/Aliases/Aliases.tsx b/public/pages/Aliases/containers/Aliases/Aliases.tsx index 7e447fa49..10c5448b0 100644 --- a/public/pages/Aliases/containers/Aliases/Aliases.tsx +++ b/public/pages/Aliases/containers/Aliases/Aliases.tsx @@ -36,14 +36,14 @@ import IndexControls, { SearchControlsProps } from "../../components/IndexContro import CreateAlias from "../CreateAlias"; import AliasesActions from "../AliasActions"; import { CoreStart } from "opensearch-dashboards/public"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import MDSEnabledComponent from "../../../../components/MDSEnabledComponent"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import MDSEnabledComponent, { getDataSourcePropsFromContext } from "../../../../components/MDSEnabledComponent"; -interface AliasesProps extends RouteComponentProps, DataSourceMenuProperties { +interface AliasesProps extends RouteComponentProps, DataSourceProperties { commonService: CommonService; } -interface AliasesState extends DataSourceMenuProperties { +interface AliasesState extends DataSourceProperties { totalAliases: number; from: string; size: string; @@ -483,8 +483,8 @@ class Aliases extends MDSEnabledComponent { } } -export default function AliasContainer(props: Omit) { +export default function AliasContainer(props: Omit) { const context = useContext(ServicesContext); - const dataSourceMenuProps = useContext(DataSourceMenuContext); - return ; + const dataSourceProps = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); + return ; } diff --git a/public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx b/public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx index ba52420d0..20c425d1e 100644 --- a/public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx +++ b/public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx @@ -14,10 +14,10 @@ import { ManagedIndexItem } from "../../../../../models/interfaces"; import { getErrorMessage } from "../../../../utils/helpers"; import { PolicyOption } from "../../models/interfaces"; import { CoreServicesContext } from "../../../../components/core_services"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import { getDataSourcePropsFromContext, useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; -interface ChangePolicyProps extends RouteComponentProps, DataSourceMenuProperties { +interface ChangePolicyProps extends RouteComponentProps, DataSourceProperties { managedIndexService: ManagedIndexService; indexService: IndexService; } @@ -207,8 +207,8 @@ export class ChangePolicy extends Component) { - const dataSourceMenuProperties = useContext(DataSourceMenuContext); +export default function (props: Omit) { + const dataSourceProperties = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); useUpdateUrlWithDataSourceProperties(); - return ; + return ; } diff --git a/public/pages/CreateIndex/containers/CreateIndex/CreateIndex.tsx b/public/pages/CreateIndex/containers/CreateIndex/CreateIndex.tsx index 4f64e7f39..d82cfabfb 100644 --- a/public/pages/CreateIndex/containers/CreateIndex/CreateIndex.tsx +++ b/public/pages/CreateIndex/containers/CreateIndex/CreateIndex.tsx @@ -9,14 +9,14 @@ import { RouteComponentProps } from "react-router-dom"; import IndexForm from "../IndexForm"; import { BREADCRUMBS, IndicesUpdateMode, ROUTES } from "../../../../utils/constants"; import { CoreServicesContext } from "../../../../components/core_services"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import { getDataSourcePropsFromContext, useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; interface CreateIndexPropsBase extends RouteComponentProps<{ index?: string; mode?: IndicesUpdateMode }> { isEdit?: boolean; } -interface CreateIndexProps extends CreateIndexPropsBase, DataSourceMenuProperties {} +interface CreateIndexProps extends CreateIndexPropsBase, DataSourceProperties {} export class CreateIndex extends Component { static contextType = CoreServicesContext; @@ -64,7 +64,7 @@ export class CreateIndex extends Component { } export default function (props: CreateIndexPropsBase) { - const dataSourceMenuProperties = useContext(DataSourceMenuContext); + const dataSourceProperties = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); useUpdateUrlWithDataSourceProperties(); - return ; + return ; } diff --git a/public/pages/CreateIndex/containers/IndexForm/index.tsx b/public/pages/CreateIndex/containers/IndexForm/index.tsx index e4bdd0ede..42799ee28 100644 --- a/public/pages/CreateIndex/containers/IndexForm/index.tsx +++ b/public/pages/CreateIndex/containers/IndexForm/index.tsx @@ -17,7 +17,7 @@ import { transformArrayToObject, transformObjectToArray } from "../../../../comp import { ServerResponse } from "../../../../../server/models/types"; import { BrowserServices } from "../../../../models/interfaces"; import { ServicesContext } from "../../../../services"; -import { DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; +import { DataSourceProperties } from "../../../../services/DataSourceMenuContext"; export const getAliasActionsByDiffArray = ( oldAliases: string[], @@ -46,9 +46,7 @@ export const getAliasActionsByDiffArray = ( }, [] as IAliasAction[]); }; -export interface IndexFormProps - extends Pick, - Pick { +export interface IndexFormProps extends Pick, Pick { index?: string; value?: Partial; mode?: IndicesUpdateMode; diff --git a/public/pages/CreatePolicy/containers/CreatePolicy/CreatePolicy.tsx b/public/pages/CreatePolicy/containers/CreatePolicy/CreatePolicy.tsx index 98070fc95..3a7968735 100644 --- a/public/pages/CreatePolicy/containers/CreatePolicy/CreatePolicy.tsx +++ b/public/pages/CreatePolicy/containers/CreatePolicy/CreatePolicy.tsx @@ -15,10 +15,10 @@ import { PolicyService } from "../../../../services"; import { BREADCRUMBS, DOCUMENTATION_URL, ROUTES } from "../../../../utils/constants"; import { getErrorMessage } from "../../../../utils/helpers"; import { CoreServicesContext } from "../../../../components/core_services"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import { getDataSourcePropsFromContext, useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; -interface CreatePolicyProps extends RouteComponentProps, DataSourceMenuProperties { +interface CreatePolicyProps extends RouteComponentProps, DataSourceProperties { isEdit: boolean; policyService: PolicyService; } @@ -267,8 +267,8 @@ export class CreatePolicy extends Component) { - const dataSourceMenuProperties = useContext(DataSourceMenuContext); +export default function (props: Omit) { + const dataSourceProperties = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); useUpdateUrlWithDataSourceProperties(); - return ; + return ; } diff --git a/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx b/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx index 92905139e..1932eeeae 100644 --- a/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx +++ b/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx @@ -12,10 +12,9 @@ import RollupIndices from "../../components/RollupIndices"; import CreateRollupSteps from "../../components/CreateRollupSteps"; import IndexService from "../../../../services/IndexService"; import { IndexItem } from "../../../../../models/interfaces"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; +import { DataSourceProperties } from "../../../../services/DataSourceMenuContext"; -interface CreateRollupProps extends RouteComponentProps, DataSourceMenuProperties { +interface CreateRollupProps extends RouteComponentProps, DataSourceProperties { rollupService: RollupService; indexService: IndexService; rollupId: string; diff --git a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx index c7cc2ea8b..838fa00d5 100644 --- a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx +++ b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx @@ -21,15 +21,10 @@ import CreateRollupStep3 from "../CreateRollupStep3"; import CreateRollupStep4 from "../CreateRollupStep4"; import { compareFieldItem, parseFieldOptions } from "../../utils/helpers"; import { CoreServicesContext } from "../../../../components/core_services"; -import { - DataSourceMenuContext, - DataSourceMenuProperties, - DataSourceMenuReadOnlyContext, - DataSourceMenuReadOnlyProperties, -} from "../../../../services/DataSourceMenuContext"; -import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; - -interface CreateRollupFormProps extends RouteComponentProps, DataSourceMenuProperties, DataSourceMenuReadOnlyProperties { +import { DataSourceMenuContext, DataSourceMenuReadOnlyProperties, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import { getDataSourcePropsFromContext, useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; + +interface CreateRollupFormProps extends RouteComponentProps, DataSourceProperties, DataSourceMenuReadOnlyProperties { rollupService: RollupService; indexService: IndexService; } @@ -717,8 +712,8 @@ export class CreateRollupForm extends Component) { - const dataSourceMenuProperties = useContext(DataSourceMenuContext); +export default function (props: Omit) { + const dataSourceProperties = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); useUpdateUrlWithDataSourceProperties(); - return ; + return ; } diff --git a/public/pages/CreateTransform/containers/CreateTransformForm/CreateTransformForm.tsx b/public/pages/CreateTransform/containers/CreateTransformForm/CreateTransformForm.tsx index 1c788e442..0b81aaabe 100644 --- a/public/pages/CreateTransform/containers/CreateTransformForm/CreateTransformForm.tsx +++ b/public/pages/CreateTransform/containers/CreateTransformForm/CreateTransformForm.tsx @@ -27,15 +27,10 @@ import SpecifyScheduleStep from "../SpecifyScheduleStep"; import ReviewAndCreateStep from "../ReviewAndCreateStep"; import { compareFieldItem, createdTransformToastMessage, isGroupBy, parseFieldOptions } from "../../utils/helpers"; import { CoreServicesContext } from "../../../../components/core_services"; -import { - DataSourceMenuContext, - DataSourceMenuProperties, - DataSourceMenuReadOnlyContext, - DataSourceMenuReadOnlyProperties, -} from "../../../../services/DataSourceMenuContext"; -import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; - -interface CreateTransformFormProps extends RouteComponentProps, DataSourceMenuProperties, DataSourceMenuReadOnlyProperties { +import { DataSourceMenuContext, DataSourceMenuReadOnlyProperties, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import { getDataSourcePropsFromContext, useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; + +interface CreateTransformFormProps extends RouteComponentProps, DataSourceProperties, DataSourceMenuReadOnlyProperties { rollupService: RollupService; transformService: TransformService; indexService: IndexService; @@ -686,8 +681,8 @@ export class CreateTransformForm extends Component) { - const dataSourceMenuProperties = useContext(DataSourceMenuContext); +export default function (props: Omit) { + const dataSourceProperties = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); useUpdateUrlWithDataSourceProperties(); - return ; + return ; } diff --git a/public/pages/Indices/containers/Indices/Indices.tsx b/public/pages/Indices/containers/Indices/Indices.tsx index c8dc06fab..bfe119971 100644 --- a/public/pages/Indices/containers/Indices/Indices.tsx +++ b/public/pages/Indices/containers/Indices/Indices.tsx @@ -37,15 +37,15 @@ import { SECURITY_EXCEPTION_PREFIX } from "../../../../../server/utils/constants import IndicesActions from "../IndicesActions"; import { destroyListener, EVENT_MAP, listenEvent } from "../../../../JobHandler"; import "./index.scss"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import MDSEnabledComponent from "../../../../components/MDSEnabledComponent"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import MDSEnabledComponent, { getDataSourcePropsFromContext } from "../../../../components/MDSEnabledComponent"; -interface IndicesProps extends RouteComponentProps, DataSourceMenuProperties { +interface IndicesProps extends RouteComponentProps, DataSourceProperties { indexService: IndexService; commonService: CommonService; } -interface IndicesState extends DataSourceMenuProperties { +interface IndicesState extends DataSourceProperties { totalIndices: number; from: number; size: number; @@ -131,10 +131,7 @@ export class Indices extends MDSEnabledComponent { try { const { indexService, history } = this.props; const queryObject = this.getQueryObjectFromState(this.state); - const queryParamsString = queryString.stringify({ - ...queryObject, - ...(this.state.multiDataSourceEnabled ? { dataSourceLabel: this.state.dataSourceLabel } : {}), - }); + const queryParamsString = queryString.stringify(queryObject); history.replace({ ...this.props.location, search: queryParamsString }); const getIndicesResponse = await indexService.getIndices({ @@ -322,7 +319,7 @@ export class Indices extends MDSEnabledComponent { } } -export default function (props: Omit) { - const dataSourceMenuProps = useContext(DataSourceMenuContext); - return ; +export default function (props: Omit) { + const dataSourceProps = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); + return ; } diff --git a/public/pages/Main/Main.tsx b/public/pages/Main/Main.tsx index 1edf71040..a80137cdc 100644 --- a/public/pages/Main/Main.tsx +++ b/public/pages/Main/Main.tsx @@ -60,7 +60,12 @@ import ComposableTemplates from "../ComposableTemplates"; import CreateComposableTemplate from "../CreateComposableTemplate"; import { DataSourceMenuContext, DataSourceMenuProperties } from "../../services/DataSourceMenuContext"; import queryString from "query-string"; -import { DataSourceManagementPluginSetup } from "../../../../../src/plugins/data_source_management/public"; +import { + DataSourceManagementPluginSetup, + DataSourceSelectableConfig, + DataSourceViewConfig, +} from "../../../../../src/plugins/data_source_management/public"; +import _ from "lodash"; enum Navigation { IndexManagement = "Index Management", @@ -131,7 +136,7 @@ interface MainProps extends RouteComponentProps { dataSourceManagement: DataSourceManagementPluginSetup; } -interface MainState extends Pick { +interface MainState extends Pick { dataSourceReadOnly: boolean; } @@ -173,20 +178,19 @@ export default class Main extends Component { constructor(props: MainProps) { super(props); let dataSourceId = ""; - let dataSourceLabel = ""; if (props.multiDataSourceEnabled) { - const { dataSourceId: parsedDataSourceId, dataSourceLabel: parsedDataSourceLabel } = queryString.parse( - this.props.location.search - ) as { + const { dataSourceId: parsedDataSourceId } = queryString.parse(this.props.location.search) as { dataSourceId: string; - dataSourceLabel: string; }; dataSourceId = parsedDataSourceId || ""; - dataSourceLabel = parsedDataSourceLabel || ""; } this.state = { - dataSourceId: dataSourceId, - dataSourceLabel: dataSourceLabel, + dataSource: [ + { + label: "", + id: dataSourceId, + }, + ], dataSourceReadOnly: false, }; } @@ -223,13 +227,15 @@ export default class Main extends Component { }; if (this.props.multiDataSourceEnabled && this.isDataSourceEnabledForPath(pathname)) { - services.indexService = new IndexService(http, this.state.dataSourceId, this.props.multiDataSourceEnabled); - services.commonService = new CommonService(http, this.state.dataSourceId, this.props.multiDataSourceEnabled); - services.managedIndexService = new ManagedIndexService(http, this.state.dataSourceId, this.props.multiDataSourceEnabled); - services.policyService = new PolicyService(http, this.state.dataSourceId, this.props.multiDataSourceEnabled); - services.notificationService = new NotificationService(http, this.state.dataSourceId, this.props.multiDataSourceEnabled); - services.rollupService = new RollupService(http, this.state.dataSourceId, this.props.multiDataSourceEnabled); - services.transformService = new TransformService(http, this.state.dataSourceId, this.props.multiDataSourceEnabled); + const dataSourceId = this.state.dataSource[0] ? this.state.dataSource[0].id : undefined; + const mdsEnabled = this.props.multiDataSourceEnabled; + services.indexService = new IndexService(http, dataSourceId, mdsEnabled); + services.commonService = new CommonService(http, dataSourceId, mdsEnabled); + services.managedIndexService = new ManagedIndexService(http, dataSourceId, mdsEnabled); + services.policyService = new PolicyService(http, dataSourceId, mdsEnabled); + services.notificationService = new NotificationService(http, dataSourceId, mdsEnabled); + services.rollupService = new RollupService(http, dataSourceId, mdsEnabled); + services.transformService = new TransformService(http, dataSourceId, mdsEnabled); } return services; } @@ -338,7 +344,8 @@ export default class Main extends Component { const { landingPage } = this.props; const ROUTE_STYLE = { padding: "25px 25px" }; - const DataSourceMenu = this.props.dataSourceManagement?.ui?.DataSourceMenu; + const DataSourceMenuSelectable = this.props.dataSourceManagement?.ui?.getDataSourceMenu(); + const DataSourceMenuView = this.props.dataSourceManagement.ui.getDataSourceMenu(); return ( @@ -351,8 +358,7 @@ export default class Main extends Component { @@ -375,24 +381,18 @@ export default class Main extends Component { ROUTES.TRANSFORM_DETAILS, ROUTES.EDIT_TRANSFORM, ]} - render={(props) => ( - ( + { - if (this.state.dataSourceId && this.state.dataSourceId !== "") { - return [ - { - id: this.state.dataSourceId, - label: this.state.dataSourceLabel, - }, - ]; - } - return undefined; - })()} - fullWidth={false} - hideLocalCluster={false} + componentType={"DataSourceView"} + componentConfig={{ + fullWidth: false, + savedObjects: core.savedObjects.client, + notifications: core.notifications, + activeOption: this.state.dataSource[0]?.id + ? [{ id: this.state.dataSource[0].id, label: this.state.dataSource[0].label }] + : [{ id: "", label: "" }], + }} /> )} /> @@ -414,66 +414,68 @@ export default class Main extends Component { ROUTES.ROLLUPS, ROUTES.TRANSFORMS, ]} - render={() => ( - ( + { - this.setState({ dataSourceId, dataSourceLabel }); + componentType={"DataSourceSelectable"} + componentConfig={{ + fullWidth: false, + onSelectedDataSources: (dataSources) => { + if ( + this.props.multiDataSourceEnabled && + dataSources.length > 0 && + !_.isEqual(dataSources[0], this.state.dataSource[0]) + ) { + this.setState({ dataSource: dataSources }); + } + }, + savedObjects: core.savedObjects.client, + notifications: core.notifications, + activeOption: + this.state.dataSource[0].id !== undefined ? [{ id: this.state.dataSource[0].id }] : undefined, }} - disableDataSourceSelectable={false} - notifications={services.notificationService} - savedObjects={core.savedObjects.client} - selectedOption={(() => { - if (this.state.dataSourceId && this.state.dataSourceId !== "") { - return [ - { - id: this.state.dataSourceId, - label: this.state.dataSourceLabel, - }, - ]; - } - return undefined; - })()} - fullWidth={false} - hideLocalCluster={false} /> )} /> ( - { - this.setState({ dataSourceId, dataSourceLabel }); + render={() => + this.state.dataSourceReadOnly ? ( + + ) : ( + { + if ( + this.props.multiDataSourceEnabled && + dataSources.length > 0 && + !_.isEqual(dataSources[0], this.state.dataSource[0]) + ) { + this.setState({ dataSource: dataSources }); } - } - notifications={this.state.dataSourceReadOnly ? undefined : services.notificationService} - savedObjects={this.state.dataSourceReadOnly ? undefined : core.savedObjects.client} - selectedOption={(() => { - if (this.state.dataSourceId && this.state.dataSourceId !== "") { - return [ - { - id: this.state.dataSourceId, - label: this.state.dataSourceLabel, - }, - ]; - } - return undefined; - })()} - fullWidth={false} - hideLocalCluster={false} - /> - )} + }, + savedObjects: core.savedObjects.client, + notifications: core.notifications, + activeOption: + this.state.dataSource[0].id !== undefined ? [{ id: this.state.dataSource[0].id }] : undefined, + }} + /> + ) + } /> )} diff --git a/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.tsx b/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.tsx index 233d19b7e..99215fb2d 100644 --- a/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.tsx +++ b/public/pages/ManagedIndices/containers/ManagedIndices/ManagedIndices.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { Component, useContext } from "react"; +import React, { useContext } from "react"; import { RouteComponentProps } from "react-router-dom"; import { EuiBasicTable, @@ -46,14 +46,14 @@ import RolloverAliasModal from "../../components/RolloverAliasModal"; import { CoreServicesContext } from "../../../../components/core_services"; import { DataStream } from "../../../../../server/models/interfaces"; import { SECURITY_EXCEPTION_PREFIX } from "../../../../../server/utils/constants"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import MDSEnabledComponent from "../../../../components/MDSEnabledComponent"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import MDSEnabledComponent, { getDataSourcePropsFromContext } from "../../../../components/MDSEnabledComponent"; -interface ManagedIndicesProps extends RouteComponentProps, DataSourceMenuProperties { +interface ManagedIndicesProps extends RouteComponentProps, DataSourceProperties { managedIndexService: ManagedIndexService; } -interface ManagedIndicesState extends DataSourceMenuProperties { +interface ManagedIndicesState extends DataSourceProperties { totalManagedIndices: number; from: number; size: number; @@ -247,10 +247,7 @@ export class ManagedIndices extends MDSEnabledComponent) { - const dataSourceMenuProps = useContext(DataSourceMenuContext); - return ; +export default function (props: Omit) { + const dataSourceProps = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); + return ; } diff --git a/public/pages/Policies/containers/Policies/Policies.tsx b/public/pages/Policies/containers/Policies/Policies.tsx index 8e7e97353..1ee1d8434 100644 --- a/public/pages/Policies/containers/Policies/Policies.tsx +++ b/public/pages/Policies/containers/Policies/Policies.tsx @@ -34,15 +34,14 @@ import { PolicyService } from "../../../../services"; import { getErrorMessage } from "../../../../utils/helpers"; import ConfirmationModal from "../../../../components/ConfirmationModal"; import { CoreServicesContext } from "../../../../components/core_services"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import MDSEnabledComponent from "../../../../components/MDSEnabledComponent"; -import { DataSource } from "src/plugins/data/public"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import MDSEnabledComponent, { getDataSourcePropsFromContext } from "../../../../components/MDSEnabledComponent"; -interface PoliciesProps extends RouteComponentProps, DataSourceMenuProperties { +interface PoliciesProps extends RouteComponentProps, DataSourceProperties { policyService: PolicyService; } -interface PoliciesState extends DataSourceMenuProperties { +interface PoliciesState extends DataSourceProperties { totalPolicies: number; from: number; size: number; @@ -142,7 +141,7 @@ export class Policies extends MDSEnabledComponent try { const { policyService, history } = this.props; const queryObject = Policies.getQueryObjectFromState(this.state); - const queryParamsString = queryString.stringify({ ...queryObject, dataSourceLabel: this.state.dataSourceLabel }); + const queryParamsString = queryString.stringify(queryObject); history.replace({ ...this.props.location, search: queryParamsString }); const getPoliciesResponse = await policyService.getPolicies(queryObject); if (getPoliciesResponse.ok) { @@ -325,7 +324,7 @@ export class Policies extends MDSEnabledComponent } } -export default function (props: Omit) { - const dataSourceMenuProps = useContext(DataSourceMenuContext); - return ; +export default function (props: Omit) { + const dataSourceProps = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); + return ; } diff --git a/public/pages/PolicyDetails/containers/PolicyDetails/PolicyDetails.tsx b/public/pages/PolicyDetails/containers/PolicyDetails/PolicyDetails.tsx index 8db46ede5..921dfc257 100644 --- a/public/pages/PolicyDetails/containers/PolicyDetails/PolicyDetails.tsx +++ b/public/pages/PolicyDetails/containers/PolicyDetails/PolicyDetails.tsx @@ -33,10 +33,10 @@ import { ContentPanel } from "../../../../components/ContentPanel"; import { convertTemplatesToArray } from "../../../VisualCreatePolicy/utils/helpers"; import CreatePolicyModal from "../../../../components/CreatePolicyModal"; import { ModalConsumer } from "../../../../components/Modal"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import { getDataSourcePropsFromContext, useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; -interface PolicyDetailsProps extends RouteComponentProps, DataSourceMenuProperties { +interface PolicyDetailsProps extends RouteComponentProps, DataSourceProperties { policyService: PolicyService; } @@ -260,8 +260,8 @@ export class PolicyDetails extends Component) { - const dataSourceMenuProperties = useContext(DataSourceMenuContext); +export default function (props: Omit) { + const dataSourceProperties = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); useUpdateUrlWithDataSourceProperties(); - return ; + return ; } diff --git a/public/pages/Rollups/containers/Rollups/Rollups.tsx b/public/pages/Rollups/containers/Rollups/Rollups.tsx index 4c06703e7..bca12fb61 100644 --- a/public/pages/Rollups/containers/Rollups/Rollups.tsx +++ b/public/pages/Rollups/containers/Rollups/Rollups.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { Component, useContext } from "react"; +import React, { useContext } from "react"; import _ from "lodash"; import { BREADCRUMBS, ROUTES } from "../../../../utils/constants"; import queryString from "query-string"; @@ -43,15 +43,14 @@ import DeleteModal from "../../components/DeleteModal"; import { renderStatus } from "../../../RollupDetails/utils/helpers"; import { DocumentRollup } from "../../../../../models/interfaces"; import { CoreServicesContext } from "../../../../components/core_services"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import MDSEnabledComponent from "../../../../components/MDSEnabledComponent"; -import { HttpFetchQuery } from "opensearch-dashboards/public"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import MDSEnabledComponent, { getDataSourcePropsFromContext } from "../../../../components/MDSEnabledComponent"; -interface RollupsProps extends RouteComponentProps, DataSourceMenuProperties { +interface RollupsProps extends RouteComponentProps, DataSourceProperties { rollupService: RollupService; } -interface RollupsState extends DataSourceMenuProperties { +interface RollupsState extends DataSourceProperties { totalRollups: number; from: number; size: number; @@ -122,7 +121,7 @@ export class Rollups extends MDSEnabledComponent { try { const { rollupService, history } = this.props; const queryObject = Rollups.getQueryObjectFromState(this.state); - const queryParamsString = queryString.stringify({ ...queryObject, dataSourceLabel: this.state.dataSourceLabel }); + const queryParamsString = queryString.stringify(queryObject); history.replace({ ...this.props.location, search: queryParamsString }); const rollupJobsResponse = await rollupService.getRollups(queryObject); // Add type assertion if (rollupJobsResponse.ok) { @@ -493,7 +492,7 @@ export class Rollups extends MDSEnabledComponent { } } -export default function (props: Omit) { - const dataSourceMenuProps = useContext(DataSourceMenuContext); - return ; +export default function (props: Omit) { + const dataSourceProps = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); + return ; } diff --git a/public/pages/Transforms/containers/Transforms/Transforms.tsx b/public/pages/Transforms/containers/Transforms/Transforms.tsx index 0ec8986af..57267cb55 100644 --- a/public/pages/Transforms/containers/Transforms/Transforms.tsx +++ b/public/pages/Transforms/containers/Transforms/Transforms.tsx @@ -31,7 +31,7 @@ import queryString from "query-string"; import { RouteComponentProps } from "react-router-dom"; import TransformService from "../../../../services/TransformService"; import { DocumentTransform } from "../../../../../models/interfaces"; -import React, { Component, useContext } from "react"; +import React, { useContext } from "react"; import { CoreServicesContext } from "../../../../components/core_services"; import { getURLQueryParams, renderTime } from "../../utils/helpers"; import { TransformQueryParams } from "../../models/interfaces"; @@ -44,14 +44,14 @@ import { DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_QUERY_PARAMS } from "../../../Indice import _ from "lodash"; import { ManagedCatIndex } from "../../../../../server/models/interfaces"; import { renderContinuous } from "../../../Rollups/utils/helpers"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import MDSEnabledComponent from "../../../../components/MDSEnabledComponent"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import MDSEnabledComponent, { getDataSourcePropsFromContext } from "../../../../components/MDSEnabledComponent"; -interface TransformProps extends RouteComponentProps, DataSourceMenuProperties { +interface TransformProps extends RouteComponentProps, DataSourceProperties { transformService: TransformService; } -interface TransformState extends DataSourceMenuProperties { +interface TransformState extends DataSourceProperties { totalTransforms: number; from: number; size: number; @@ -344,7 +344,6 @@ export class Transforms extends MDSEnabledComponent) { - const dataSourceMenuProps = useContext(DataSourceMenuContext); - return ; +export default function (props: Omit) { + const dataSourceProps = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); + return ; } diff --git a/public/pages/VisualCreatePolicy/containers/VisualCreatePolicy/VisualCreatePolicy.tsx b/public/pages/VisualCreatePolicy/containers/VisualCreatePolicy/VisualCreatePolicy.tsx index 52dccc716..76a1a80e6 100644 --- a/public/pages/VisualCreatePolicy/containers/VisualCreatePolicy/VisualCreatePolicy.tsx +++ b/public/pages/VisualCreatePolicy/containers/VisualCreatePolicy/VisualCreatePolicy.tsx @@ -19,11 +19,10 @@ import CreateState from "../CreateState"; import { getErrorMessage } from "../../../../utils/helpers"; import { getUpdatedPolicy, getUpdatedStates } from "../../utils/helpers"; import ErrorNotification from "../ErrorNotification"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; -import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; -import { Data } from "vega"; +import { DataSourceMenuContext, DataSourceProperties } from "../../../../services/DataSourceMenuContext"; +import { getDataSourcePropsFromContext, useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; -interface VisualCreatePolicyProps extends RouteComponentProps, DataSourceMenuProperties { +interface VisualCreatePolicyProps extends RouteComponentProps, DataSourceProperties { isEdit: boolean; policyService: PolicyService; notificationService: NotificationService; @@ -344,8 +343,8 @@ export class VisualCreatePolicy extends Component) { - const dataSourceMenuProperties = useContext(DataSourceMenuContext); +export default function (props: Omit) { + const dataSourceProperties = getDataSourcePropsFromContext(useContext(DataSourceMenuContext)); useUpdateUrlWithDataSourceProperties(); - return ; + return ; } diff --git a/public/plugin.ts b/public/plugin.ts index 0c9f92331..d30a16f43 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -18,10 +18,12 @@ import { ROUTES } from "./utils/constants"; import { JobHandlerRegister } from "./JobHandler"; import { ManagementOverViewPluginSetup } from "../../../src/plugins/management_overview/public"; import { DataSourceManagementPluginSetup } from "../../../src/plugins/data_source_management/public"; +import { DataSourcePluginSetup } from "../../../src/plugins/data_source/public"; interface IndexManagementSetupDeps { managementOverview?: ManagementOverViewPluginSetup; - dataSourceManagement?: DataSourceManagementPluginSetup; + dataSource: DataSourcePluginSetup; + dataSourceManagement: DataSourceManagementPluginSetup; } export class IndexManagementPlugin implements Plugin { @@ -29,7 +31,10 @@ export class IndexManagementPlugin implements Plugin { const { renderApp } = await import("./index_management_app"); const [coreStart, depsStart] = await core.getStartServices(); - return renderApp(coreStart, depsStart, params, ROUTES.INDEX_POLICIES, dataSourceManagement); + return renderApp(coreStart, params, ROUTES.INDEX_POLICIES, dataSource, dataSourceManagement); }, }); @@ -72,7 +77,7 @@ export class IndexManagementPlugin implements Plugin { const { renderApp } = await import("./index_management_app"); const [coreStart, depsStart] = await core.getStartServices(); - return renderApp(coreStart, depsStart, params, ROUTES.SNAPSHOT_POLICIES, dataSourceManagement); + return renderApp(coreStart, params, ROUTES.SNAPSHOT_POLICIES, dataSource, dataSourceManagement); }, }); diff --git a/public/services/DataSourceMenuContext.ts b/public/services/DataSourceMenuContext.ts index 6e2e849f7..7664117b3 100644 --- a/public/services/DataSourceMenuContext.ts +++ b/public/services/DataSourceMenuContext.ts @@ -1,9 +1,13 @@ -import { create } from "lodash"; import { createContext } from "react"; +import { DataSourceOption } from "../../../../src/plugins/data_source_management/public/components/data_source_menu/types"; export interface DataSourceMenuProperties { + dataSource: DataSourceOption[]; + multiDataSourceEnabled: boolean; +} + +export interface DataSourceProperties { dataSourceId: string; - dataSourceLabel: string; multiDataSourceEnabled: boolean; } @@ -13,8 +17,7 @@ export interface DataSourceMenuReadOnlyProperties { } const DataSourceMenuContext = createContext({ - dataSourceId: "", - dataSourceLabel: "", + dataSource: [], multiDataSourceEnabled: false, }); diff --git a/public/services/IndexService.ts b/public/services/IndexService.ts index bc26bef5d..6472ef130 100644 --- a/public/services/IndexService.ts +++ b/public/services/IndexService.ts @@ -22,6 +22,10 @@ import { MDSEnabledClientService } from "./MDSEnabledClientService"; export default class IndexService extends MDSEnabledClientService { getIndices = async (queryObject: HttpFetchQuery): Promise> => { + const invalidStateResponse = this.ensureValidState(); + if (invalidStateResponse) { + return invalidStateResponse; + } let url = `..${NODE_API._INDICES}`; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; @@ -29,6 +33,10 @@ export default class IndexService extends MDSEnabledClientService { }; getDataStreams = async (queryObject: HttpFetchQuery): Promise> => { + const invalidStateResponse = this.ensureValidState(); + if (invalidStateResponse) { + return invalidStateResponse; + } const url = `..${NODE_API._DATA_STREAMS}`; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; @@ -36,6 +44,10 @@ export default class IndexService extends MDSEnabledClientService { }; getAliases = async (queryObject: HttpFetchQuery): Promise> => { + const invalidStateResponse = this.ensureValidState(); + if (invalidStateResponse) { + return invalidStateResponse; + } const url = `..${NODE_API._ALIASES}`; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; @@ -90,6 +102,10 @@ export default class IndexService extends MDSEnabledClientService { }; applyPolicy = async (indices: string[], policyId: string, queryObject?: HttpFetchQuery): Promise> => { + const invalidStateResponse = this.ensureValidState(); + if (invalidStateResponse) { + return invalidStateResponse; + } const body = { indices, policyId }; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; @@ -101,6 +117,10 @@ export default class IndexService extends MDSEnabledClientService { }; editRolloverAlias = async (index: string, alias: string, queryObject?: HttpFetchQuery): Promise> => { + const invalidStateResponse = this.ensureValidState(); + if (invalidStateResponse) { + return invalidStateResponse; + } const body = { index, alias }; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; @@ -112,6 +132,10 @@ export default class IndexService extends MDSEnabledClientService { }; searchPolicies = async (searchValue: string, source: boolean = false): Promise> => { + const invalidStateResponse = this.ensureValidState(); + if (invalidStateResponse) { + return invalidStateResponse; + } const str = searchValue.trim(); const query = this.patchQueryObjectWithDataSourceId({ from: 0, size: 10, search: str, sortDirection: "desc", sortField: "id" }); const params = query ? { query } : {}; diff --git a/public/services/MDSEnabledClientService.ts b/public/services/MDSEnabledClientService.ts index c5a2755c4..e1f349db9 100644 --- a/public/services/MDSEnabledClientService.ts +++ b/public/services/MDSEnabledClientService.ts @@ -1,4 +1,5 @@ import { HttpFetchQuery, HttpSetup } from "opensearch-dashboards/public"; +import { ServerResponse } from "../../../../plugins/index-management-dashboards-plugin/server/models/types"; export abstract class MDSEnabledClientService { httpClient: HttpSetup; @@ -18,4 +19,11 @@ export abstract class MDSEnabledClientService { } return queryObject; } + + ensureValidState(): ServerResponse | null { + if (this.mdsEnabled && this.dataSourceId === undefined) { + return { ok: false, error: "Invalid DataSource" }; + } + return null; + } } diff --git a/public/services/ManagedIndexService.ts b/public/services/ManagedIndexService.ts index a87e83894..757f76eee 100644 --- a/public/services/ManagedIndexService.ts +++ b/public/services/ManagedIndexService.ts @@ -16,7 +16,7 @@ import { NODE_API } from "../../utils/constants"; import { MDSEnabledClientService } from "./MDSEnabledClientService"; export default class ManagedIndexService extends MDSEnabledClientService { - getManagedIndex = async (managedIndexUuid: string, queryObject: HttpFetchQuery | undefined): Promise> => { + getManagedIndex = async (managedIndexUuid: string, queryObject?: HttpFetchQuery): Promise> => { let url = `..${NODE_API.MANAGED_INDICES}/${managedIndexUuid}`; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; @@ -24,7 +24,7 @@ export default class ManagedIndexService extends MDSEnabledClientService { return response; }; - getManagedIndices = async (queryObject: HttpFetchQuery | undefined): Promise> => { + getManagedIndices = async (queryObject?: HttpFetchQuery): Promise> => { let url = `..${NODE_API.MANAGED_INDICES}`; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; @@ -32,7 +32,7 @@ export default class ManagedIndexService extends MDSEnabledClientService { return response; }; - getDataStreams = async (queryObject: HttpFetchQuery | undefined): Promise> => { + getDataStreams = async (queryObject?: HttpFetchQuery): Promise> => { let url = `..${NODE_API._DATA_STREAMS}`; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; @@ -43,7 +43,7 @@ export default class ManagedIndexService extends MDSEnabledClientService { retryManagedIndexPolicy = async ( index: string[], state: string | null, - queryObject: HttpFetchQuery | undefined + queryObject?: HttpFetchQuery ): Promise> => { const body = { index, state }; const query = this.patchQueryObjectWithDataSourceId(queryObject); @@ -55,7 +55,7 @@ export default class ManagedIndexService extends MDSEnabledClientService { return response; }; - removePolicy = async (indices: string[], queryObject?: HttpFetchQuery | undefined): Promise> => { + removePolicy = async (indices: string[], queryObject?: HttpFetchQuery): Promise> => { const body = { indices }; const query = this.patchQueryObjectWithDataSourceId(queryObject); const params = query ? { query } : {}; diff --git a/public/types.ts b/public/types.ts deleted file mode 100644 index 9010386dd..000000000 --- a/public/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { DataSourcePluginStart } from "src/plugins/data_source/public/types"; - -export interface AppPluginStartDependencies { - dataSource: DataSourcePluginStart; -}