Skip to content

Commit

Permalink
MDS Version Decoupling (opensearch-project#314)
Browse files Browse the repository at this point in the history
Signed-off-by: saimedhi <[email protected]>
  • Loading branch information
saimedhi authored Aug 27, 2024
1 parent c8faaf7 commit 5828295
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
14 changes: 5 additions & 9 deletions opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
"server": true,
"ui": true,
"requiredBundles": [],
"requiredPlugins": [
"navigation",
"opensearchDashboardsUtils"
],
"optionalPlugins": [
"dataSource",
"dataSourceManagement"
]
}
"requiredPlugins": ["navigation", "opensearchDashboardsUtils"],
"optionalPlugins": ["dataSource", "dataSourceManagement"],
"supportedOSDataSourceVersions": ">=2.17.0 <4.0.0",
"requiredOSDataSourcePlugins": ["opensearch-ml", "opensearch-flow-framework"]
}
2 changes: 2 additions & 0 deletions public/pages/workflow_detail/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
SHOW_ACTIONS_IN_HEADER,
constructUrlWithParams,
getDataSourceId,
dataSourceFilterFn,
} from '../../../utils';
import { ExportModal } from './export_modal';
import {
Expand Down Expand Up @@ -143,6 +144,7 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
fullWidth: false,
savedObjects: getSavedObjectsClient(),
notifications: getNotifications(),
dataSourceFilter: dataSourceFilterFn,
}}
/>
);
Expand Down
3 changes: 2 additions & 1 deletion public/pages/workflows/workflows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -198,6 +198,7 @@ export function Workflows(props: WorkflowsProps) {
notifications: getNotifications(),
onSelectedDataSources: (dataSources) =>
handleDataSourceChange(dataSources),
dataSourceFilter: dataSourceFilterFn,
}}
/>
);
Expand Down
20 changes: 20 additions & 0 deletions public/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<DataSourceAttributes>
) => {
const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || '';
const installedPlugins = dataSource?.attributes?.installedPlugins || [];
return (
semver.satisfies(
dataSourceVersion,
pluginManifest.supportedOSDataSourceVersions
) &&
pluginManifest.requiredOSDataSourcePlugins.every((plugin) =>
installedPlugins.includes(plugin)
)
);
};

0 comments on commit 5828295

Please sign in to comment.