Skip to content

Commit 03e299f

Browse files
authored
[Infra] Fix types in alerting Threshold (#206133)
## Summary This fixes bad typings for `chartProps` from #202405. At some point we started passing the eui theme to the chart props in `x-pack/solutions/observability/plugins/infra/public/alerting/log_threshold/components/alert_details_app_section/index.tsx`. The `chartProps.theme` is meant only to be the chart `PartialTheme` which can override settings from the `baseTheme`.
1 parent eddbbb1 commit 03e299f

File tree

2 files changed

+5
-7
lines changed
  • x-pack/solutions/observability/plugins/infra/public/alerting

2 files changed

+5
-7
lines changed

x-pack/solutions/observability/plugins/infra/public/alerting/common/components/threshold.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
import React from 'react';
99
import { Chart, Metric, Settings } from '@elastic/charts';
10-
import { EuiIcon, EuiPanel, type UseEuiTheme, useEuiTheme } from '@elastic/eui';
10+
import { EuiIcon, EuiPanel, useEuiTheme } from '@elastic/eui';
1111
import type { PartialTheme, Theme } from '@elastic/charts';
1212
import { i18n } from '@kbn/i18n';
1313
import type { COMPARATORS } from '@kbn/alerting-comparators';
1414

1515
export interface ChartProps {
16-
theme?: UseEuiTheme<{}>;
16+
theme?: PartialTheme;
1717
baseTheme: Theme;
1818
}
1919

@@ -57,7 +57,7 @@ export const Threshold = ({
5757
data-test-subj={`threshold-${thresholds.join('-')}-${value}`}
5858
>
5959
<Chart>
60-
<Settings theme={theme as PartialTheme} baseTheme={baseTheme} locale={i18n.getLocale()} />
60+
<Settings theme={theme} baseTheme={baseTheme} locale={i18n.getLocale()} />
6161
<Metric
6262
id={id}
6363
data={[

x-pack/solutions/observability/plugins/infra/public/alerting/log_threshold/components/alert_details_app_section/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
ALERT_START,
1515
} from '@kbn/rule-data-utils';
1616
import moment from 'moment';
17-
import { useTheme } from '@emotion/react';
1817
import { EuiTitle } from '@elastic/eui';
1918
import { i18n } from '@kbn/i18n';
2019
import { getPaddedAlertTimeRange } from '@kbn/observability-get-padded-alert-time-range-util';
@@ -39,7 +38,6 @@ const formatThreshold = (threshold: number) => String(threshold);
3938

4039
const AlertDetailsAppSection = ({ rule, alert }: AlertDetailsAppSectionProps) => {
4140
const { logsShared } = useKibanaContextForPlugin().services;
42-
const theme = useTheme();
4341
const baseTheme = useElasticChartsTheme();
4442
const timeRange = getPaddedAlertTimeRange(alert.fields[ALERT_START]!, alert.fields[ALERT_END]);
4543
const alertEnd = alert.fields[ALERT_END] ? moment(alert.fields[ALERT_END]).valueOf() : undefined;
@@ -94,7 +92,7 @@ const AlertDetailsAppSection = ({ rule, alert }: AlertDetailsAppSectionProps) =>
9492
<EuiSpacer size="s" />
9593
<Threshold
9694
title={`Threshold breached`}
97-
chartProps={{ theme, baseTheme }}
95+
chartProps={{ baseTheme }}
9896
comparator={ComparatorToi18nSymbolsMap[rule.params.count.comparator]}
9997
id={'threshold-ratio-chart'}
10098
thresholds={[rule.params.count.value]}
@@ -161,7 +159,7 @@ const AlertDetailsAppSection = ({ rule, alert }: AlertDetailsAppSectionProps) =>
161159
<EuiSpacer size="s" />
162160
<Threshold
163161
title={`Threshold breached`}
164-
chartProps={{ theme, baseTheme }}
162+
chartProps={{ baseTheme }}
165163
comparator={ComparatorToi18nSymbolsMap[rule.params.count.comparator]}
166164
id="logCountThreshold"
167165
thresholds={[rule.params.count.value]}

0 commit comments

Comments
 (0)