diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 0453ecc..4e5a3a6 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -13,5 +13,7 @@ "observabilityDashboards", "dataSource", "dataSourceManagement" - ] + ], + "supportedOSDataSourceVersions": ">=1.0.0", + "requiredOSDataSourcePlugins": ["opensearch-sql"] } \ No newline at end of file diff --git a/public/components/Main/main.tsx b/public/components/Main/main.tsx index 14c8035..183774b 100644 --- a/public/components/Main/main.tsx +++ b/public/components/Main/main.tsx @@ -22,13 +22,16 @@ import { IHttpResponse } from 'angular'; import { createBrowserHistory } from 'history'; import _ from 'lodash'; import React from 'react'; +import semver from 'semver'; import { ChromeBreadcrumb, CoreStart, MountPoint, NotificationsStart, + SavedObject, SavedObjectsStart, } from '../../../../../src/core/public'; +import { DataSourceAttributes } from '../../../../../src/plugins/data_source/common/data_sources'; import { DataSourceManagementPluginSetup, DataSourceSelectableConfig, @@ -38,6 +41,7 @@ import { OPENSEARCH_SQL_INIT_QUERY } from '../../../common/constants'; import { AsyncApiResponse, AsyncQueryStatus } from '../../../common/types'; import { executeAsyncQuery } from '../../../common/utils/async_query_helpers'; import { fetchDataSources } from '../../../common/utils/fetch_datasources'; +import * as pluginManifest from '../../../opensearch_dashboards.json'; import { MESSAGE_TAB_LABEL } from '../../utils/constants'; import { Tree, @@ -288,7 +292,7 @@ export class Main extends React.Component { dataSourceOptions: [], selectedMDSDataConnectionId: '', mdsClusterName: '', - flintDataConnections: false + flintDataConnections: false, }; this.httpClient = this.props.httpClient; this.updateSQLQueries = _.debounce(this.updateSQLQueries, 250).bind(this); @@ -900,11 +904,22 @@ export class Main extends React.Component { mdsClusterName: clusterName, cluster: 'Indexes', selectedDatasource: [{ label: 'OpenSearch', key: '' }], - isAccelerationFlyoutOpened: false + isAccelerationFlyoutOpened: false, }); this.fetchFlintDataSources(); }; + dataSourceFilterFn = (dataSource: SavedObject) => { + const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || ''; + const installedPlugins = dataSource?.attributes?.installedPlugins || []; + return ( + semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions) && + pluginManifest.requiredOSDataSourcePlugins.every((plugin) => + installedPlugins.includes(plugin) + ) + ); + }; + DataSourceMenu = this.props.dataSourceManagement?.ui?.getDataSourceMenu< DataSourceSelectableConfig >(); @@ -1014,11 +1029,12 @@ export class Main extends React.Component { notifications: this.props.notifications, fullWidth: true, onSelectedDataSources: this.onSelectedDataSource, + dataSourceFilter: this.dataSourceFilterFn, }} /> )} - + { height: 'calc(100vh - 254px)', }} > - -

{this.state.mdsClusterName}

-
- + +

+ {this.state.mdsClusterName} +

+
+ {this.state.flintDataConnections && (