diff --git a/x-pack/plugins/infra/public/locators/discover_logs_locator.ts b/x-pack/plugins/infra/public/locators/discover_logs_locator.ts index 8693c5e281078..9e610d41af34b 100644 --- a/x-pack/plugins/infra/public/locators/discover_logs_locator.ts +++ b/x-pack/plugins/infra/public/locators/discover_logs_locator.ts @@ -7,13 +7,12 @@ import { LocatorDefinition, LocatorPublic } from '@kbn/share-plugin/public'; import type { LogsLocatorDependencies, LogsLocatorParams } from './logs_locator'; - -const DISCOVER_LOGS_LOCATOR_ID = 'DISCOVER_LOGS_LOCATOR'; +import { LOGS_LOCATOR_ID } from './logs_locator'; export type DiscoverLogsLocator = LocatorPublic; export class DiscoverLogsLocatorDefinition implements LocatorDefinition { - public readonly id = DISCOVER_LOGS_LOCATOR_ID; + public readonly id = LOGS_LOCATOR_ID; constructor(protected readonly deps: LogsLocatorDependencies) {} diff --git a/x-pack/plugins/infra/public/locators/discover_node_logs_locator.ts b/x-pack/plugins/infra/public/locators/discover_node_logs_locator.ts index 727c7abb401a5..e4ad2b34c5e66 100644 --- a/x-pack/plugins/infra/public/locators/discover_node_logs_locator.ts +++ b/x-pack/plugins/infra/public/locators/discover_node_logs_locator.ts @@ -7,13 +7,12 @@ import { LocatorDefinition, LocatorPublic } from '@kbn/share-plugin/public'; import type { NodeLogsLocatorDependencies, NodeLogsLocatorParams } from './node_logs_locator'; - -const DISCOVER_NODE_LOGS_LOCATOR_ID = 'DISCOVER_NODE_LOGS_LOCATOR'; +import { NODE_LOGS_LOCATOR_ID } from './node_logs_locator'; export type DiscoverNodeLogsLocator = LocatorPublic; export class DiscoverNodeLogsLocatorDefinition implements LocatorDefinition { - public readonly id = DISCOVER_NODE_LOGS_LOCATOR_ID; + public readonly id = NODE_LOGS_LOCATOR_ID; constructor(protected readonly deps: NodeLogsLocatorDependencies) {} diff --git a/x-pack/plugins/infra/public/locators/logs_locator.ts b/x-pack/plugins/infra/public/locators/logs_locator.ts index fd78b9cce74fe..3c95384ff9af7 100644 --- a/x-pack/plugins/infra/public/locators/logs_locator.ts +++ b/x-pack/plugins/infra/public/locators/logs_locator.ts @@ -11,7 +11,7 @@ import type { LogViewReference } from '../../common/log_views'; import type { TimeRange } from '../../common/time'; import type { InfraClientCoreSetup } from '../types'; -const LOGS_LOCATOR_ID = 'LOGS_LOCATOR'; +export const LOGS_LOCATOR_ID = 'LOGS_LOCATOR'; export interface LogsLocatorParams extends SerializableRecord { /** Defines log position */ diff --git a/x-pack/plugins/infra/public/locators/node_logs_locator.ts b/x-pack/plugins/infra/public/locators/node_logs_locator.ts index afa49882262c4..f0c9ad0ff73ca 100644 --- a/x-pack/plugins/infra/public/locators/node_logs_locator.ts +++ b/x-pack/plugins/infra/public/locators/node_logs_locator.ts @@ -9,7 +9,7 @@ import { LocatorDefinition, LocatorPublic } from '@kbn/share-plugin/public'; import type { InventoryItemType } from '../../common/inventory_models/types'; import type { LogsLocatorDependencies, LogsLocatorParams } from './logs_locator'; -const NODE_LOGS_LOCATOR_ID = 'NODE_LOGS_LOCATOR'; +export const NODE_LOGS_LOCATOR_ID = 'NODE_LOGS_LOCATOR'; export interface NodeLogsLocatorParams extends LogsLocatorParams { nodeId: string; 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 d2a10b0c4504f..0991c6dba1936 100644 --- a/x-pack/plugins/infra/public/pages/link_to/index.ts +++ b/x-pack/plugins/infra/public/pages/link_to/index.ts @@ -7,5 +7,5 @@ export { LinkToLogsPage } from './link_to_logs'; export { LinkToMetricsPage } from './link_to_metrics'; -export { getNodeLogsUrl, RedirectToNodeLogs } from './redirect_to_node_logs'; +export { 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/redirect_to_node_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx index ab5723427a1ec..7cf40df09b80e 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import { LinkDescriptor } from '@kbn/observability-shared-plugin/public'; import { useEffect } from 'react'; import { RouteComponentProps } from 'react-router-dom'; import { InventoryItemType } from '../../../common/inventory_models/types'; @@ -47,23 +46,3 @@ export const RedirectToNodeLogs = ({ return null; }; - -export const getNodeLogsUrl = ({ - nodeId, - nodeType, - time, -}: { - nodeId: string; - nodeType: InventoryItemType; - time?: number; -}): LinkDescriptor => { - return { - app: 'logs', - pathname: `link-to/${nodeType}-logs/${nodeId}`, - search: time - ? { - time: `${time}`, - } - : undefined, - }; -}; diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx index 773a1261e81e2..3024ff3d1bd06 100644 --- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx @@ -13,14 +13,16 @@ import { EuiFieldSearch } from '@elastic/eui'; import { EuiFlexGroup } from '@elastic/eui'; import { EuiFlexItem } from '@elastic/eui'; import { EuiButtonEmpty } from '@elastic/eui'; -import { useLinkProps } from '@kbn/observability-shared-plugin/public'; +import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; +import { useKibanaContextForPlugin } from '../../../../../../hooks/use_kibana'; import { TabContent, TabProps } from './shared'; import { LogStream } from '../../../../../../components/log_stream'; import { useWaffleOptionsContext } from '../../../hooks/use_waffle_options'; import { findInventoryFields } from '../../../../../../../common/inventory_models'; -import { getNodeLogsUrl } from '../../../../../link_to'; const TabComponent = (props: TabProps) => { + const { services } = useKibanaContextForPlugin(); + const { locators } = services; const [textQuery, setTextQuery] = useState(''); const [textQueryDebounced, setTextQueryDebounced] = useState(''); const endTimestamp = props.currentTime; @@ -46,13 +48,14 @@ const TabComponent = (props: TabProps) => { setTextQuery(e.target.value); }, []); - const nodeLogsMenuItemLinkProps = useLinkProps( - getNodeLogsUrl({ + const logsUrl = useMemo(() => { + return locators.nodeLogsLocator.getRedirectUrl({ nodeType, nodeId: node.id, time: startTimestamp, - }) - ); + filter: textQueryDebounced, + }); + }, [locators.nodeLogsLocator, node.id, nodeType, startTimestamp, textQueryDebounced]); return ( @@ -70,18 +73,20 @@ const TabComponent = (props: TabProps) => { /> - - - + + + + + = withTheme const [flyoutVisible, setFlyoutVisible] = useState(false); const inventoryModel = findInventoryModel(nodeType); const nodeDetailFrom = currentTime - inventoryModel.metrics.defaultTimeRangeInSeconds * 1000; - const { application, share } = useKibana() - .services; + const { services } = useKibanaContextForPlugin(); + const { application, share, locators } = services; const uiCapabilities = application?.capabilities; // Due to the changing nature of the fields between APM and this UI, // We need to have some exceptions until 7.0 & ECS is finalized. Reference @@ -76,13 +75,6 @@ export const NodeContextMenu: React.FC = withTheme return { label: '', value: '' }; }, [nodeType, node.ip, node.id]); - const nodeLogsMenuItemLinkProps = useLinkProps( - getNodeLogsUrl({ - nodeType, - nodeId: node.id, - time: currentTime, - }) - ); const nodeDetailMenuItemLinkProps = useLinkProps({ ...getNodeDetailUrl({ nodeType, @@ -104,7 +96,11 @@ export const NodeContextMenu: React.FC = withTheme defaultMessage: '{inventoryName} logs', values: { inventoryName: inventoryModel.singularDisplayName }, }), - ...nodeLogsMenuItemLinkProps, + href: locators.nodeLogsLocator.getRedirectUrl({ + nodeType, + nodeId: node.id, + time: currentTime, + }), 'data-test-subj': 'viewLogsContextMenuItem', isDisabled: !showLogsLink, };