Skip to content

Commit

Permalink
support for version decoupling
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn committed Jul 14, 2024
1 parent 738295f commit e05cede
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
"opensearchDashboardsUtils"
],
"server": true,
"ui": true
"ui": true,
"supportedOSDataSourceVersions": ">=2.3.0",
"requiredOSDataSourcePlugins": ["opensearch-alerting"]
}
12 changes: 12 additions & 0 deletions public/pages/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = {
Expand All @@ -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;
Expand Down

0 comments on commit e05cede

Please sign in to comment.