Skip to content

Commit

Permalink
Add LinktoApp to host details for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-tavares committed Apr 7, 2020
1 parent 898504d commit 7ff7d04
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useNavigateToAppEventHandler } from '../hooks/use_navigate_to_app_event
export type LinkToAppProps = EuiLinkProps & {
/** the app id - normally the value of the `id` in that plugin's `kibana.json` */
appId: string;
/** Any app specic path (route) */
/** Any app specific path (route) */
appPath?: string;
appState?: any;
onClick?: MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useHostListSelector } from './hooks';
import { urlFromQueryParams } from './url_from_query_params';
import { FormattedDateAndTime } from '../formatted_date_time';
import { uiQueryParams, detailsData, detailsError } from './../../store/hosts/selectors';
import { LinkToApp } from '../../components/link_to_app';

const HostIds = styled(EuiListGroupItem)`
margin-top: 0;
Expand All @@ -37,6 +38,7 @@ const HostIds = styled(EuiListGroupItem)`
`;

const HostDetails = memo(({ details }: { details: HostMetadata }) => {
const { appId, appPath, url } = useHostLogsUrl(details.host.id);
const detailsResultsUpper = useMemo(() => {
return [
{
Expand Down Expand Up @@ -113,6 +115,15 @@ const HostDetails = memo(({ details }: { details: HostMetadata }) => {
listItems={detailsResultsLower}
data-test-subj="hostDetailsLowerList"
/>
<EuiHorizontalRule margin="s" />
<p>
<LinkToApp appId={appId} appPath={appPath} href={url}>
<FormattedMessage
id="xpack.endpoint.host.details.linkToLogsTitle"
defaultMessage="Endpoint Logs"
/>
</LinkToApp>
</p>
</>
);
});
Expand Down Expand Up @@ -170,3 +181,15 @@ export const HostDetailsFlyout = () => {
</EuiFlyout>
);
};

const useHostLogsUrl = (hostId: string): { url: string; appId: string; appPath: string } => {
const { services } = useKibana();
return useMemo(() => {
const appPath = `/stream?logFilter=(expression:host.id:${hostId},kind:kuery)`;
return {
url: `${services.application.getUrlForApp('logs')}${appPath}`,
appId: 'logs',
appPath,
};
}, [hostId, services.application]);
};

0 comments on commit 7ff7d04

Please sign in to comment.