From 66c4980fc12ab614f8fe7e5d4a1c944e689381dc Mon Sep 17 00:00:00 2001 From: Carlos Crespo Date: Thu, 7 Sep 2023 15:24:04 +0200 Subject: [PATCH] Revert changes --- .../asset_details/hooks/use_page_header.tsx | 2 +- .../public/hooks/create_use_rules_link.ts | 50 +------------------ .../components/sections/metrics/host_link.tsx | 28 ++--------- 3 files changed, 7 insertions(+), 73 deletions(-) diff --git a/x-pack/plugins/infra/public/components/asset_details/hooks/use_page_header.tsx b/x-pack/plugins/infra/public/components/asset_details/hooks/use_page_header.tsx index 5edfc6c8ce45..fd77e4d776a8 100644 --- a/x-pack/plugins/infra/public/components/asset_details/hooks/use_page_header.tsx +++ b/x-pack/plugins/infra/public/components/asset_details/hooks/use_page_header.tsx @@ -60,7 +60,7 @@ export const useTemplateHeaderBreadcrumbs = () => { const breadcrumbs: EuiBreadcrumbsProps['breadcrumbs'] = // If there is a state object in location, it's persisted in case the page is opened in a new tab or after page refresh // With that, we can show the return button. Otherwise, it will be hidden (ex: the user opened a shared URL or opened the page from their bookmarks) - location.state || location.key + location.state || history.length > 1 ? [ { text: ( diff --git a/x-pack/plugins/observability/public/hooks/create_use_rules_link.ts b/x-pack/plugins/observability/public/hooks/create_use_rules_link.ts index c789fb73ae45..5d50efa31a0b 100644 --- a/x-pack/plugins/observability/public/hooks/create_use_rules_link.ts +++ b/x-pack/plugins/observability/public/hooks/create_use_rules_link.ts @@ -4,15 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { - UseLinkPropsOptions, - useLinkProps, - type LinkDescriptor, -} from '@kbn/observability-shared-plugin/public'; -import rison from '@kbn/rison'; -import { useLocation } from 'react-router-dom'; -import useObservable from 'react-use/lib/useObservable'; -import { useKibana } from '../utils/kibana_react'; +import { UseLinkPropsOptions, useLinkProps } from '@kbn/observability-shared-plugin/public'; export const createUseRulesLink = () => @@ -24,43 +16,3 @@ export const createUseRulesLink = return useLinkProps(linkProps, options); }; - -export const crateInfraNodeDetailsLink = - ({ - assetType, - assetId, - search, - }: { - assetType: 'host'; - assetId: string; - search: LinkDescriptor['search']; - }) => - (options: UseLinkPropsOptions = {}) => { - const location = useLocation(); - const { - services: { - application: { currentAppId$ }, - }, - } = useKibana(); - - const appId = useObservable(currentAppId$); - - const linkProps = { - app: 'metrics', - pathname: `link-to/${assetType}-detail/${assetId}`, - search: { - ...search, - ...(location.pathname - ? { - state: rison.encodeUnknown({ - originAppId: appId, - originPathname: location.pathname, - originSearch: location.search, - }), - } - : undefined), - }, - }; - - return useLinkProps(linkProps, options); - }; diff --git a/x-pack/plugins/observability/public/pages/overview/components/sections/metrics/host_link.tsx b/x-pack/plugins/observability/public/pages/overview/components/sections/metrics/host_link.tsx index 43ad5ff7e633..91db16d08144 100644 --- a/x-pack/plugins/observability/public/pages/overview/components/sections/metrics/host_link.tsx +++ b/x-pack/plugins/observability/public/pages/overview/components/sections/metrics/host_link.tsx @@ -5,37 +5,19 @@ * 2.0. */ import React from 'react'; -import rison from '@kbn/rison'; -import { EuiLink } from '@elastic/eui'; -import { crateInfraNodeDetailsLink } from '../../../../../hooks/create_use_rules_link'; import { StringOrNull } from '../../../../..'; interface Props { name: StringOrNull; - id: string; + id: StringOrNull; timerange: { from: number; to: number }; } export function HostLink({ name, id, timerange }: Props) { - const linkProps = crateInfraNodeDetailsLink({ - assetType: 'host', - assetId: id, - search: { - from: `${timerange.from}`, - to: `${timerange.to}`, - ...(!!name - ? { - assetDetails: rison.encodeUnknown({ - name, - }), - } - : undefined), - }, - })(); - + const link = `../../app/metrics/link-to/host-detail/${id}?from=${timerange.from}&to=${timerange.to}`; return ( - - {name} - + <> + {name} + ); }