Skip to content

Commit e730aa9

Browse files
committed
Fix bad merge and metrics explorer infinite loop
1 parent e5f7318 commit e730aa9

2 files changed

Lines changed: 15 additions & 57 deletions

File tree

x-pack/plugins/infra/public/alerting/metric_threshold/hooks/use_metric_threshold_alert_prefill.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { isEqual } from 'lodash';
78
import { useState } from 'react';
89
import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer';
910

@@ -14,18 +15,20 @@ interface MetricThresholdPrefillOptions {
1415
}
1516

1617
export const useMetricThresholdAlertPrefill = () => {
17-
const [{ groupBy, filterQuery, metrics }, setPrefillOptions] = useState<
18-
MetricThresholdPrefillOptions
19-
>({
18+
const [prefillOptionsState, setPrefillOptionsState] = useState<MetricThresholdPrefillOptions>({
2019
groupBy: undefined,
2120
filterQuery: undefined,
2221
metrics: [],
2322
});
2423

24+
const { groupBy, filterQuery, metrics } = prefillOptionsState;
25+
2526
return {
2627
groupBy,
2728
filterQuery,
2829
metrics,
29-
setPrefillOptions,
30+
setPrefillOptions(newState: MetricThresholdPrefillOptions) {
31+
if (!isEqual(newState, prefillOptionsState)) setPrefillOptionsState(newState);
32+
},
3033
};
3134
};

x-pack/plugins/infra/public/pages/metrics/index.tsx

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Route, RouteComponentProps, Switch } from 'react-router-dom';
1111

1212
import { EuiErrorBoundary, EuiFlexItem, EuiFlexGroup, EuiButtonEmpty } from '@elastic/eui';
1313
import { DocumentTitle } from '../../components/document_title';
14+
import { HelpCenterContent } from '../../components/help_center_content';
1415
import { RoutedTabs } from '../../components/navigation/routed_tabs';
1516
import { ColumnarPage } from '../../components/page';
1617
import { Header } from '../../components/header';
@@ -55,6 +56,13 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
5556
})}
5657
/>
5758

59+
<HelpCenterContent
60+
feedbackLink="https://discuss.elastic.co/c/metrics"
61+
appName={i18n.translate('xpack.infra.header.infrastructureHelpAppName', {
62+
defaultMessage: 'Metrics',
63+
})}
64+
/>
65+
5866
<Header
5967
breadcrumbs={[
6068
{
@@ -120,59 +128,6 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
120128
</EuiFlexGroup>
121129
</AppNavigation>
122130

123-
<Header
124-
breadcrumbs={[
125-
{
126-
text: i18n.translate('xpack.infra.header.infrastructureTitle', {
127-
defaultMessage: 'Metrics',
128-
}),
129-
},
130-
]}
131-
readOnlyBadge={!uiCapabilities?.infrastructure?.save}
132-
/>
133-
<AppNavigation
134-
aria-label={i18n.translate('xpack.infra.header.infrastructureNavigationTitle', {
135-
defaultMessage: 'Metrics',
136-
})}
137-
>
138-
<EuiFlexGroup gutterSize={'none'} alignItems={'center'}>
139-
<EuiFlexItem>
140-
<RoutedTabs
141-
tabs={[
142-
{
143-
app: 'metrics',
144-
title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', {
145-
defaultMessage: 'Inventory',
146-
}),
147-
pathname: '/inventory',
148-
},
149-
{
150-
app: 'metrics',
151-
title: i18n.translate(
152-
'xpack.infra.homePage.metricsExplorerTabTitle',
153-
{
154-
defaultMessage: 'Metrics Explorer',
155-
}
156-
),
157-
pathname: '/explorer',
158-
},
159-
{
160-
app: 'metrics',
161-
title: i18n.translate('xpack.infra.homePage.settingsTabTitle', {
162-
defaultMessage: 'Settings',
163-
}),
164-
pathname: '/settings',
165-
},
166-
]}
167-
/>
168-
</EuiFlexItem>
169-
<EuiFlexItem grow={false}>
170-
<Route path={'/explorer'} component={MetricsAlertDropdown} />
171-
<Route path={'/inventory'} component={InventoryAlertDropdown} />
172-
</EuiFlexItem>
173-
</EuiFlexGroup>
174-
</AppNavigation>
175-
176131
<Switch>
177132
<Route path={'/inventory'} component={SnapshotPage} />
178133
<Route

0 commit comments

Comments
 (0)