Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding dataVersionFilter support to MDS to enable version decoupling #1080

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 || "";
RamakrishnaChilaka marked this conversation as resolved.
Show resolved Hide resolved
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
Loading