Skip to content

Commit

Permalink
remove logs link and alerts count (elastic#70282)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlog authored Jun 30, 2020
1 parent 43bfa4a commit 04b8d10
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import React, { memo, useMemo } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { HostMetadata } from '../../../../../../common/endpoint/types';
import { useHostSelector, useHostLogsUrl, useAgentDetailsIngestUrl } from '../hooks';
import { useHostSelector, useAgentDetailsIngestUrl } from '../hooks';
import { useNavigateToAppEventHandler } from '../../../../../common/hooks/endpoint/use_navigate_to_app_event_handler';
import { policyResponseStatus, uiQueryParams } from '../../store/selectors';
import { POLICY_STATUS_TO_HEALTH_COLOR } from '../host_constants';
Expand Down Expand Up @@ -51,7 +51,6 @@ const LinkToExternalApp = styled.div`
const openReassignFlyoutSearch = '?openReassignFlyout=true';

export const HostDetails = memo(({ details }: { details: HostMetadata }) => {
const { url: logsUrl, appId: logsAppId, appPath: logsAppPath } = useHostLogsUrl(details.host.id);
const agentId = details.elastic.agent.id;
const {
url: agentDetailsUrl,
Expand All @@ -78,12 +77,6 @@ export const HostDetails = memo(({ details }: { details: HostMetadata }) => {
}),
description: <FormattedDateAndTime date={new Date(details['@timestamp'])} />,
},
{
title: i18n.translate('xpack.securitySolution.endpoint.host.details.alerts', {
defaultMessage: 'Alerts',
}),
description: '0',
},
];
}, [details]);

Expand Down Expand Up @@ -251,22 +244,6 @@ export const HostDetails = memo(({ details }: { details: HostMetadata }) => {
listItems={detailsResultsLower}
data-test-subj="hostDetailsLowerList"
/>
<EuiHorizontalRule margin="m" />
<LinkToExternalApp>
<LinkToApp
appId={logsAppId}
appPath={logsAppPath}
href={logsUrl}
data-test-subj="hostDetailsLinkToLogs"
>
<EuiIcon type="logsApp" className="linkToAppIcon" />
<FormattedMessage
id="xpack.securitySolution.endpoint.host.details.linkToLogsTitle"
defaultMessage="Endpoint Logs"
/>
<EuiIcon type="popout" className="linkToAppPopoutIcon" />
</LinkToApp>
</LinkToExternalApp>
</>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@ export function useHostSelector<TSelected>(selector: (state: HostState) => TSele
});
}

/**
* Returns an object that contains Kibana Logs app and URL information for a given host id
* @param hostId
*/
export 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]);
};

/**
* Returns an object that contains Ingest app and URL information
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ describe('when on the hosts page', () => {
agentId = hostDetails.metadata.elastic.agent.id;

coreStart.http.get.mockReturnValue(Promise.resolve(hostDetails));
coreStart.application.getUrlForApp.mockReturnValue('/app/logs');

reactTestingLibrary.act(() => {
history.push({
Expand Down Expand Up @@ -433,30 +432,6 @@ describe('when on the hosts page', () => {
});
});

it('should include the link to logs', async () => {
const renderResult = render();
const linkToLogs = await renderResult.findByTestId('hostDetailsLinkToLogs');
expect(linkToLogs).not.toBeNull();
expect(linkToLogs.textContent).toEqual('Endpoint Logs');
expect(linkToLogs.getAttribute('href')).toEqual(
"/app/logs/stream?logFilter=(expression:'host.id:1',kind:kuery)"
);
});

describe('when link to logs is clicked', () => {
beforeEach(async () => {
const renderResult = render();
const linkToLogs = await renderResult.findByTestId('hostDetailsLinkToLogs');
reactTestingLibrary.act(() => {
reactTestingLibrary.fireEvent.click(linkToLogs);
});
});

it('should navigate to logs without full page refresh', () => {
expect(coreStart.application.navigateToApp.mock.calls).toHaveLength(1);
});
});

describe('when showing host Policy Response panel', () => {
let renderResult: ReturnType<typeof render>;
beforeEach(async () => {
Expand Down

0 comments on commit 04b8d10

Please sign in to comment.