Skip to content

Commit

Permalink
Backport/backporting to 2.x (#223)
Browse files Browse the repository at this point in the history
* bumping up the opensearch dashboards versions

Signed-off-by: Riya Saxena <[email protected]>

* version decoupling support (#221)

* version decoupling support

Signed-off-by: Riya Saxena <[email protected]>

* addressed the comments

Signed-off-by: Riya Saxena <[email protected]>

---------

Signed-off-by: Riya Saxena <[email protected]>
(cherry picked from commit aba3a4c)

---------

Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya <[email protected]>
  • Loading branch information
riysaxen-amzn authored Jul 18, 2024
1 parent 786e1bd commit 2c05621
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
6 changes: 4 additions & 2 deletions opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"dataSourceManagement"
],
"server": true,
"ui": true
}
"ui": true,
"supportedOSDataSourceVersions": ">=2.0.0",
"requiredOSDataSourcePlugins": ["opensearch-notifications"]
}
25 changes: 20 additions & 5 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { EuiPage, EuiPageBody, EuiPageSideBar, EuiSideNav } from '@elastic/eui';
import React, { Component, createContext, useContext } from 'react';
import { Redirect, Route, RouteComponentProps, Switch } from 'react-router-dom';
import { CoreStart } from '../../../../../src/core/public';
import { CoreStart, SavedObject } from '../../../../../src/core/public';
import { CoreServicesConsumer, CoreServicesContext } from '../../components/coreServices';
import { ModalProvider, ModalRoot } from '../../components/Modal';
import { BrowserServices } from '../../models/interfaces';
Expand All @@ -32,7 +32,9 @@ import { DataSourceOption } from "../../../../../src/plugins/data_source_managem
import _ from "lodash";
import { NotificationService } from '../../services';
import { HttpSetup } from '../../../../../src/core/public';
import * as http from 'http';
import * as pluginManifest from "../../../opensearch_dashboards.json";
import { DataSourceAttributes } from "../../../../../src/plugins/data_source/common/data_sources";
import semver from "semver";

enum Navigation {
Notifications = 'Notifications',
Expand Down Expand Up @@ -104,7 +106,7 @@ export default class Main extends Component<MainProps, MainState> {
}
}

async setServerFeatures() : Promise<void> {
async setServerFeatures() : Promise<void> {
const services = this.getServices(this.props.http);
const serverFeatures = await services.notificationService.getServerFeatures();
const defaultConfigTypes = [
Expand Down Expand Up @@ -145,7 +147,7 @@ export default class Main extends Component<MainProps, MainState> {
onSelectedDataSources = (dataSources: DataSourceOption[]) => {
const { id = "", label = "" } = dataSources[0] || {};
if (this.state.dataSourceId !== id || this.state.dataSourceLabel !==label) {
this.setState({
this.setState({
dataSourceId: id,
dataSourceLabel: label,
});
Expand All @@ -157,6 +159,15 @@ export default class Main extends Component<MainProps, MainState> {
}
};

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))
);
};

getServices(http: HttpSetup) {
const {
location: { pathname },
Expand Down Expand Up @@ -252,6 +263,7 @@ export default class Main extends Component<MainProps, MainState> {
componentType={"DataSourceView"}
componentConfig={{
activeOption: [{ label: this.state.dataSourceLabel, id: this.state.dataSourceId }],
dataSourceFilter: this.dataSourceFilterFn,
}}
/>
)}
Expand All @@ -278,6 +290,7 @@ export default class Main extends Component<MainProps, MainState> {
fullWidth: false,
activeOption,
onSelectedDataSources: this.onSelectedDataSources,
dataSourceFilter: this.dataSourceFilterFn,
}}
/>
)}
Expand All @@ -292,6 +305,7 @@ export default class Main extends Component<MainProps, MainState> {
componentConfig={{
activeOption: [{ label: this.state.dataSourceLabel, id: this.state.dataSourceId }],
fullWidth: false,
dataSourceFilter: this.dataSourceFilterFn,
}}
/>
) : (
Expand All @@ -304,6 +318,7 @@ export default class Main extends Component<MainProps, MainState> {
fullWidth: false,
activeOption,
onSelectedDataSources: this.onSelectedDataSources,
dataSourceFilter: this.dataSourceFilterFn,
}}
/>
)
Expand Down Expand Up @@ -443,4 +458,4 @@ export default class Main extends Component<MainProps, MainState> {
</CoreServicesConsumer>
);
}
}
}

0 comments on commit 2c05621

Please sign in to comment.