diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 3098ede0f..3e21a7fe0 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -16,5 +16,7 @@ "opensearchDashboardsUtils" ], "server": true, - "ui": true + "ui": true, + "supportedOSDataSourceVersions": ">=2.3.0", + "requiredOSDataSourcePlugins": ["opensearch-alerting"] } diff --git a/public/pages/Main/Main.js b/public/pages/Main/Main.js index 48e25a5d0..b3ffc6894 100644 --- a/public/pages/Main/Main.js +++ b/public/pages/Main/Main.js @@ -22,6 +22,8 @@ import { } from '../../../public/services'; import { MultiDataSourceContext } from '../../../public/utils/MultiDataSourceContext'; import { parseQueryStringAndGetDataSource } from '../utils/helpers'; +import * as pluginManifest from "../../../opensearch_dashboards.json"; +import semver from "semver"; class Main extends Component { static contextType = CoreContext; @@ -100,6 +102,15 @@ class Main extends Component { } }; + dataSourceFilterFn = (dataSource) => { + const engineVersion = dataSource?.attributes?.dataSourceVersion || ""; + const availablePlugins = dataSource?.attributes?.installedPlugins || []; + return ( + semver.satisfies(engineVersion, pluginManifest.supportedOSDataSourceVersions) && + pluginManifest.requiredOSDataSourcePlugins.every((plugin) => availablePlugins.includes(plugin)) + ); + }; + renderDataSourceComponent(dataSourceType) { const { setActionMenu } = this.props; const componentConfig = { @@ -109,6 +120,7 @@ class Main extends Component { : [{ id: this.state.selectedDataSourceId }], savedObjects: getSavedObjectsClient(), notifications: getNotifications(), + dataSourceFilter: this.dataSourceFilterFn, }; if (dataSourceType === 'DataSourceSelectable') { componentConfig.onSelectedDataSources = this.handleDataSourceChange;