Skip to content

Commit

Permalink
Fix bad merge and metrics explorer infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Jun 23, 2020
1 parent e5f7318 commit e730aa9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -14,18 +15,20 @@ interface MetricThresholdPrefillOptions {
}

export const useMetricThresholdAlertPrefill = () => {
const [{ groupBy, filterQuery, metrics }, setPrefillOptions] = useState<
MetricThresholdPrefillOptions
>({
const [prefillOptionsState, setPrefillOptionsState] = useState<MetricThresholdPrefillOptions>({
groupBy: undefined,
filterQuery: undefined,
metrics: [],
});

const { groupBy, filterQuery, metrics } = prefillOptionsState;

return {
groupBy,
filterQuery,
metrics,
setPrefillOptions,
setPrefillOptions(newState: MetricThresholdPrefillOptions) {
if (!isEqual(newState, prefillOptionsState)) setPrefillOptionsState(newState);
},
};
};
61 changes: 8 additions & 53 deletions x-pack/plugins/infra/public/pages/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -55,6 +56,13 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
})}
/>

<HelpCenterContent
feedbackLink="https://discuss.elastic.co/c/metrics"
appName={i18n.translate('xpack.infra.header.infrastructureHelpAppName', {
defaultMessage: 'Metrics',
})}
/>

<Header
breadcrumbs={[
{
Expand Down Expand Up @@ -120,59 +128,6 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
</EuiFlexGroup>
</AppNavigation>

<Header
breadcrumbs={[
{
text: i18n.translate('xpack.infra.header.infrastructureTitle', {
defaultMessage: 'Metrics',
}),
},
]}
readOnlyBadge={!uiCapabilities?.infrastructure?.save}
/>
<AppNavigation
aria-label={i18n.translate('xpack.infra.header.infrastructureNavigationTitle', {
defaultMessage: 'Metrics',
})}
>
<EuiFlexGroup gutterSize={'none'} alignItems={'center'}>
<EuiFlexItem>
<RoutedTabs
tabs={[
{
app: 'metrics',
title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', {
defaultMessage: 'Inventory',
}),
pathname: '/inventory',
},
{
app: 'metrics',
title: i18n.translate(
'xpack.infra.homePage.metricsExplorerTabTitle',
{
defaultMessage: 'Metrics Explorer',
}
),
pathname: '/explorer',
},
{
app: 'metrics',
title: i18n.translate('xpack.infra.homePage.settingsTabTitle', {
defaultMessage: 'Settings',
}),
pathname: '/settings',
},
]}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<Route path={'/explorer'} component={MetricsAlertDropdown} />
<Route path={'/inventory'} component={InventoryAlertDropdown} />
</EuiFlexItem>
</EuiFlexGroup>
</AppNavigation>

<Switch>
<Route path={'/inventory'} component={SnapshotPage} />
<Route
Expand Down

0 comments on commit e730aa9

Please sign in to comment.