Skip to content

Commit

Permalink
fixed due to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Mar 18, 2020
1 parent 4081635 commit c8df66c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function getAlertType(): AlertTypeModel {
)
);
}
if (!threshold || threshold.length === 0 || (threshold.length === 1 && !threshold[0])) {
if (!threshold || threshold.length === 0) {
errors.threshold0.push(
i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredThreshold0Text', {
defaultMessage: 'Threshold0, is required.',
Expand All @@ -110,9 +110,12 @@ export function getAlertType(): AlertTypeModel {
}
if (threshold && threshold.length === 2 && threshold[0] > threshold[1]) {
errors.threshold1.push(
i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredThreshold1Text', {
defaultMessage: 'Threshold1 should be > Threshold0.',
})
i18n.translate(
'xpack.triggersActionsUI.sections.addAlert.error.greaterThenThreshold0Text',
{
defaultMessage: 'Threshold1 should be > Threshold0.',
}
)
);
}
return validationResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ export const ThresholdExpression = ({
value={thresholdComparator}
onChange={e => {
onChangeSelectedThresholdComparator(e.target.value);
const thresholdValues: number[] | undefined = [];
Array.from(Array(comparators[e.target.value].requiredValues)).map((_notUsed, i) => {
thresholdValues.push(threshold[i] ?? 0);
});
const thresholdValues = threshold.slice(
0,
comparators[e.target.value].requiredValues
);
onChangeSelectedThreshold(thresholdValues);
}}
options={Object.values(comparators).map(({ text, value }) => {
Expand Down

0 comments on commit c8df66c

Please sign in to comment.