diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 9f8491be3..b271aa5db 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -15,5 +15,7 @@ "dataSourceManagement" ], "server": true, - "ui": true -} \ No newline at end of file + "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..73498d603 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,15 @@ export default class Main extends Component { } }; + dataSourceFilterFn = (dataSource: SavedObject) => { + const engineVersion = dataSource?.attributes?.dataSourceVersion || ""; + const availablePlugins = dataSource?.attributes?.installedPlugins || []; + return ( + semver.satisfies(engineVersion, pluginManifest.supportedOSDataSourceVersions) && + pluginManifest.requiredOSDataSourcePlugins.every((plugin) => availablePlugins.includes(plugin)) + ); + }; + render() { const { location: { pathname }, @@ -400,6 +412,7 @@ export default class Main extends Component { componentConfig={{ activeOption, fullWidth: false, + dataSourceFilter: this.dataSourceFilterFn, }} /> ) : ( @@ -412,6 +425,7 @@ export default class Main extends Component { fullWidth: false, activeOption, onSelectedDataSources: this.onSelectedDataSources, + dataSourceFilter: this.dataSourceFilterFn, }} /> ) @@ -441,13 +455,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 && (