diff --git a/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx b/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx index 0d3586f9376f..ddd5b471a02c 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx +++ b/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx @@ -144,5 +144,7 @@ export const replaceLogPositionInQueryString = (time: number) => time, tiebreaker: 0, }, + end: new Date(time + ONE_HOUR).toISOString(), + start: new Date(time - ONE_HOUR).toISOString(), streamLive: false, }); diff --git a/x-pack/plugins/infra/public/pages/link_to/index.ts b/x-pack/plugins/infra/public/pages/link_to/index.ts index 4c8051f8da73..27e2d483f8fa 100644 --- a/x-pack/plugins/infra/public/pages/link_to/index.ts +++ b/x-pack/plugins/infra/public/pages/link_to/index.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -export { LinkToPage } from './link_to'; +export { LinkToLogsPage } from './link_to_logs'; +export { LinkToMetricsPage } from './link_to_metrics'; export { getNodeLogsUrl, RedirectToNodeLogs } from './redirect_to_node_logs'; export { getNodeDetailUrl, RedirectToNodeDetail } from './redirect_to_node_detail'; diff --git a/x-pack/plugins/infra/public/pages/link_to/link_to_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/link_to_logs.tsx new file mode 100644 index 000000000000..04d5c454a92c --- /dev/null +++ b/x-pack/plugins/infra/public/pages/link_to/link_to_logs.tsx @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { match as RouteMatch, Redirect, Route, Switch } from 'react-router-dom'; + +import { RedirectToLogs } from './redirect_to_logs'; +import { RedirectToNodeLogs } from './redirect_to_node_logs'; +import { inventoryModels } from '../../../common/inventory_models'; + +interface LinkToPageProps { + match: RouteMatch<{}>; + location: { + search: string; + }; +} + +const ITEM_TYPES = inventoryModels.map(m => m.id).join('|'); + +export const LinkToLogsPage: React.FC = props => { + return ( + + + + + + ); +}; diff --git a/x-pack/plugins/infra/public/pages/link_to/link_to.tsx b/x-pack/plugins/infra/public/pages/link_to/link_to_metrics.tsx similarity index 68% rename from x-pack/plugins/infra/public/pages/link_to/link_to.tsx rename to x-pack/plugins/infra/public/pages/link_to/link_to_metrics.tsx index ce62a0a3f4e3..3eb4a9f26fe2 100644 --- a/x-pack/plugins/infra/public/pages/link_to/link_to.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/link_to_metrics.tsx @@ -7,9 +7,7 @@ import React from 'react'; import { match as RouteMatch, Redirect, Route, Switch } from 'react-router-dom'; -import { RedirectToLogs } from './redirect_to_logs'; import { RedirectToNodeDetail } from './redirect_to_node_detail'; -import { RedirectToNodeLogs } from './redirect_to_node_logs'; import { RedirectToHostDetailViaIP } from './redirect_to_host_detail_via_ip'; import { inventoryModels } from '../../../common/inventory_models'; @@ -19,13 +17,9 @@ interface LinkToPageProps { const ITEM_TYPES = inventoryModels.map(m => m.id).join('|'); -export const LinkToPage: React.FC = props => { +export const LinkToMetricsPage: React.FC = props => { return ( - = props => { path={`${props.match.url}/host-detail-via-ip/:hostIp`} component={RedirectToHostDetailViaIP} /> - - + ); }; diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx index b4ed43f84e27..0556955e47f6 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx @@ -19,7 +19,7 @@ describe('RedirectToLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -33,7 +33,7 @@ describe('RedirectToLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx index 519ee6406093..1394fc48107e 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx @@ -73,7 +73,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -89,7 +89,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); diff --git a/x-pack/plugins/infra/public/routers/logs_router.tsx b/x-pack/plugins/infra/public/routers/logs_router.tsx index 6700ed1fc847..8258f087b587 100644 --- a/x-pack/plugins/infra/public/routers/logs_router.tsx +++ b/x-pack/plugins/infra/public/routers/logs_router.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { Route, Router, Switch } from 'react-router-dom'; import { NotFoundPage } from '../pages/404'; -import { LinkToPage } from '../pages/link_to'; +import { LinkToLogsPage } from '../pages/link_to'; import { LogsPage } from '../pages/logs'; import { RedirectWithQueryParams } from '../utils/redirect_with_query_params'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; @@ -19,7 +19,7 @@ export const LogsRouter: AppRouter = ({ history }) => { return ( - + {uiCapabilities?.logs?.show && ( )} diff --git a/x-pack/plugins/infra/public/routers/metrics_router.tsx b/x-pack/plugins/infra/public/routers/metrics_router.tsx index 7c2ebed8463f..7cb9de65e729 100644 --- a/x-pack/plugins/infra/public/routers/metrics_router.tsx +++ b/x-pack/plugins/infra/public/routers/metrics_router.tsx @@ -9,7 +9,7 @@ import { Route, Router, Switch } from 'react-router-dom'; import { NotFoundPage } from '../pages/404'; import { InfrastructurePage } from '../pages/infrastructure'; -import { LinkToPage } from '../pages/link_to'; +import { LinkToMetricsPage } from '../pages/link_to'; import { MetricDetail } from '../pages/metrics'; import { RedirectWithQueryParams } from '../utils/redirect_with_query_params'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; @@ -20,7 +20,7 @@ export const MetricsRouter: AppRouter = ({ history }) => { return ( - + {uiCapabilities?.infrastructure?.show && ( )} diff --git a/x-pack/test/functional/apps/infra/link_to.ts b/x-pack/test/functional/apps/infra/link_to.ts index 7e79f42ac94c..a287d53d5df0 100644 --- a/x-pack/test/functional/apps/infra/link_to.ts +++ b/x-pack/test/functional/apps/infra/link_to.ts @@ -25,7 +25,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('redirects to the logs app and parses URL search params correctly', async () => { const location = { hash: '', - pathname: '/link-to/logs', + pathname: '/link-to', search: `time=${timestamp}&filter=trace.id:${traceId}`, state: undefined, };