From dbbaabe1d28c7d1e5719a42249cbf6347e15c5b9 Mon Sep 17 00:00:00 2001 From: Ramakrishna Chilaka Date: Wed, 10 Jul 2024 18:36:51 +0530 Subject: [PATCH] Adding dataVersionFilter support to MDS to enable version decoupling Signed-off-by: Ramakrishna Chilaka --- opensearch_dashboards.json | 4 +++- public/pages/Main/Main.tsx | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index f2e5d849d..5493c743e 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -6,5 +6,7 @@ "requiredPlugins": ["navigation", "opensearchDashboardsReact"], "optionalPlugins": ["managementOverview", "dataSource", "dataSourceManagement"], "server": true, - "ui": true + "ui": true, + "supportedOSDataSourceVersions": ">=2.0.0", + "requiredOSDataSourcePlugins": ["opensearch-index-management"] } diff --git a/public/pages/Main/Main.tsx b/public/pages/Main/Main.tsx index e462fe10d..afa421113 100644 --- a/public/pages/Main/Main.tsx +++ b/public/pages/Main/Main.tsx @@ -7,7 +7,9 @@ import React, { Component } from "react"; import { Switch, Route, Redirect, RouteComponentProps } from "react-router-dom"; // @ts-ignore import { EuiSideNav, EuiPage, EuiPageBody, EuiPageSideBar } from "@elastic/eui"; -import { CoreStart, HttpSetup, MountPoint } from "opensearch-dashboards/public"; +import { CoreStart, HttpSetup, MountPoint, SavedObject } from "opensearch-dashboards/public"; +import queryString from "query-string"; +import semver from "semver"; import Policies from "../Policies"; import ManagedIndices from "../ManagedIndices"; import Indices from "../Indices"; @@ -59,13 +61,14 @@ import Notifications from "../Notifications"; import ComposableTemplates from "../ComposableTemplates"; import CreateComposableTemplate from "../CreateComposableTemplate"; import { DataSourceMenuContext, DataSourceMenuProperties } from "../../services/DataSourceMenuContext"; -import queryString from "query-string"; import { DataSourceManagementPluginSetup, DataSourceSelectableConfig, DataSourceViewConfig, } from "../../../../../src/plugins/data_source_management/public"; import { DataSourceOption } from "../../../../../src/plugins/data_source_management/public/components/data_source_menu/types"; +import * as pluginManifest from "../../../opensearch_dashboards.json"; +import { DataSourceAttributes } from "../../../../../src/plugins/data_source/common/data_sources"; enum Navigation { IndexManagement = "Index Management", @@ -192,8 +195,8 @@ export default class Main extends Component { dataSourceLabel = parsedDataSourceLabel || ""; } this.state = { - dataSourceId: dataSourceId, - dataSourceLabel: dataSourceLabel, + dataSourceId, + dataSourceLabel, dataSourceReadOnly: false, dataSourceLoading: props.multiDataSourceEnabled, }; @@ -257,6 +260,11 @@ export default class Main extends Component { } }; + dataSourceFilterFn = (dataSource: SavedObject) => { + const engineVersion = dataSource?.attributes?.dataSourceVersion || ""; + return semver.satisfies(engineVersion, pluginManifest.supportedOSDataSourceVersions); + }; + render() { const { location: { pathname }, @@ -400,6 +408,7 @@ export default class Main extends Component { componentConfig={{ activeOption, fullWidth: false, + dataSourceFilter: this.dataSourceFilterFn, }} /> ) : ( @@ -412,6 +421,7 @@ export default class Main extends Component { fullWidth: false, activeOption, onSelectedDataSources: this.onSelectedDataSources, + dataSourceFilter: this.dataSourceFilterFn, }} /> ) @@ -441,13 +451,13 @@ export default class Main extends Component { componentConfig={{ activeOption, fullWidth: false, + dataSourceFilter: this.dataSourceFilterFn, }} /> )} /> { fullWidth: false, activeOption, onSelectedDataSources: this.onSelectedDataSources, + dataSourceFilter: this.dataSourceFilterFn, }} /> )} /> + )} {!this.state.dataSourceLoading && (