From e730aa95e44eeef46856503a90f22c9e7def6c70 Mon Sep 17 00:00:00 2001 From: Zacqary Xeper Date: Tue, 23 Jun 2020 15:58:27 -0500 Subject: [PATCH] Fix bad merge and metrics explorer infinite loop --- .../use_metric_threshold_alert_prefill.ts | 11 ++-- .../infra/public/pages/metrics/index.tsx | 61 +++---------------- 2 files changed, 15 insertions(+), 57 deletions(-) diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metric_threshold_alert_prefill.ts b/x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metric_threshold_alert_prefill.ts index a11a57b90e605..366d6aa7003e6 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metric_threshold_alert_prefill.ts +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metric_threshold_alert_prefill.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { isEqual } from 'lodash'; import { useState } from 'react'; import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; @@ -14,18 +15,20 @@ interface MetricThresholdPrefillOptions { } export const useMetricThresholdAlertPrefill = () => { - const [{ groupBy, filterQuery, metrics }, setPrefillOptions] = useState< - MetricThresholdPrefillOptions - >({ + const [prefillOptionsState, setPrefillOptionsState] = useState({ groupBy: undefined, filterQuery: undefined, metrics: [], }); + const { groupBy, filterQuery, metrics } = prefillOptionsState; + return { groupBy, filterQuery, metrics, - setPrefillOptions, + setPrefillOptions(newState: MetricThresholdPrefillOptions) { + if (!isEqual(newState, prefillOptionsState)) setPrefillOptionsState(newState); + }, }; }; diff --git a/x-pack/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx index 495c3f1febb60..fd30a10879441 100644 --- a/x-pack/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -11,6 +11,7 @@ import { Route, RouteComponentProps, Switch } from 'react-router-dom'; import { EuiErrorBoundary, EuiFlexItem, EuiFlexGroup, EuiButtonEmpty } from '@elastic/eui'; import { DocumentTitle } from '../../components/document_title'; +import { HelpCenterContent } from '../../components/help_center_content'; import { RoutedTabs } from '../../components/navigation/routed_tabs'; import { ColumnarPage } from '../../components/page'; import { Header } from '../../components/header'; @@ -55,6 +56,13 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => { })} /> + +
{ -
- - - - - - - - - - - -