Skip to content

Commit

Permalink
version-dec
Browse files Browse the repository at this point in the history
Signed-off-by: sumukhswamy <[email protected]>
  • Loading branch information
sumukhswamy committed Jul 22, 2024
1 parent ec8ee32 commit 19f9b1b
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 13 deletions.
11 changes: 10 additions & 1 deletion public/components/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@ import debounce from 'lodash/debounce';
import React, { useEffect, useMemo, useState } from 'react';
import { useDispatch } from 'react-redux';
import { HashRouter, Route, RouteComponentProps, StaticContext } from 'react-router-dom';
import semver from 'semver';
import {
ChromeBreadcrumb,
MountPoint,
NotificationsStart,
SavedObject,
SavedObjectsStart,
} from '../../../../../src/core/public';
import { DataSourceAttributes } from '../../../../../src/plugins/data_source/common/data_sources';
import {
DataSourceManagementPluginSetup,
DataSourceSelectableConfig,
} from '../../../../../src/plugins/data_source_management/public';
import { DataSourceOption } from '../../../../../src/plugins/data_source_management/public/components/data_source_menu/types';
import { OptionType } from '../../../common/types/metrics';
import { setNavBreadCrumbs } from '../../../common/utils/set_nav_bread_crumbs';
import * as pluginManifest from '../../../opensearch_dashboards.json';
import PPLService from '../../services/requests/ppl';
import SavedObjects from '../../services/saved_objects/event_analytics/saved_objects';
import './index.scss';
import { setSelectedDataSourceMDSId } from './redux/slices/metrics_slice';
import { Sidebar } from './sidebar/sidebar';
import { TopMenu } from './top_menu/top_menu';
import { MetricsGrid } from './view/metrics_grid';
import { setNavBreadCrumbs } from '../../../common/utils/set_nav_bread_crumbs';

interface MetricsProps {
parentBreadcrumb: ChromeBreadcrumb;
Expand Down Expand Up @@ -82,6 +86,10 @@ export const Home = ({
dispatch(setSelectedDataSourceMDSId(id));
}, 300);
};
const dataSourceFilterFn = (dataSource: SavedObject<DataSourceAttributes>) => {
const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || '';
return semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions);
};
const DataSourceMenu = dataSourceManagement?.ui?.getDataSourceMenu<DataSourceSelectableConfig>();
const dataSourceMenuComponent = useMemo(() => {
return (
Expand All @@ -94,6 +102,7 @@ export const Home = ({
fullWidth: true,
// activeOption: dataSourceMDSId,
onSelectedDataSources: onSelectedDataSource,
dataSourceFilter: dataSourceFilterFn,
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ import {
import filter from 'lodash/filter';
import moment from 'moment';
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import { CoreStart, MountPoint, SavedObjectsStart } from '../../../../../../../src/core/public';
import semver from 'semver';
import {
CoreStart,
MountPoint,
SavedObject,
SavedObjectsStart,
} from '../../../../../../../src/core/public';
import {
DashboardContainerInput,
DashboardStart,
} from '../../../../../../../src/plugins/dashboard/public';
import { DataSourceAttributes } from '../../../../../../../src/plugins/data_source/common/data_sources';
import { DataSourceManagementPluginSetup } from '../../../../../../../src/plugins/data_source_management/public';
import { ViewMode } from '../../../../../../../src/plugins/embeddable/public';
import { NOTEBOOKS_API_PREFIX } from '../../../../../common/constants/notebooks';
Expand All @@ -39,6 +46,7 @@ import {
} from '../../../../../common/constants/shared';
import { ParaType } from '../../../../../common/types/notebooks';
import { uiSettingsService } from '../../../../../common/utils';
import * as pluginManifest from '../../../../../opensearch_dashboards.json';
import PPLService from '../../../../services/requests/ppl';
import { SavedObjectsActions } from '../../../../services/saved_objects/saved_object_client/saved_objects_actions';
import { ObservabilitySavedVisualization } from '../../../../services/saved_objects/saved_object_client/types';
Expand Down Expand Up @@ -549,6 +557,11 @@ export const Paragraphs = forwardRef((props: ParagraphProps, ref) => {
setDataSourceMDSId(dataConnectionId);
handleSelectedDataSourceChange(dataConnectionId, dataConnectionLabel);
};
const dataSourceFilterFn = (dataSource: SavedObject<DataSourceAttributes>) => {
const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || '';
return semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions);
};

if (dataSourceEnabled) {
DataSourceSelector = dataSourceManagement.ui.DataSourceSelector;
}
Expand All @@ -564,11 +577,13 @@ export const Paragraphs = forwardRef((props: ParagraphProps, ref) => {
disabled={false}
fullWidth={false}
removePrepend={true}
dataSourceFilter={dataSourceFilterFn}
defaultOption={
paradataSourceMDSId !== undefined && [
{ id: paradataSourceMDSId, label: dataSourceMDSLabel },
]
}
filter
/>
)}
<EuiSpacer size="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import {
} from '@elastic/eui';
import round from 'lodash/round';
import React, { useEffect, useMemo, useState } from 'react';
import semver from 'semver';
import { SavedObject } from '../../../../../../../src/core/public';
import { DataSourceAttributes } from '../../../../../../../src/plugins/data_source/common/data_sources';
import {
DataSourceManagementPluginSetup,
DataSourceViewConfig,
Expand All @@ -37,6 +40,8 @@ import {
DEFAULT_DATA_SOURCE_TYPE,
} from '../../../../../common/constants/data_sources';
import { observabilityLogsID } from '../../../../../common/constants/shared';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';
import * as pluginManifest from '../../../../../opensearch_dashboards.json';
import { coreRefs } from '../../../../framework/core_refs';
import { TraceAnalyticsComponentDeps } from '../../home';
import {
Expand All @@ -50,7 +55,6 @@ import { SearchBarProps, renderDatePicker } from '../common/search_bar';
import { SpanDetailFlyout } from '../traces/span_detail_flyout';
import { SpanDetailTable } from '../traces/span_detail_table';
import { ServiceMetrics } from './service_metrics';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';

interface ServiceViewProps extends TraceAnalyticsComponentDeps {
serviceName: string;
Expand Down Expand Up @@ -121,6 +125,10 @@ export function ServiceView(props: ServiceViewProps) {
);
}, [props.serviceName]);

const dataSourceFilterFn = (dataSource: SavedObject<DataSourceAttributes>) => {
const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || '';
return semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions);
};
const DataSourceMenu = props.dataSourceManagement?.ui?.getDataSourceMenu<DataSourceViewConfig>();

const redirectToServicePage = (service: string) => {
Expand Down Expand Up @@ -260,6 +268,7 @@ export function ServiceView(props: ServiceViewProps) {
componentConfig={{
activeOption: props.dataSourceMDSId,
fullWidth: true,
dataSourceFilter: dataSourceFilterFn,
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,27 @@ exports[`Traces component renders empty traces page 1`] = `
},
"navGroup": Object {
"getCurrentNavGroup$": [MockFunction],
"getNavGroupEnabled": [MockFunction],
"getNavGroupEnabled": [MockFunction] {
"calls": Array [
Array [],
Array [],
Array [],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
},
"getNavGroupsMap$": [MockFunction],
"setCurrentNavGroup": [MockFunction],
},
Expand Down Expand Up @@ -440,7 +460,27 @@ exports[`Traces component renders empty traces page 1`] = `
},
"navGroup": Object {
"getCurrentNavGroup$": [MockFunction],
"getNavGroupEnabled": [MockFunction],
"getNavGroupEnabled": [MockFunction] {
"calls": Array [
Array [],
Array [],
Array [],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
},
"getNavGroupsMap$": [MockFunction],
"setCurrentNavGroup": [MockFunction],
},
Expand Down Expand Up @@ -1739,7 +1779,27 @@ exports[`Traces component renders jaeger traces page 1`] = `
},
"navGroup": Object {
"getCurrentNavGroup$": [MockFunction],
"getNavGroupEnabled": [MockFunction],
"getNavGroupEnabled": [MockFunction] {
"calls": Array [
Array [],
Array [],
Array [],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
},
"getNavGroupsMap$": [MockFunction],
"setCurrentNavGroup": [MockFunction],
},
Expand Down Expand Up @@ -2074,7 +2134,27 @@ exports[`Traces component renders jaeger traces page 1`] = `
},
"navGroup": Object {
"getCurrentNavGroup$": [MockFunction],
"getNavGroupEnabled": [MockFunction],
"getNavGroupEnabled": [MockFunction] {
"calls": Array [
Array [],
Array [],
Array [],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
},
"getNavGroupsMap$": [MockFunction],
"setCurrentNavGroup": [MockFunction],
},
Expand Down Expand Up @@ -3378,7 +3458,27 @@ exports[`Traces component renders traces page 1`] = `
},
"navGroup": Object {
"getCurrentNavGroup$": [MockFunction],
"getNavGroupEnabled": [MockFunction],
"getNavGroupEnabled": [MockFunction] {
"calls": Array [
Array [],
Array [],
Array [],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
},
"getNavGroupsMap$": [MockFunction],
"setCurrentNavGroup": [MockFunction],
},
Expand Down Expand Up @@ -3712,7 +3812,27 @@ exports[`Traces component renders traces page 1`] = `
},
"navGroup": Object {
"getCurrentNavGroup$": [MockFunction],
"getNavGroupEnabled": [MockFunction],
"getNavGroupEnabled": [MockFunction] {
"calls": Array [
Array [],
Array [],
Array [],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
},
"getNavGroupsMap$": [MockFunction],
"setCurrentNavGroup": [MockFunction],
},
Expand Down
12 changes: 10 additions & 2 deletions public/components/trace_analytics/components/traces/trace_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ import {
} from '@elastic/eui';
import round from 'lodash/round';
import React, { useEffect, useState } from 'react';
import { MountPoint } from '../../../../../../../src/core/public';
import semver from 'semver';
import { MountPoint, SavedObject } from '../../../../../../../src/core/public';
import { DataSourceAttributes } from '../../../../../../../src/plugins/data_source/common/data_sources/types';
import {
DataSourceManagementPluginSetup,
DataSourceViewConfig,
} from '../../../../../../../src/plugins/data_source_management/public';
import { DataSourceOption } from '../../../../../../../src/plugins/data_source_management/public/components/data_source_menu/types';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';
import * as pluginManifest from '../../../../../opensearch_dashboards.json';
import { TraceAnalyticsCoreDeps, TraceAnalyticsMode } from '../../home';
import { handleServiceMapRequest } from '../../requests/services_request_handler';
import {
Expand All @@ -37,7 +41,6 @@ import { PanelTitle, filtersToDsl, processTimeStamp } from '../common/helper_fun
import { ServiceMap, ServiceObject } from '../common/plots/service_map';
import { ServiceBreakdownPanel } from './service_breakdown_panel';
import { SpanDetailPanel } from './span_detail_panel';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';

interface TraceViewProps extends TraceAnalyticsCoreDeps {
traceId: string;
Expand All @@ -62,6 +65,10 @@ export function TraceView(props: TraceViewProps) {
);
};
const DataSourceMenu = props.dataSourceManagement?.ui?.getDataSourceMenu<DataSourceViewConfig>();
const dataSourceFilterFn = (dataSource: SavedObject<DataSourceAttributes>) => {
const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || '';
return semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions);
};

const renderOverview = (fields: any) => {

Check warning on line 73 in public/components/trace_analytics/components/traces/trace_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
return (
Expand Down Expand Up @@ -260,6 +267,7 @@ export function TraceView(props: TraceViewProps) {
componentConfig={{
activeOption: props.dataSourceMDSId,
fullWidth: true,
dataSourceFilter: dataSourceFilterFn,
}}
/>
)}
Expand Down
Loading

0 comments on commit 19f9b1b

Please sign in to comment.