diff --git a/x-pack/plugins/infra/public/alerting/inventory/components/expression.tsx b/x-pack/plugins/infra/public/alerting/inventory/components/expression.tsx index 340c00b9f48cc..6375a5032d365 100644 --- a/x-pack/plugins/infra/public/alerting/inventory/components/expression.tsx +++ b/x-pack/plugins/infra/public/alerting/inventory/components/expression.tsx @@ -19,8 +19,8 @@ import { EuiToolTip, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { css } from '@emotion/react'; import { FormattedMessage } from '@kbn/i18n-react'; -import { euiStyled } from '@kbn/kibana-react-plugin/common'; import { TimeUnitChar } from '@kbn/observability-plugin/common/utils/formatters/duration'; import { ForLastExpression, @@ -149,8 +149,8 @@ export const Expressions: React.FC = (props) => { ); const onFilterChange = useCallback( - (filter: any) => { - setRuleParams('filterQueryText', filter || ''); + (filter: string) => { + setRuleParams('filterQueryText', filter ?? ''); try { setRuleParams( 'filterQuery', @@ -257,7 +257,7 @@ export const Expressions: React.FC = (props) => { preFillAlertCriteria(); } - if (!ruleParams.filterQuery) { + if (ruleParams.filterQuery === undefined) { preFillAlertFilter(); } @@ -268,7 +268,7 @@ export const Expressions: React.FC = (props) => { return ( <> - +

= (props) => { />

- - - +
+ +
- - - - +
+
+
+ {ruleParams.criteria && ruleParams.criteria.map((e, idx) => { return ( @@ -315,7 +315,7 @@ export const Expressions: React.FC = (props) => { ); })} - +
= (props) => { onChangeWindowSize={updateTimeSize} onChangeWindowUnit={updateTimeUnit} /> - +
= (props) => {
- + = (props) => { onChange={(e) => setRuleParams('alertOnNoData', e.target.checked)} /> - + = (props) => { fullWidth display="rowCompressed" > - {(metadata && ( + {metadata ? ( - )) || ( + ) : ( = (props) => { )} - + ); }; @@ -415,21 +415,21 @@ interface ExpressionRowProps { fields: DerivedIndexPattern['fields']; } -const NonCollapsibleExpression = euiStyled.div` +const NonCollapsibleExpressionCss = css` margin-left: 28px; `; -const StyledExpressionRow = euiStyled(EuiFlexGroup)` +const StyledExpressionRowCss = css` display: flex; flex-wrap: wrap; margin: 0 -4px; `; -const StyledExpression = euiStyled.div` +const StyledExpressionCss = css` padding: 0 4px; `; -const StyledHealth = euiStyled(EuiHealth)` +const StyledHealthCss = css` margin-left: 4px; `; @@ -588,8 +588,8 @@ export const ExpressionRow: React.FC = (props) => { - - + +
= (props) => { customMetric={customMetric} fields={fields} /> - +
{!displayWarningThreshold && criticalThresholdExpression} -
+ {displayWarningThreshold && ( <> - + {criticalThresholdExpression} - + - - - + + + {warningThresholdExpression} - + - + = (props) => { )} iconSize="s" color="text" - iconType={'minusInCircleFilled'} + iconType="minusInCircleFilled" onClick={toggleWarningThreshold} /> - + )} {!displayWarningThreshold && ( <> {' '} - - + + = (props) => { defaultMessage="Add warning threshold" /> - + )}
@@ -674,15 +674,23 @@ export const ExpressionRow: React.FC = (props) => { aria-label={i18n.translate('xpack.infra.metrics.alertFlyout.removeCondition', { defaultMessage: 'Remove condition', })} - color={'danger'} - iconType={'trash'} + color="danger" + iconType="trash" onClick={() => remove(expressionId)} /> )} - {isExpanded ?
{children}
: null} - + {isExpanded ? ( +
+ {children} +
+ ) : null} + ); }; @@ -697,7 +705,7 @@ const ThresholdElement: React.FC<{ }> = ({ updateComparator, updateThreshold, threshold, metric, comparator, errors }) => { return ( <> - +
- +
{metric && (
- {metricUnit[metric]?.label || ''} + {metricUnit[metric]?.label || ''}
)}