Skip to content

Commit

Permalink
Adding dataVersionFilter support to MDS to enable version decoupling (#…
Browse files Browse the repository at this point in the history
…1080)

* Adding dataVersionFilter support to MDS to enable version decoupling

Signed-off-by: Ramakrishna Chilaka <[email protected]>

* added check for checking available plugins on a datasource

Signed-off-by: Ramakrishna Chilaka <[email protected]>

---------

Signed-off-by: Ramakrishna Chilaka <[email protected]>
  • Loading branch information
RamakrishnaChilaka authored Jul 11, 2024
1 parent 9b140e3 commit 50c2275
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
4 changes: 3 additions & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"requiredPlugins": ["navigation", "opensearchDashboardsReact"],
"optionalPlugins": ["managementOverview", "dataSource", "dataSourceManagement"],
"server": true,
"ui": true
"ui": true,
"supportedOSDataSourceVersions": ">=2.0.0",
"requiredOSDataSourcePlugins": ["opensearch-index-management"]
}
26 changes: 21 additions & 5 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import React, { Component } from "react";
import { Switch, Route, Redirect, RouteComponentProps } from "react-router-dom";
// @ts-ignore
import { EuiSideNav, EuiPage, EuiPageBody, EuiPageSideBar } from "@elastic/eui";
import { CoreStart, HttpSetup, MountPoint } from "opensearch-dashboards/public";
import { CoreStart, HttpSetup, MountPoint, SavedObject } from "opensearch-dashboards/public";
import queryString from "query-string";
import semver from "semver";
import Policies from "../Policies";
import ManagedIndices from "../ManagedIndices";
import Indices from "../Indices";
Expand Down Expand Up @@ -59,13 +61,14 @@ import Notifications from "../Notifications";
import ComposableTemplates from "../ComposableTemplates";
import CreateComposableTemplate from "../CreateComposableTemplate";
import { DataSourceMenuContext, DataSourceMenuProperties } from "../../services/DataSourceMenuContext";
import queryString from "query-string";
import {
DataSourceManagementPluginSetup,
DataSourceSelectableConfig,
DataSourceViewConfig,
} from "../../../../../src/plugins/data_source_management/public";
import { DataSourceOption } from "../../../../../src/plugins/data_source_management/public/components/data_source_menu/types";
import * as pluginManifest from "../../../opensearch_dashboards.json";
import { DataSourceAttributes } from "../../../../../src/plugins/data_source/common/data_sources";

enum Navigation {
IndexManagement = "Index Management",
Expand Down Expand Up @@ -192,8 +195,8 @@ export default class Main extends Component<MainProps, MainState> {
dataSourceLabel = parsedDataSourceLabel || "";
}
this.state = {
dataSourceId: dataSourceId,
dataSourceLabel: dataSourceLabel,
dataSourceId,
dataSourceLabel,
dataSourceReadOnly: false,
dataSourceLoading: props.multiDataSourceEnabled,
};
Expand Down Expand Up @@ -257,6 +260,15 @@ export default class Main extends Component<MainProps, MainState> {
}
};

dataSourceFilterFn = (dataSource: SavedObject<DataSourceAttributes>) => {
const engineVersion = dataSource?.attributes?.dataSourceVersion || "";
const availablePlugins = dataSource?.attributes?.installedPlugins || [];
return (
semver.satisfies(engineVersion, pluginManifest.supportedOSDataSourceVersions) &&
pluginManifest.requiredOSDataSourcePlugins.every((plugin) => availablePlugins.includes(plugin))
);
};

render() {
const {
location: { pathname },
Expand Down Expand Up @@ -400,6 +412,7 @@ export default class Main extends Component<MainProps, MainState> {
componentConfig={{
activeOption,
fullWidth: false,
dataSourceFilter: this.dataSourceFilterFn,
}}
/>
) : (
Expand All @@ -412,6 +425,7 @@ export default class Main extends Component<MainProps, MainState> {
fullWidth: false,
activeOption,
onSelectedDataSources: this.onSelectedDataSources,
dataSourceFilter: this.dataSourceFilterFn,
}}
/>
)
Expand Down Expand Up @@ -441,13 +455,13 @@ export default class Main extends Component<MainProps, MainState> {
componentConfig={{
activeOption,
fullWidth: false,
dataSourceFilter: this.dataSourceFilterFn,
}}
/>
)}
/>
<Route
path={[
"/",
ROUTES.INDICES,
ROUTES.CREATE_INDEX,
ROUTES.ALIASES,
Expand All @@ -474,10 +488,12 @@ export default class Main extends Component<MainProps, MainState> {
fullWidth: false,
activeOption,
onSelectedDataSources: this.onSelectedDataSources,
dataSourceFilter: this.dataSourceFilterFn,
}}
/>
)}
/>
<Redirect from="/" to={landingPage} />
</Switch>
)}
{!this.state.dataSourceLoading && (
Expand Down

0 comments on commit 50c2275

Please sign in to comment.