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

[Backport 2.x] added version decoupling for neo MDS support (#353) #354

Merged
merged 1 commit into from
Jul 18, 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 @@ -13,5 +13,7 @@
"observabilityDashboards",
"dataSource",
"dataSourceManagement"
]
],
"supportedOSDataSourceVersions": ">=1.0.0",
"requiredOSDataSourcePlugins": ["opensearch-sql"]
}
32 changes: 25 additions & 7 deletions public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
import { createBrowserHistory } from 'history';
import _ from 'lodash';
import React from 'react';
import semver from 'semver';
import {
ChromeBreadcrumb,
CoreStart,
MountPoint,
NotificationsStart,
SavedObject,
SavedObjectsStart,
} from '../../../../../src/core/public';
import { DataSourceAttributes } from '../../../../../src/plugins/data_source/common/data_sources';
import {
DataSourceManagementPluginSetup,
DataSourceSelectableConfig,
Expand All @@ -38,6 +41,7 @@
import { AsyncApiResponse, AsyncQueryStatus } from '../../../common/types';
import { executeAsyncQuery } from '../../../common/utils/async_query_helpers';
import { fetchDataSources } from '../../../common/utils/fetch_datasources';
import * as pluginManifest from '../../../opensearch_dashboards.json';
import { MESSAGE_TAB_LABEL } from '../../utils/constants';
import {
Tree,
Expand All @@ -53,8 +57,8 @@
import { CreateButton } from '../SQLPage/CreateButton';
import { DataSelect } from '../SQLPage/DataSelect';
import { SQLPage } from '../SQLPage/SQLPage';
import { CatalogTree } from '../SQLPage/sql_catalog_tree/catalog_tree';

Check warning on line 60 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 61 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
interface ResponseData {
ok: boolean;
resp: any;
Expand All @@ -64,11 +68,11 @@
export interface ResponseDetail<T> {
fulfilled: boolean;
errorMessage?: string;
data?: T;

Check warning on line 71 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

export interface TranslateResult {
[key: string]: any;

Check warning on line 75 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

export interface QueryMessage {
Expand All @@ -88,13 +92,13 @@
disabled: boolean;
}

export interface ItemIdToExpandedRowMap {

Check warning on line 95 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
[key: string]: {
nodes: Tree;
expandedRow?: {};
selectedNodes?: { [key: string]: any };
};
}

Check warning on line 101 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

export interface DataRow {
rowId: number;
Expand Down Expand Up @@ -142,7 +146,7 @@
cluster: string;
dataSourceOptions: DataSourceOption[];
mdsClusterName: string;
flintDataConnections: boolean;

Check warning on line 149 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

const SUCCESS_MESSAGE = 'Success';
Expand Down Expand Up @@ -170,7 +174,7 @@
? JSON.parse(queryResultResponseDetail.data)
: queryResultResponseDetail.data;
const responseObj = queryResultResponseDetail.data ? resultData : '';
const fields: string[] = [];

Check warning on line 177 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const dataRows: DataRow[] = [];

const schema: object[] = _.get(responseObj, 'schema');
Expand All @@ -195,7 +199,7 @@
if (_.eq(_.get(field, 'name'), 'TABLE_NAME')) {
index = id;
break;
}

Check warning on line 202 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

for (const [id, field] of datarows.entries()) {
Expand All @@ -208,7 +212,7 @@
dataRows[id] = dataRow;
}
break;

Check warning on line 215 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
case 'describe':
case 'default':
for (const [id, field] of schema.entries()) {
Expand Down Expand Up @@ -284,11 +288,11 @@
refreshTree: false,
isAccelerationFlyoutOpened: false,
isCallOutVisible: false,
cluster: 'Indexes',

Check failure on line 291 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `,`
dataSourceOptions: [],
selectedMDSDataConnectionId: '',
mdsClusterName: '',
flintDataConnections: false
flintDataConnections: false,
};
this.httpClient = this.props.httpClient;
this.updateSQLQueries = _.debounce(this.updateSQLQueries, 250).bind(this);
Expand Down Expand Up @@ -896,15 +900,26 @@
const dataConnectionId = e[0] ? e[0].id : undefined;
const clusterName = e[0] ? e[0].label : '';
await this.setState({
selectedMDSDataConnectionId: dataConnectionId,

Check failure on line 903 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `,`
mdsClusterName: clusterName,
cluster: 'Indexes',
selectedDatasource: [{ label: 'OpenSearch', key: '' }],
isAccelerationFlyoutOpened: false
isAccelerationFlyoutOpened: false,
});
this.fetchFlintDataSources();
};

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

DataSourceMenu = this.props.dataSourceManagement?.ui?.getDataSourceMenu<
DataSourceSelectableConfig
>();
Expand Down Expand Up @@ -1003,7 +1018,7 @@
);
}

return (

Check failure on line 1021 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `marginRight:·'10px'` with `·marginRight:·'10px'·`
<>
{this.props.dataSourceEnabled && (
<this.DataSourceMenu
Expand All @@ -1011,25 +1026,28 @@
componentType={'DataSourceSelectable'}
componentConfig={{
savedObjects: this.props.savedObjects.client,
notifications: this.props.notifications,

Check failure on line 1029 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `'xs'` with `"xs"`
fullWidth: true,

Check failure on line 1030 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `··················<p><b>{this.state.mdsClusterName}</b>` with `················<p>⏎··················<b>{this.state.mdsClusterName}</b>⏎················`
onSelectedDataSources: this.onSelectedDataSource,

Check failure on line 1031 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
dataSourceFilter: this.dataSourceFilterFn,

Check failure on line 1032 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `··<EuiSpacer·size='s'` with `<EuiSpacer·size="s"·`
}}
/>
)}
<EuiPage paddingSize="none">
<EuiPanel grow={true} style={{marginRight: '10px'}}>
<EuiPanel grow={true} style={{ marginRight: '10px' }}>
<EuiPageSideBar
style={{
maxWidth: '400px',
width: '400px',
height: 'calc(100vh - 254px)',
}}
>
<EuiTitle size='xs'>
<p><b>{this.state.mdsClusterName}</b></p>
</EuiTitle>
<EuiSpacer size='s'/>
<EuiTitle size="xs">
<p>
<b>{this.state.mdsClusterName}</b>
</p>
</EuiTitle>
<EuiSpacer size="s" />
{this.state.flintDataConnections && (
<EuiFlexGroup direction="row" gutterSize="s">
<EuiFlexItem grow={false}>
Expand Down
Loading