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

plugin decoupling changes #1079

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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": ["data"],
"optionalPlugins": ["dataSource", "dataSourceManagement"],
"server": true,
"ui": true
"ui": true,
"supportedOSDataSourceVersions": ">=2.16.0",
"requiredOSDataSourcePlugins": ["opensearch_security_analytics"]
}
9 changes: 8 additions & 1 deletion public/components/MDS/DataSourceMenuWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import {
DataSourceSelectableConfig,
DataSourceViewConfig,
} from '../../../../../src/plugins/data_source_management/public';
import { AppMountParameters, CoreStart } from 'opensearch-dashboards/public';
import { AppMountParameters, CoreStart, SavedObject } from 'opensearch-dashboards/public';
import { ROUTES } from '../../utils/constants';
import { DataSourceContext } from '../../services/DataSourceContext';
import { DataSourceAttributes } from 'src/plugins/data_source/common/data_sources';

export interface DataSourceMenuWrapperProps {
core: CoreStart;
dataSourceManagement?: DataSourceManagementPluginSetup;
dataSourceMenuReadOnly: boolean;
dataSourceLoading: boolean;
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
dataSourceFilterFn?: (dataSource: SavedObject<DataSourceAttributes>) => boolean;
amsiglan marked this conversation as resolved.
Show resolved Hide resolved
}

export const DataSourceMenuWrapper: React.FC<DataSourceMenuWrapperProps> = ({
Expand All @@ -28,6 +30,7 @@ export const DataSourceMenuWrapper: React.FC<DataSourceMenuWrapperProps> = ({
dataSourceMenuReadOnly,
dataSourceLoading,
setHeaderActionMenu,
dataSourceFilterFn,
}) => {
if (!dataSourceManagement) {
return null;
Expand Down Expand Up @@ -64,6 +67,7 @@ export const DataSourceMenuWrapper: React.FC<DataSourceMenuWrapperProps> = ({
componentConfig={{
fullWidth: false,
activeOption: [dataSource],
dataSourceFilter: dataSourceFilterFn,
}}
componentType="DataSourceView"
setMenuMountPoint={setHeaderActionMenu}
Expand All @@ -79,6 +83,7 @@ export const DataSourceMenuWrapper: React.FC<DataSourceMenuWrapperProps> = ({
componentConfig={{
fullWidth: false,
activeOption: [dataSource],
dataSourceFilter: dataSourceFilterFn,
}}
componentType="DataSourceView"
setMenuMountPoint={setHeaderActionMenu}
Expand All @@ -93,6 +98,7 @@ export const DataSourceMenuWrapper: React.FC<DataSourceMenuWrapperProps> = ({
notifications: core.notifications,
onSelectedDataSources: setDataSource,
savedObjects: core.savedObjects.client,
dataSourceFilter: dataSourceFilterFn,
}}
/>
);
Expand Down Expand Up @@ -126,6 +132,7 @@ export const DataSourceMenuWrapper: React.FC<DataSourceMenuWrapperProps> = ({
notifications: core.notifications,
onSelectedDataSources: setDataSource,
savedObjects: core.savedObjects.client,
dataSourceFilter: dataSourceFilterFn,
}}
/>
);
Expand Down
15 changes: 14 additions & 1 deletion public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
EuiFlexItem,
} from '@elastic/eui';
import { Toast } from '@opensearch-project/oui/src/eui_components/toast/global_toast_list';
import { AppMountParameters, CoreStart } from 'opensearch-dashboards/public';
import { AppMountParameters, CoreStart, SavedObject } from 'opensearch-dashboards/public';
import { SaContextConsumer } from '../../services';
import { DEFAULT_DATE_RANGE, DATE_TIME_FILTER_KEY, ROUTES } from '../../utils/constants';
import { CoreServicesConsumer } from '../../components/core_services';
Expand Down Expand Up @@ -61,6 +61,9 @@ import { ThreatIntelOverview } from '../ThreatIntel/containers/Overview/ThreatIn
import { AddThreatIntelSource } from '../ThreatIntel/containers/AddThreatIntelSource/AddThreatIntelSource';
import { ThreatIntelScanConfigForm } from '../ThreatIntel/containers/ScanConfiguration/ThreatIntelScanConfigForm';
import { ThreatIntelSource } from '../ThreatIntel/containers/ThreatIntelSource/ThreatIntelSource';
import * as pluginManifest from "../../../opensearch_dashboards.json";
import { DataSourceAttributes } from "../../../../../src/plugins/data_source/common/data_sources";
import semver from "semver";

enum Navigation {
SecurityAnalytics = 'Security Analytics',
Expand Down Expand Up @@ -373,6 +376,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))
);
};

render() {
const {
landingPage,
Expand Down Expand Up @@ -419,6 +431,7 @@ export default class Main extends Component<MainProps, MainState> {
dataSourceLoading={this.state.dataSourceLoading}
dataSourceMenuReadOnly={dataSourceMenuReadOnly}
setHeaderActionMenu={setActionMenu}
dataSourceFilterFn={this.dataSourceFilterFn}
/>
)}
{!dataSourceLoading && services && (
Expand Down
Loading