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

feat: enable default route #1

Merged
merged 1 commit into from
Jul 5, 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: 4 additions & 0 deletions common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export const observabilityTracesID = 'observability-traces';
export const observabilityTracesTitle = 'Traces';
export const observabilityTracesPluginOrder = 5093;

export const observabilityServicesID = 'observability-services';
export const observabilityServicesTitle = 'Services';
export const observabilityServicesPluginOrder = 5092;

export const observabilityNotebookID = 'observability-notebooks';
export const observabilityNotebookTitle = 'Notebooks';
export const observabilityNotebookPluginOrder = 5094;
Expand Down
3 changes: 3 additions & 0 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
interface ObservabilityAppDeps {
CoreStartProp: CoreStart;
DepsStart: AppPluginStartDependencies;
pplService: any;

Check warning on line 28 in public/components/app.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
dslService: any;

Check warning on line 29 in public/components/app.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
savedObjects: any;

Check warning on line 30 in public/components/app.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
timestampUtils: any;

Check warning on line 31 in public/components/app.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
queryManager: QueryManager;
startPage: string;
dataSourceEnabled: boolean;
dataSourceManagement: DataSourceManagementPluginSetup;
setActionMenu: (menuMount: MountPoint | undefined) => void;
savedObjectsMDSClient: CoreStart['savedObjects'];
defaultRoute?: string;
}

// for cypress to test redux store
Expand Down Expand Up @@ -67,8 +68,9 @@
setActionMenu,
dataSourceEnabled,
savedObjectsMDSClient,
defaultRoute,
}: ObservabilityAppDeps) => {
const { chrome, http, notifications, savedObjects: coreSavedObjects } = CoreStartProp;

Check failure on line 73 in public/components/app.tsx

View workflow job for this annotation

GitHub Actions / Lint

'coreSavedObjects' is assigned a value but never used. Allowed unused vars must match /^_/u
const parentBreadcrumb = {
text: observabilityTitle,
href: `${observabilityID}#/`,
Expand Down Expand Up @@ -102,6 +104,7 @@
dataSourceEnabled={dataSourceEnabled}
setActionMenu={setActionMenu}
savedObjectsMDSClient={savedObjectsMDSClient}
defaultRoute={defaultRoute}
/>
</MetricsListener>
</I18nProvider>
Expand Down
4 changes: 3 additions & 1 deletion public/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
CoreStartProp: CoreStart,
DepsStart: AppPluginStartDependencies,
AppMountParametersProp: AppMountParameters,
pplService: any,

Check warning on line 18 in public/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
dslService: any,

Check warning on line 19 in public/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
savedObjects: any,

Check warning on line 20 in public/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
timestampUtils: any,

Check warning on line 21 in public/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
queryManager: QueryManager,
startPage: string,
dataSourcePluggables,
dataSourceManagement: DataSourceManagementPluginSetup,
savedObjectsMDSClient: CoreStart['savedObjects']
savedObjectsMDSClient: CoreStart['savedObjects'],
defaultRoute?: string,

Check failure on line 27 in public/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Delete `,`
) => {
const { setHeaderActionMenu } = AppMountParametersProp;
const { dataSource } = DepsStart;
Expand All @@ -42,6 +43,7 @@
setActionMenu={setHeaderActionMenu}
dataSourceEnabled={!!dataSource}
savedObjectsMDSClient={savedObjectsMDSClient}
defaultRoute={defaultRoute}
/>,
AppMountParametersProp.element
);
Expand Down
12 changes: 10 additions & 2 deletions public/components/trace_analytics/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { EuiGlobalToastList } from '@elastic/eui';
import { Toast } from '@elastic/eui/src/components/toast/global_toast_list';
import React, { ReactChild, useEffect, useState } from 'react';
import { HashRouter, Route, RouteComponentProps } from 'react-router-dom';
import { HashRouter, Route, RouteComponentProps, Redirect } from 'react-router-dom';
import {
ChromeBreadcrumb,
ChromeStart,
Expand Down Expand Up @@ -44,6 +44,7 @@
dataSourceManagement: DataSourceManagementPluginSetup;
setActionMenu: (menuMount: MountPoint | undefined) => void;
savedObjectsMDSClient: SavedObjectsStart;
defaultRoute?: string;
}

interface HomeProps extends RouteComponentProps, TraceAnalyticsCoreDeps {}
Expand All @@ -69,7 +70,7 @@
}: {
spanId: string;
isFlyoutVisible: boolean;
addSpanFilter: (field: string, value: any) => void;

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

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
spanMode: TraceAnalyticsMode;
spanDataSourceMDSId: string;
}) => void;
Expand Down Expand Up @@ -119,6 +120,7 @@

const [dataSourceMDSId, setDataSourceMDSId] = useState([{ id: '', label: '' }]);
const [currentSelectedService, setCurrentSelectedService] = useState('');
const { defaultRoute = '/services' } = props;

useEffect(() => {
handleDataPrepperIndicesExistRequest(
Expand All @@ -127,7 +129,7 @@
dataSourceMDSId[0].id
);
handleJaegerIndicesExistRequest(props.http, setJaegerIndicesExist, dataSourceMDSId[0].id);
}, [dataSourceMDSId]);

Check warning on line 132 in public/components/trace_analytics/home.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'props.http'. Either include it or remove the dependency array

const modes = [
{ id: 'jaeger', title: 'Jaeger', 'data-test-subj': 'jaeger-mode' },
Expand Down Expand Up @@ -326,7 +328,7 @@
/>
<Route
exact
path={['/services', '/']}
path={['/services']}
render={(_routerProps) => (
<TraceSideBar>
<Services
Expand Down Expand Up @@ -364,6 +366,12 @@
/>
)}
/>
<Route

Check failure on line 369 in public/components/trace_analytics/home.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎··········path="/"⏎··········render={()·=>·(⏎············<Redirect·to={defaultRoute}·/>⏎··········)}⏎·······` with `·path="/"·render={()·=>·<Redirect·to={defaultRoute}·/>}`
path="/"
render={() => (
<Redirect to={defaultRoute} />
)}
/>
</HashRouter>
{flyout}
{spanFlyoutComponent}
Expand Down
33 changes: 22 additions & 11 deletions public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
observabilityPanelsTitle,
observabilityPanelsTitleForNav,
observabilityPluginOrder,
observabilityServicesPluginOrder,
observabilityServicesTitle,
observabilityTracesID,
observabilityTracesPluginOrder,
observabilityTracesTitle,
Expand Down Expand Up @@ -269,7 +271,7 @@
// prometheus: openSearchLocalDataSourcePluggable
};

const appMountWithStartPage = (startPage: string) => async (params: AppMountParameters) => {
const appMountWithStartPage = (startPage: string, defaultRoute?: string) => async (params: AppMountParameters) => {

Check failure on line 274 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `params:·AppMountParameters` with `⏎······params:·AppMountParameters⏎····`
const { Observability } = await import('./components/index');
const [coreStart, depsStart] = await core.getStartServices();
const dslService = new DSLService(coreStart.http);
Expand All @@ -288,7 +290,8 @@
startPage,
dataSourcePluggables, // just pass down for now due to time constraint, later may better expose this as context
dataSourceManagement,
coreStart.savedObjects
coreStart.savedObjects,
defaultRoute,

Check failure on line 294 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Delete `,`
);
};

Expand Down Expand Up @@ -326,15 +329,23 @@

// NEEDS CORRECTION OR REFACTOR //ADAM
// The new-added applications need to be wrapped by a feature flag check.
// if (core.chrome.navGroup.getNavGroupEnabled()) {
// core.application.register({
// id: "observability-traces-nav",
// title: observabilityTracesTitle,
// order: observabilityTracesPluginOrder,
// category: DEFAULT_APP_CATEGORIES.investigate,
// mount: appMountWithStartPage('traces'),
// });
// }
if (core.chrome.navGroup.getNavGroupEnabled()) {
core.application.register({
id: "observability-traces-nav",

Check failure on line 334 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `"observability-traces-nav"` with `'observability-traces-nav'`
title: observabilityTracesTitle,
order: observabilityTracesPluginOrder,
category: DEFAULT_APP_CATEGORIES.investigate,
mount: appMountWithStartPage('traces', '/traces'),
});

core.application.register({
id: "observability-services-nav",

Check failure on line 342 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `"observability-services-nav"` with `'observability-services-nav'`
title: observabilityServicesTitle,
order: observabilityServicesPluginOrder,
category: DEFAULT_APP_CATEGORIES.investigate,
mount: appMountWithStartPage('traces', '/services'),
});
}

core.application.register({
id: observabilityNotebookID,
Expand Down
11 changes: 11 additions & 0 deletions public/plugin_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,15 @@ export function registerAllPluginNavGroups(core: CoreSetup<AppPluginStartDepende
category: DEFAULT_APP_CATEGORIES.dashboardAndReport,
},
]);

core.chrome.navGroup.addNavLinksToGroup(DEFAULT_NAV_GROUPS.analytics, [
{
id: 'observability-traces-nav',
category: DEFAULT_APP_CATEGORIES.investigate,
},
{
id: 'observability-services-nav',
category: DEFAULT_APP_CATEGORIES.investigate,
},
]);
}
Loading