From 582829591eecdb409c75ecd9e4288612c383a1b5 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada <117196660+saimedhi@users.noreply.github.com> Date: Tue, 27 Aug 2024 09:00:15 -0700 Subject: [PATCH] MDS Version Decoupling (#314) Signed-off-by: saimedhi --- opensearch_dashboards.json | 14 +++++-------- .../workflow_detail/components/header.tsx | 2 ++ public/pages/workflows/workflows.tsx | 3 ++- public/utils/utils.ts | 20 +++++++++++++++++++ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 3c23f504..6b21d08a 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -5,12 +5,8 @@ "server": true, "ui": true, "requiredBundles": [], - "requiredPlugins": [ - "navigation", - "opensearchDashboardsUtils" - ], - "optionalPlugins": [ - "dataSource", - "dataSourceManagement" - ] -} \ No newline at end of file + "requiredPlugins": ["navigation", "opensearchDashboardsUtils"], + "optionalPlugins": ["dataSource", "dataSourceManagement"], + "supportedOSDataSourceVersions": ">=2.17.0 <4.0.0", + "requiredOSDataSourcePlugins": ["opensearch-ml", "opensearch-flow-framework"] +} diff --git a/public/pages/workflow_detail/components/header.tsx b/public/pages/workflow_detail/components/header.tsx index b967c63f..c020614f 100644 --- a/public/pages/workflow_detail/components/header.tsx +++ b/public/pages/workflow_detail/components/header.tsx @@ -27,6 +27,7 @@ import { SHOW_ACTIONS_IN_HEADER, constructUrlWithParams, getDataSourceId, + dataSourceFilterFn, } from '../../../utils'; import { ExportModal } from './export_modal'; import { @@ -143,6 +144,7 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) { fullWidth: false, savedObjects: getSavedObjectsClient(), notifications: getNotifications(), + dataSourceFilter: dataSourceFilterFn, }} /> ); diff --git a/public/pages/workflows/workflows.tsx b/public/pages/workflows/workflows.tsx index 0f15755e..303af723 100644 --- a/public/pages/workflows/workflows.tsx +++ b/public/pages/workflows/workflows.tsx @@ -30,7 +30,7 @@ import { ImportWorkflowModal } from './import_workflow'; import { MountPoint } from '../../../../../src/core/public'; import { DataSourceSelectableConfig } from '../../../../../src/plugins/data_source_management/public'; -import { getDataSourceFromURL } from '../../utils/utils'; +import { dataSourceFilterFn, getDataSourceFromURL } from '../../utils/utils'; import { getDataSourceManagementPlugin, @@ -198,6 +198,7 @@ export function Workflows(props: WorkflowsProps) { notifications: getNotifications(), onSelectedDataSources: (dataSources) => handleDataSourceChange(dataSources), + dataSourceFilter: dataSourceFilterFn, }} /> ); diff --git a/public/utils/utils.ts b/public/utils/utils.ts index 11a71a59..b22dffae 100644 --- a/public/utils/utils.ts +++ b/public/utils/utils.ts @@ -25,6 +25,10 @@ import { getCore, getDataSourceEnabled } from '../services'; import { MDSQueryParams } from '../../common/interfaces'; import queryString from 'query-string'; import { useLocation } from 'react-router-dom'; +import * as pluginManifest from '../../opensearch_dashboards.json'; +import { DataSourceAttributes } from '../../../../src/plugins/data_source/common/data_sources'; +import { SavedObject } from '../../../../src/core/public'; +import semver from 'semver'; // Append 16 random characters export function generateId(prefix?: string): string { @@ -282,3 +286,19 @@ export function camelCaseToTitleString(snakeCaseString: string): string { .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) .join(' '); } + +export const 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) + ) + ); +};