From e22f6e470908c0025efa30a7ba4ab9b194dea7c1 Mon Sep 17 00:00:00 2001 From: monilprajapati Date: Wed, 24 Jul 2024 13:17:42 +0530 Subject: [PATCH] Added error in Auth field for unescaped dollar --- frontend/src/components/ParsedAction.jsx | 37 +++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/ParsedAction.jsx b/frontend/src/components/ParsedAction.jsx index 208b822e..31378963 100755 --- a/frontend/src/components/ParsedAction.jsx +++ b/frontend/src/components/ParsedAction.jsx @@ -566,10 +566,11 @@ const ParsedAction = (props) => { let actions = workflow.actions?.map((action) => { return "$"+action.label.toLowerCase(); }) - if(newActionList.length > 0){ + if(newActionList?.length > 0){ let appParentActions = parentActionList?.map(action => "$" + action.name.toLowerCase()); let notPresentAction = actions?.filter((action) => !appParentActions?.includes(action)) notPresentAction?.forEach((action) => { + action = action.replace(" ", "_"); if(paramvalue.includes(action)){ errorVars.push(action); // paramvalue = paramvalue.replace(action, "") @@ -582,9 +583,20 @@ const ParsedAction = (props) => { let message = ""; if(errorVars.length > 0){ if(errorVars.length === 1){ - message = errorVars[0] + " is not accessible in this action"; + message = errorVars[0] + " is not accessible in this action."; }else{ - message = errorVars.join(", ") + " are not accessible in this action"; + message = errorVars.join(", ") + " are not accessible in this action."; + } + } + + if (param?.configuration) { + let regex = /(^|[^\\])\$/; + if (regex.test(paramvalue)) { + if(message.length > 0){ + message += "\nUse \"\\$\" instead of \"$\"."; + }else{ + message = "Use \"\\$\" instead of \"$\"."; + } } } return {...param, value: paramvalue, error: message} @@ -1137,6 +1149,15 @@ const ParsedAction = (props) => { return helperText } + const errorHelperText = (name, value, error) => { + return ( +
+ {error} +
+ ); + } + + const analyzeFields = () => { if (selectedAction === undefined || selectedAction === null) { @@ -3169,7 +3190,7 @@ const ParsedAction = (props) => { error={ data?.error?.length > 0 ? true : false } - helperText={data?.error?.length > 0 ? data.error : returnHelperText(data.name, data.value)} + helperText={data?.error?.length > 0 ? errorHelperText(data?.name,data?.value,data?.error) : returnHelperText(data.name, data.value)} //options={{ // theme: 'gruvbox-dark', // keyMap: 'sublime', @@ -3946,6 +3967,14 @@ const ParsedAction = (props) => { - Description: {description} + { + data?.configuration ? + ( + + - Use "\$" instead of "$" + + ) : null + } );