From 9aa33d779e15bfa5281bcd91af140a42c25b270f Mon Sep 17 00:00:00 2001 From: Sumukh Swamy Date: Thu, 18 Jul 2024 15:37:42 -0700 Subject: [PATCH] added version decoupling for neo MDS support (#353) * added version decoupling for neo MDS suypport Signed-off-by: sumukhswamy * linter changes Signed-off-by: sumukhswamy * updated manifest file Signed-off-by: sumukhswamy * updated lowest version to 1 Signed-off-by: sumukhswamy --------- Signed-off-by: sumukhswamy --- opensearch_dashboards.json | 2 ++ public/components/Main/main.tsx | 32 +++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 351a4b4..26acfcf 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -4,6 +4,8 @@ "opensearchDashboardsVersion": "3.0.0", "server": true, "ui": true, + "supportedOSDataSourceVersions": ">=1.0.0", + "requiredOSDataSourcePlugins": ["opensearch-sql"], "requiredPlugins": ["navigation", "opensearchDashboardsReact", "opensearchDashboardsUtils"], "optionalPlugins": ["observabilityDashboards", "dataSource", "dataSourceManagement"] } \ 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 && (