Skip to content

Commit

Permalink
Revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
crespocarlos committed Sep 7, 2023
1 parent 5c96178 commit 66c4980
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
() =>
Expand All @@ -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);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<EuiLink data-test-subj="o11yInfraNodeDetailsLink" {...linkProps}>
{name}
</EuiLink>
<>
<a href={link}>{name}</a>
</>
);
}

0 comments on commit 66c4980

Please sign in to comment.