Skip to content

Commit

Permalink
Update EA page anomalies link to scroll down to the anomalies table (#…
Browse files Browse the repository at this point in the history
…143085)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
machadoum and kibanamachine authored Oct 12, 2022
1 parent 8c4976f commit fc2332f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const TABLE_SORTING = {
},
} as const;

export const ENTITY_ANALYTICS_ANOMALIES_PANEL = 'entity_analytics_anomalies';

export const EntityAnalyticsAnomalies = () => {
const {
services: { ml, http },
Expand Down Expand Up @@ -86,7 +88,7 @@ export const EntityAnalyticsAnomalies = () => {
}, [getSecuritySolutionLinkProps]);

return (
<EuiPanel hasBorder data-test-subj="entity_analytics_anomalies">
<EuiPanel hasBorder data-test-subj={ENTITY_ANALYTICS_ANOMALIES_PANEL}>
<HeaderSection
title={i18n.ANOMALIES_TITLE}
titleSize="s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React, { useMemo } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiTitle } from '@elastic/eui';
import React, { useMemo, useCallback } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiTitle, EuiLink } from '@elastic/eui';
import styled from 'styled-components';
import { useDispatch } from 'react-redux';
import { sumBy } from 'lodash/fp';
import { ML_PAGES, useMlHref } from '@kbn/ml-plugin/public';
import { useRiskScoreKpi } from '../../../../risk_score/containers';
import { LinkAnchor, useGetSecuritySolutionLinkProps } from '../../../../common/components/links';
import {
Expand All @@ -28,9 +27,9 @@ import { getTabsOnUsersUrl } from '../../../../common/components/link_to/redirec
import { UsersTableType } from '../../../../users/store/model';
import { useNotableAnomaliesSearch } from '../../../../common/components/ml/anomaly/use_anomalies_search';
import { useGlobalTime } from '../../../../common/containers/use_global_time';
import { useKibana } from '../../../../common/lib/kibana';
import { useMlCapabilities } from '../../../../common/components/ml/hooks/use_ml_capabilities';
import { useQueryInspector } from '../../../../common/components/page/manage_query';
import { ENTITY_ANALYTICS_ANOMALIES_PANEL } from '../anomalies';

const StyledEuiTitle = styled(EuiTitle)`
color: ${({ theme: { eui } }) => eui.euiColorDanger};
Expand Down Expand Up @@ -74,10 +73,6 @@ export const EntityAnalyticsHeader = () => {
const getSecuritySolutionLinkProps = useGetSecuritySolutionLinkProps();
const isPlatinumOrTrialLicense = useMlCapabilities().isPlatinumOrTrialLicense;

const {
services: { ml, http },
} = useKibana();

const [goToHostRiskTabFilteredByCritical, hostRiskTabUrl] = useMemo(() => {
const { onClick, href } = getSecuritySolutionLinkProps({
deepLinkId: SecurityPageName.hosts,
Expand Down Expand Up @@ -151,9 +146,14 @@ export const EntityAnalyticsHeader = () => {
[data, areJobsEnabled]
);

const jobsUrl = useMlHref(ml, http.basePath.get(), {
page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE,
});
const scrollToAnomalies = useCallback(() => {
const element = document.querySelector<HTMLElement>(
`[data-test-subj="${ENTITY_ANALYTICS_ANOMALIES_PANEL}"]`
);
if (element) {
element.scrollIntoView({ behavior: 'smooth' });
}
}, []);

return (
<EuiPanel hasBorder paddingSize="l">
Expand Down Expand Up @@ -211,9 +211,9 @@ export const EntityAnalyticsHeader = () => {
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
<LinkAnchor data-test-subj="all_anomalies_link" href={jobsUrl} target="_blank">
<EuiLink data-test-subj="all_anomalies_link" onClick={scrollToAnomalies}>
{i18n.ANOMALIES}
</LinkAnchor>
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down

0 comments on commit fc2332f

Please sign in to comment.