From 17413715b8ad05dd546bfebf2d7f2501ec421df4 Mon Sep 17 00:00:00 2001 From: Amardeepsingh Siglani Date: Tue, 1 Aug 2023 18:10:47 -0700 Subject: [PATCH] added another invalid trigger check (#668) Signed-off-by: Amardeepsingh Siglani --- .../FormControls/FormikInputWrapper/FormikInputWrapper.js | 2 +- .../CompositeTriggerCondition/ExpressionBuilder.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/public/components/FormControls/FormikInputWrapper/FormikInputWrapper.js b/public/components/FormControls/FormikInputWrapper/FormikInputWrapper.js index f17edd8cc..5f716622e 100644 --- a/public/components/FormControls/FormikInputWrapper/FormikInputWrapper.js +++ b/public/components/FormControls/FormikInputWrapper/FormikInputWrapper.js @@ -15,7 +15,7 @@ const FormikInputWrapper = ({ name, fieldProps, render }) => ( FormikInputWrapper.propTypes = { name: PropTypes.string.isRequired, - fieldProps: PropTypes.object.isRequired, + fieldProps: PropTypes.object, render: PropTypes.func.isRequired, }; diff --git a/public/pages/CreateTrigger/components/CompositeTriggerCondition/ExpressionBuilder.js b/public/pages/CreateTrigger/components/CompositeTriggerCondition/ExpressionBuilder.js index 2a3b929da..f32d136dd 100644 --- a/public/pages/CreateTrigger/components/CompositeTriggerCondition/ExpressionBuilder.js +++ b/public/pages/CreateTrigger/components/CompositeTriggerCondition/ExpressionBuilder.js @@ -228,7 +228,8 @@ const ExpressionBuilder = ({ ); const hasInvalidExpression = () => - !!usedExpressions.filter((expression) => expression.monitor_id === '')?.length; + !!usedExpressions.filter((expression) => expression.monitor_id === '')?.length || + options.length < usedExpressions.length; const isValid = () => options.length > 1 && usedExpressions.length > 1 && !hasInvalidExpression(); @@ -236,6 +237,9 @@ const ExpressionBuilder = ({ if (options.length < 2) return 'Trigger condition requires at least two associated monitors.'; if (usedExpressions.length < 2) return 'Trigger condition requires at least two monitors selected.'; + if (options.length < usedExpressions.length) { + return 'Trigger condition is using unselected Delegate monitor.'; + } if (hasInvalidExpression()) return 'Invalid expressions.'; }; @@ -307,7 +311,7 @@ const ExpressionBuilder = ({ validate(), + validate, }} render={({ form }) => (