Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EA page anomalies link to scroll down to the anomalies table #143085

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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